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 1.4.3 to 1.4.4

2

build-style.config.js

@@ -6,3 +6,3 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin')

var styleConfig = CONFIG.style || {}
var mainFile = styleConfig.main || './index.styl'
var mainFile = styleConfig.main || './style/index.styl'

@@ -9,0 +9,0 @@ module.exports = {

@@ -63,2 +63,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

var copyUtils = __webpack_require__(8)
var copy = copyUtils.copy

@@ -156,3 +157,3 @@ var copyList = copyUtils.copyList

getViewDate: function() {
return this.state.viewMoment || this.props.viewDate || this.props.date || this.now
return this.state.viewMoment || this.viewMoment || this.props.viewDate || this.props.date || this.now
},

@@ -167,3 +168,3 @@

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

@@ -278,7 +279,7 @@ props.renderDay = this.props.renderDay

React.createElement("tr", {className: "dp-row"},
React.createElement("td", {className: "dp-prev-nav dp-nav-cell dp-cell", onClick: this.handlePrevNav}, prev),
React.createElement("td", {className: "dp-prev-nav dp-nav-cell dp-cell", onClick: this.handleNavPrev}, prev),
React.createElement("td", {className: "dp-nav-view dp-cell ", colSpan: colspan, onClick: this.handleViewChange}, headerText),
React.createElement("td", {className: "dp-next-nav dp-nav-cell dp-cell", onClick: this.handleNextNav}, next)
React.createElement("td", {className: "dp-next-nav dp-nav-cell dp-cell", onClick: this.handleNavNext}, next)
)

@@ -332,3 +333,3 @@ ))

handlePrevNav: function(event) {
handleNavPrev: function(event) {
var viewMoment = this.getPrev()

@@ -348,3 +349,3 @@

handleNextNav: function(event) {
handleNavNext: function(event) {
var viewMoment = this.getNext()

@@ -367,2 +368,16 @@

var viewDate = moment(this.getViewDate())
//it's not enough to compare months, since the year can change as well
//
//also it's ok to hardcode the format here
var viewMonth = viewDate.format('YYYY-MM')
var dateMonth = date.format('YYYY-MM')
if (dateMonth > viewMonth){
this.handleNavNext(event)
} else if (dateMonth < viewMonth){
this.handleNavPrev(event)
}
var text = date.format(this.props.dateFormat)

@@ -369,0 +384,0 @@

@@ -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(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(){}var a=r(5),o=r(1),s=r(2),i=(s.copy,s.copyList,r(4)),p=r(16),c=r(17),d=r(15),u={month:p,year:c,decade:d},h=(r(10),a.createClass({displayName:"DatePicker",propTypes:{todayText:a.PropTypes.string,gotoSelectedText:a.PropTypes.string,renderFooter:a.PropTypes.func,onChange:a.PropTypes.func,date:a.PropTypes.any,viewDate:a.PropTypes.any},getInitialState:function(){return{}},getDefaultProps:function(){return i()},getViewName:function(){return this.state.view||this.props.view||"month"},getViewOrder:function(){return["month","year","decade"]},addViewIndex:function(e){var t=this.getViewName(),r=this.getViewOrder(),n=r.indexOf(t);return n+=e,n%r.length},getNextViewName:function(){return this.getViewOrder()[this.addViewIndex(1)]},getPrevViewName:function(){return this.getViewOrder()[this.addViewIndex(-1)]},getView:function(){return u[this.getViewName()]||u.month},getViewFactory:function(){var e=this.getView();return a.createFactory&&(e.__factory=e.__factory||a.createFactory(e),e=e.__factory),e},getViewDate:function(){return this.state.viewMoment||this.props.viewDate||this.props.date||this.now},render:function(){this.now=+new Date;var e=this.getViewFactory(),t=i(this.props);t.viewDate=this.getViewDate(),t.renderDay=this.props.renderDay,t.onRenderDay=this.props.onRenderDay,t.onChange=this.handleChange,t.onSelect=this.handleSelect;var r=(this.props.className||"")+" date-picker";return a.createElement("div",a.__spread({className:r},this.props),a.createElement("div",{className:"dp-inner"},this.renderHeader(e),a.createElement("div",{className:"dp-body"},a.createElement("div",{className:"dp-anim-target"},e(t))),this.renderFooter(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,r=this.props.todayText||"Today",n=this.props.gotoSelectedText||"Go to selected",o={todayText:r,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:a.createElement("div",{className:"dp-footer"},a.createElement("div",{className:"dp-footer-today",onClick:this.gotoNow},r),a.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.setState({view:"month",viewMoment:o(e)})},getViewColspan:function(){var e={month:5,year:2,decade:2};return e[this.getViewName()]},renderHeader:function(){var e=this.getViewDate(),t=this.getView().getHeaderText(e),r=this.getViewColspan(),n=this.props.navPrev,o=this.props.navNext;return a.createElement("div",{className:"dp-header"},a.createElement("table",{className:"dp-nav-table"},a.createElement("tbody",null,a.createElement("tr",{className:"dp-row"},a.createElement("td",{className:"dp-prev-nav dp-nav-cell dp-cell",onClick:this.handlePrevNav},n),a.createElement("td",{className:"dp-nav-view dp-cell ",colSpan:r,onClick:this.handleViewChange},t),a.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:this.handleNextNav},o)))))},handleRenderDay:function(e){return(this.props.renderDay||n)(e)||[]},handleViewChange:function(){this.setState({view:this.getNextViewName()})},getNext:function(){var e=this.getViewDate();return{month:function(){return o(e).add(1,"month")},year:function(){return o(e).add(1,"year")},decade:function(){return o(e).add(10,"year")}}[this.getViewName()]()},getPrev:function(){var e=this.getViewDate();return{month:function(){return o(e).add(-1,"month")},year:function(){return o(e).add(-1,"year")},decade:function(){return o(e).add(-10,"year")}}[this.getViewName()]()},handlePrevNav:function(e){var t=this.getPrev();if(this.setState({viewMoment:t}),"function"==typeof this.props.onNav){var r=t.format(this.props.dateFormat),n=this.getViewName();this.props.onNav(t,r,n,-1,e)}},handleNextNav:function(e){var t=this.getNext();if(this.setState({viewMoment:t}),"function"==typeof this.props.onNav){var r=t.format(this.props.dateFormat),n=this.getViewName();this.props.onNav(t,r,n,1,e)}},handleChange:function(e,t){e=o(e);var r=e.format(this.props.dateFormat);(this.props.onChange||n)(e,r,t)},handleSelect:function(e,t){var r=this.getViewName(),n={decade:"year",year:"month"}[r],a=e.get(n),s=o(this.getViewDate()).set(n,a),i=this.getPrevViewName();if(this.setState({viewMoment:s,view:i}),"function"==typeof this.props.onSelect){var p=s.format(this.props.dateFormat);this.props.onSelect(s,p,i,t)}}}));e.exports=h},function(t){t.exports=e},function(e,t,r){e.exports=function(){"use strict";var e=Object.prototype.hasOwnProperty,t="object",n="undefined";return{copy:r(11),copyIf:r(12),copyAs:function(r,n){var a={};if(n=n||1,null!=r&&typeof r===t)for(var o in r)e.call(r,o)&&(a[o]=n);return a},copyList:r(8),copyListIf:r(9),copyKeys:r(13),copyKeysIf:r(14),copyExceptKeys:function(r,n,a){if(n=n||{},a=a||{},null!=r&&typeof r===t)for(var o in r)e.call(r,o)&&!e.call(a,o)&&(n[o]=r[o]);return n},bindCopyKeys:function(r,a,o){if(2==arguments.length&&(o=a,a=null),a=a||{},null!=r&&typeof r===t&&null!=o&&typeof o===t){var s,i,p,c;for(var d in o)e.call(o,d)&&(i=o[d],s=typeof i,c=r[d],p=typeof c,p!==n&&(a["string"==s?i:d]="function"==p?c.bind(r):c))}return a}}}()},function(e,t,r){"use strict";var n=r(1),a=r(6);e.exports=function(e,t,r){var o=!(!r||!r.strict);return t=t||a.dateFormat,"string"==typeof e?n(e,t,o):n(null==e?new Date:e)}},function(e,t,r){"use strict";var n=r(2),a=n.copy,o=n.copyList,s=r(6),i=Object.keys(s);e.exports=function(e,t){var r=i;return t&&(r=Object.keys(t)),t=t||s,e?o(e,a(t),r):a(t)}},function(e){e.exports=t},function(e,t,r){"use strict";var n=r(10);e.exports={weekDayNames:n(),weekStartDay:0,dayFormat:"D",monthFormat:"MMMM",yearFormat:"YYYY",navPrev:"‹",navNext:"›",view:"month",date:null,minDate:null,maxDate:null,viewDate:null,dateFormat:"YYYY-MM-DD"}},function(e,t,r){"use strict";function n(e,t){return o(e).format(t)}var a=r(6),o=r(3);e.exports={day:function(e,t){return n(e,t||a.dayFormat)},month:function(e,t){return n(e,t||a.monthFormat)},year:function(e,t){return n(e,t||a.yearFormat)}}},function(e){"use strict";var t="undefined";e.exports=function(e,r,n){arguments.length<3&&(n=r,r=null),r=r||{},n=n||Object.keys(e);for(var a,o=0,s=n.length;s>o;o++)a=n[o],typeof e[a]!==t&&(r[n[o]]=e[n[o]]);return r}},function(e){"use strict";var t="undefined";e.exports=function(e,r,n){arguments.length<3&&(n=r,r=null),r=r||{},n=n||Object.keys(e);for(var a,o=0,s=n.length;s>o;o++)a=n[o],typeof e[a]!==t&&typeof r[a]===t&&(r[a]=e[a]);return r}},function(e,t,r){"use strict";var n=r(1),a=1*n().startOf("week").format("d");e.exports=function(e){for(var t=n.weekdaysShort(),r=e||a;r>0;)t.push(t.shift()),r--;return t}},function(e){"use strict";var t=Object.prototype.hasOwnProperty,r="object";e.exports=function(e,n){if(n=n||{},null!=e&&typeof e===r)for(var a in e)t.call(e,a)&&(n[a]=e[a]);return n}},function(e){"use strict";var t=Object.prototype.hasOwnProperty,r="object",n="undefined";e.exports=function(e,a){if(a=a||{},null!=e&&typeof e===r)for(var o in e)t.call(e,o)&&typeof a[o]===n&&(a[o]=e[o]);return a}},function(e,t,r){"use strict";var n="undefined",a="object",o=Object.prototype.hasOwnProperty,s=r(8);e.exports=function(e,t,r){if(arguments.length<3&&(r=t,t=null),t=t||{},!r||Array.isArray(r))return s(e,t,r);if(null!=e&&typeof e===a&&null!=r&&typeof r===a){var i,p;for(var c in r)o.call(r,c)&&(p=r[c],i=typeof p,typeof e[c]!==n&&(t["string"==i?p:c]=e[c]))}return t}},function(e,t,r){"use strict";var n="undefined",a="object",o=Object.prototype.hasOwnProperty,s=r(9);e.exports=function(e,t,r){if(arguments.length<3&&(r=t,t=null),t=t||{},!r||Array.isArray(r))return s(e,t,r);if(null!=e&&typeof e===a&&null!=r&&typeof r===a){var i,p,c;for(var d in r)o.call(r,d)&&(p=r[d],i=typeof p,c="string"==i?p:d,typeof e[d]!==n&&typeof t[c]===n&&(t[c]=e[d]))}return t}},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=(r(3),o.createClass({displayName:"DecadeView",getDefaultProps:function(){return c()},getYearsInDecade:function(e){var t=s(e).get("year"),r=t%10;t=t-r-1;for(var n=[],a=0,o=s(t,"YYYY").startOf("year");12>a;a++)n.push(s(o)),o.add(1,"year");return n},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("year"));var t=this.getYearsInDecade(e);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(t)))},renderYears:function(e){for(var t=e.map(this.renderYear,this),r=e.length,n=[],a=Math.ceil(r/4),s=0;a>s;s++)n.push(t.slice(4*s,4*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderYear:function(e,t,r){var n=p.year(e),a=["dp-cell dp-year"],s=+e;return s==this.props.moment&&a.push("dp-value"),t||a.push("dp-prev"),t==r.length-1&&a.push("dp-next"),o.createElement("td",{key:n,className:a.join(" "),onClick:this.handleClick.bind(this,e)},n)},handleClick:function(e,t){t.target.value=e,(this.props.onSelect||n)(e,t)}}));i({getHeaderText:function(e){var t=s(e).get("year"),r=t%10;return t=t-r-1,t+" - "+(t+11)}},d),e.exports=d},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=r(3),u=o.createClass({displayName:"MonthView",formatAsDay:function(e,t){return e.format(t||"D")},getDefaultProps:function(){return c()},getWeekStartMoment:function(e){var t=s(e).startOf("week");return t},getDaysInMonth:function(e){var t=s(e).startOf("month"),r=this.getWeekStartMoment(t),n=[],a=0;for(t.add(-1,"days").isBefore(r)&&r.add(-1,"weeks");42>a;a++)n.push(s(r)),r.add(1,"days");return n},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=d(this.props.viewDate,this.props.dateFormat);this.props.minDate&&(this.props.minDate=+d(this.props.minDate,this.props.dateFormat)),this.props.maxDate&&(this.props.maxDate=+d(this.props.maxDate,this.props.dateFormat)),this.props.minDate,this.monthFirst=s(e).startOf("month"),this.monthLast=s(e).endOf("month"),this.props.date&&(this.props.moment=s(this.props.date).startOf("day"));var t=this.getDaysInMonth(e);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(t)))},renderDays:function(e){for(var t=e.map(this.renderDay,this),r=e.length,n=[],a=Math.ceil(r/7),s=0;a>s;s++)n.push(t.slice(7*s,7*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t,className:"dp-week dp-row"},e)})},renderDay:function(e){var t=p.day(e),r=["dp-cell dp-day"],n=+e;n==a?r.push("dp-current"):n<this.monthFirst?r.push("dp-prev"):n>this.monthLast&&r.push("dp-next"),this.props.minDate&&e<this.props.minDate&&r.push("dp-disabled dp-before-min"),this.props.maxDate&&e>this.props.maxDate&&r.push("dp-disabled dp-after-max"),n==this.props.moment&&r.push("dp-value");var s={key:t,text:t,date:e,className:r.join(" "),style:{},onClick:this.handleClick.bind(this,e,n),children:t};"function"==typeof this.props.onRenderDay&&(s=this.props.onRenderDay(s));var i=o.DOM.td,c=this.props.renderDay||i,d=c(s);return void 0===d&&(d=i(s)),d},renderWeekDayNames:function(){var e=this.props.weekDayNames;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,r){this.props.minDate&&t<this.props.minDate||this.props.maxDate&&t>this.props.maxDate||(r.target.value=e,(this.props.onChange||n)(e,r))}});i({getHeaderText:function(e){return d(e).format("MMMM YYYY")}},u),e.exports=u},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=r(3),u=o.createClass({displayName:"YearView",getDefaultProps:function(){return c()},getMonthsInYear:function(e){for(var t=s(e).startOf("year"),r=[],n=0;12>n;n++)r.push(s(t)),t.add(1,"month");return r},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("month"));var t=this.getMonthsInYear(e);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(t)))},renderMonths:function(e){for(var t=e.map(this.renderMonth,this),r=e.length,n=[],a=Math.ceil(r/4),s=0;a>s;s++)n.push(t.slice(4*s,4*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderMonth:function(e){var t=p.month(e),r=["dp-cell dp-month"],n=+e;return n==this.props.moment&&r.push("dp-value"),o.createElement("td",{key:t,className:r.join(" "),onClick:this.handleClick.bind(this,e)},t)},handleClick:function(e,t){t.target.value=e,(this.props.onSelect||n)(e,t)}});i({getHeaderText:function(e){return d(e).format("YYYY")}},u),e.exports=u}])});
!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(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(){}var a=r(5),o=r(1),s=r(2),i=(s.copy,s.copyList,r(4)),p=r(16),c=r(17),d=r(15),u={month:p,year:c,decade:d},h=(r(10),a.createClass({displayName:"DatePicker",propTypes:{todayText:a.PropTypes.string,gotoSelectedText:a.PropTypes.string,renderFooter:a.PropTypes.func,onChange:a.PropTypes.func,date:a.PropTypes.any,viewDate:a.PropTypes.any},getInitialState:function(){return{}},getDefaultProps:function(){return i()},getViewName:function(){return this.state.view||this.props.view||"month"},getViewOrder:function(){return["month","year","decade"]},addViewIndex:function(e){var t=this.getViewName(),r=this.getViewOrder(),n=r.indexOf(t);return n+=e,n%r.length},getNextViewName:function(){return this.getViewOrder()[this.addViewIndex(1)]},getPrevViewName:function(){return this.getViewOrder()[this.addViewIndex(-1)]},getView:function(){return u[this.getViewName()]||u.month},getViewFactory:function(){var e=this.getView();return a.createFactory&&(e.__factory=e.__factory||a.createFactory(e),e=e.__factory),e},getViewDate:function(){return this.state.viewMoment||this.viewMoment||this.props.viewDate||this.props.date||this.now},render:function(){this.now=+new Date;var e=this.getViewFactory(),t=i(this.props);t.viewDate=this.viewMoment=this.getViewDate(),t.renderDay=this.props.renderDay,t.onRenderDay=this.props.onRenderDay,t.onChange=this.handleChange,t.onSelect=this.handleSelect;var r=(this.props.className||"")+" date-picker";return a.createElement("div",a.__spread({className:r},this.props),a.createElement("div",{className:"dp-inner"},this.renderHeader(e),a.createElement("div",{className:"dp-body"},a.createElement("div",{className:"dp-anim-target"},e(t))),this.renderFooter(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,r=this.props.todayText||"Today",n=this.props.gotoSelectedText||"Go to selected",o={todayText:r,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:a.createElement("div",{className:"dp-footer"},a.createElement("div",{className:"dp-footer-today",onClick:this.gotoNow},r),a.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.setState({view:"month",viewMoment:o(e)})},getViewColspan:function(){var e={month:5,year:2,decade:2};return e[this.getViewName()]},renderHeader:function(){var e=this.getViewDate(),t=this.getView().getHeaderText(e),r=this.getViewColspan(),n=this.props.navPrev,o=this.props.navNext;return a.createElement("div",{className:"dp-header"},a.createElement("table",{className:"dp-nav-table"},a.createElement("tbody",null,a.createElement("tr",{className:"dp-row"},a.createElement("td",{className:"dp-prev-nav dp-nav-cell dp-cell",onClick:this.handleNavPrev},n),a.createElement("td",{className:"dp-nav-view dp-cell ",colSpan:r,onClick:this.handleViewChange},t),a.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:this.handleNavNext},o)))))},handleRenderDay:function(e){return(this.props.renderDay||n)(e)||[]},handleViewChange:function(){this.setState({view:this.getNextViewName()})},getNext:function(){var e=this.getViewDate();return{month:function(){return o(e).add(1,"month")},year:function(){return o(e).add(1,"year")},decade:function(){return o(e).add(10,"year")}}[this.getViewName()]()},getPrev:function(){var e=this.getViewDate();return{month:function(){return o(e).add(-1,"month")},year:function(){return o(e).add(-1,"year")},decade:function(){return o(e).add(-10,"year")}}[this.getViewName()]()},handleNavPrev:function(e){var t=this.getPrev();if(this.setState({viewMoment:t}),"function"==typeof this.props.onNav){var r=t.format(this.props.dateFormat),n=this.getViewName();this.props.onNav(t,r,n,-1,e)}},handleNavNext:function(e){var t=this.getNext();if(this.setState({viewMoment:t}),"function"==typeof this.props.onNav){var r=t.format(this.props.dateFormat),n=this.getViewName();this.props.onNav(t,r,n,1,e)}},handleChange:function(e,t){e=o(e);var r=o(this.getViewDate()),a=r.format("YYYY-MM"),s=e.format("YYYY-MM");s>a?this.handleNavNext(t):a>s&&this.handleNavPrev(t);var i=e.format(this.props.dateFormat);(this.props.onChange||n)(e,i,t)},handleSelect:function(e,t){var r=this.getViewName(),n={decade:"year",year:"month"}[r],a=e.get(n),s=o(this.getViewDate()).set(n,a),i=this.getPrevViewName();if(this.setState({viewMoment:s,view:i}),"function"==typeof this.props.onSelect){var p=s.format(this.props.dateFormat);this.props.onSelect(s,p,i,t)}}}));e.exports=h},function(t){t.exports=e},function(e,t,r){e.exports=function(){"use strict";var e=Object.prototype.hasOwnProperty,t="object",n="undefined";return{copy:r(11),copyIf:r(12),copyAs:function(r,n){var a={};if(n=n||1,null!=r&&typeof r===t)for(var o in r)e.call(r,o)&&(a[o]=n);return a},copyList:r(8),copyListIf:r(9),copyKeys:r(13),copyKeysIf:r(14),copyExceptKeys:function(r,n,a){if(n=n||{},a=a||{},null!=r&&typeof r===t)for(var o in r)e.call(r,o)&&!e.call(a,o)&&(n[o]=r[o]);return n},bindCopyKeys:function(r,a,o){if(2==arguments.length&&(o=a,a=null),a=a||{},null!=r&&typeof r===t&&null!=o&&typeof o===t){var s,i,p,c;for(var d in o)e.call(o,d)&&(i=o[d],s=typeof i,c=r[d],p=typeof c,p!==n&&(a["string"==s?i:d]="function"==p?c.bind(r):c))}return a}}}()},function(e,t,r){"use strict";var n=r(1),a=r(6);e.exports=function(e,t,r){var o=!(!r||!r.strict);return t=t||a.dateFormat,"string"==typeof e?n(e,t,o):n(null==e?new Date:e)}},function(e,t,r){"use strict";var n=r(2),a=n.copy,o=n.copyList,s=r(6),i=Object.keys(s);e.exports=function(e,t){var r=i;return t&&(r=Object.keys(t)),t=t||s,e?o(e,a(t),r):a(t)}},function(e){e.exports=t},function(e,t,r){"use strict";var n=r(10);e.exports={weekDayNames:n(),weekStartDay:0,dayFormat:"D",monthFormat:"MMMM",yearFormat:"YYYY",navPrev:"‹",navNext:"›",view:"month",date:null,minDate:null,maxDate:null,viewDate:null,dateFormat:"YYYY-MM-DD"}},function(e,t,r){"use strict";function n(e,t){return o(e).format(t)}var a=r(6),o=r(3);e.exports={day:function(e,t){return n(e,t||a.dayFormat)},month:function(e,t){return n(e,t||a.monthFormat)},year:function(e,t){return n(e,t||a.yearFormat)}}},function(e){"use strict";var t="undefined";e.exports=function(e,r,n){arguments.length<3&&(n=r,r=null),r=r||{},n=n||Object.keys(e);for(var a,o=0,s=n.length;s>o;o++)a=n[o],typeof e[a]!==t&&(r[n[o]]=e[n[o]]);return r}},function(e){"use strict";var t="undefined";e.exports=function(e,r,n){arguments.length<3&&(n=r,r=null),r=r||{},n=n||Object.keys(e);for(var a,o=0,s=n.length;s>o;o++)a=n[o],typeof e[a]!==t&&typeof r[a]===t&&(r[a]=e[a]);return r}},function(e,t,r){"use strict";var n=r(1),a=1*n().startOf("week").format("d");e.exports=function(e){for(var t=n.weekdaysShort(),r=e||a;r>0;)t.push(t.shift()),r--;return t}},function(e){"use strict";var t=Object.prototype.hasOwnProperty,r="object";e.exports=function(e,n){if(n=n||{},null!=e&&typeof e===r)for(var a in e)t.call(e,a)&&(n[a]=e[a]);return n}},function(e){"use strict";var t=Object.prototype.hasOwnProperty,r="object",n="undefined";e.exports=function(e,a){if(a=a||{},null!=e&&typeof e===r)for(var o in e)t.call(e,o)&&typeof a[o]===n&&(a[o]=e[o]);return a}},function(e,t,r){"use strict";var n="undefined",a="object",o=Object.prototype.hasOwnProperty,s=r(8);e.exports=function(e,t,r){if(arguments.length<3&&(r=t,t=null),t=t||{},!r||Array.isArray(r))return s(e,t,r);if(null!=e&&typeof e===a&&null!=r&&typeof r===a){var i,p;for(var c in r)o.call(r,c)&&(p=r[c],i=typeof p,typeof e[c]!==n&&(t["string"==i?p:c]=e[c]))}return t}},function(e,t,r){"use strict";var n="undefined",a="object",o=Object.prototype.hasOwnProperty,s=r(9);e.exports=function(e,t,r){if(arguments.length<3&&(r=t,t=null),t=t||{},!r||Array.isArray(r))return s(e,t,r);if(null!=e&&typeof e===a&&null!=r&&typeof r===a){var i,p,c;for(var d in r)o.call(r,d)&&(p=r[d],i=typeof p,c="string"==i?p:d,typeof e[d]!==n&&typeof t[c]===n&&(t[c]=e[d]))}return t}},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=(r(3),o.createClass({displayName:"DecadeView",getDefaultProps:function(){return c()},getYearsInDecade:function(e){var t=s(e).get("year"),r=t%10;t=t-r-1;for(var n=[],a=0,o=s(t,"YYYY").startOf("year");12>a;a++)n.push(s(o)),o.add(1,"year");return n},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("year"));var t=this.getYearsInDecade(e);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(t)))},renderYears:function(e){for(var t=e.map(this.renderYear,this),r=e.length,n=[],a=Math.ceil(r/4),s=0;a>s;s++)n.push(t.slice(4*s,4*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderYear:function(e,t,r){var n=p.year(e),a=["dp-cell dp-year"],s=+e;return s==this.props.moment&&a.push("dp-value"),t||a.push("dp-prev"),t==r.length-1&&a.push("dp-next"),o.createElement("td",{key:n,className:a.join(" "),onClick:this.handleClick.bind(this,e)},n)},handleClick:function(e,t){t.target.value=e,(this.props.onSelect||n)(e,t)}}));i({getHeaderText:function(e){var t=s(e).get("year"),r=t%10;return t=t-r-1,t+" - "+(t+11)}},d),e.exports=d},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=r(3),u=o.createClass({displayName:"MonthView",formatAsDay:function(e,t){return e.format(t||"D")},getDefaultProps:function(){return c()},getWeekStartMoment:function(e){var t=s(e).startOf("week");return t},getDaysInMonth:function(e){var t=s(e).startOf("month"),r=this.getWeekStartMoment(t),n=[],a=0;for(t.add(-1,"days").isBefore(r)&&r.add(-1,"weeks");42>a;a++)n.push(s(r)),r.add(1,"days");return n},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=d(this.props.viewDate,this.props.dateFormat);this.props.minDate&&(this.props.minDate=+d(this.props.minDate,this.props.dateFormat)),this.props.maxDate&&(this.props.maxDate=+d(this.props.maxDate,this.props.dateFormat)),this.props.minDate,this.monthFirst=s(e).startOf("month"),this.monthLast=s(e).endOf("month"),this.props.date&&(this.props.moment=s(this.props.date).startOf("day"));var t=this.getDaysInMonth(e);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(t)))},renderDays:function(e){for(var t=e.map(this.renderDay,this),r=e.length,n=[],a=Math.ceil(r/7),s=0;a>s;s++)n.push(t.slice(7*s,7*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t,className:"dp-week dp-row"},e)})},renderDay:function(e){var t=p.day(e),r=["dp-cell dp-day"],n=+e;n==a?r.push("dp-current"):n<this.monthFirst?r.push("dp-prev"):n>this.monthLast&&r.push("dp-next"),this.props.minDate&&e<this.props.minDate&&r.push("dp-disabled dp-before-min"),this.props.maxDate&&e>this.props.maxDate&&r.push("dp-disabled dp-after-max"),n==this.props.moment&&r.push("dp-value");var s={key:t,text:t,date:e,className:r.join(" "),style:{},onClick:this.handleClick.bind(this,e,n),children:t};"function"==typeof this.props.onRenderDay&&(s=this.props.onRenderDay(s));var i=o.DOM.td,c=this.props.renderDay||i,d=c(s);return void 0===d&&(d=i(s)),d},renderWeekDayNames:function(){var e=this.props.weekDayNames;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,r){this.props.minDate&&t<this.props.minDate||this.props.maxDate&&t>this.props.maxDate||(r.target.value=e,(this.props.onChange||n)(e,r))}});i({getHeaderText:function(e){return d(e).format("MMMM YYYY")}},u),e.exports=u},function(e,t,r){"use strict";function n(){}var a,o=r(5),s=r(1),i=r(2).copy,p=r(7),c=r(4),d=r(3),u=o.createClass({displayName:"YearView",getDefaultProps:function(){return c()},getMonthsInYear:function(e){for(var t=s(e).startOf("year"),r=[],n=0;12>n;n++)r.push(s(t)),t.add(1,"month");return r},render:function(){a=+s().startOf("day");var e=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("month"));var t=this.getMonthsInYear(e);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(t)))},renderMonths:function(e){for(var t=e.map(this.renderMonth,this),r=e.length,n=[],a=Math.ceil(r/4),s=0;a>s;s++)n.push(t.slice(4*s,4*(s+1)));return n.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderMonth:function(e){var t=p.month(e),r=["dp-cell dp-month"],n=+e;return n==this.props.moment&&r.push("dp-value"),o.createElement("td",{key:t,className:r.join(" "),onClick:this.handleClick.bind(this,e)},t)},handleClick:function(e,t){t.target.value=e,(this.props.onSelect||n)(e,t)}});i({getHeaderText:function(e){return d(e).format("YYYY")}},u),e.exports=u}])});

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

var nl = require('moment/locale/nl')
var React = require('react')

@@ -22,3 +20,3 @@ var DatePicker = require('./src/index')

function onNav(moment, text, view){
console.log(moment, text, view)
console.log('nav to ', text)
}

@@ -35,4 +33,2 @@

props.style.color = 'red'
return props

@@ -51,3 +47,3 @@ }

onRenderDay={renderDay}
minDate='2014-04-04' maxDate='2015-10-10' date={v} viewDate={DATE} onChange={this.onChange}/>
date={v} onChange={this.onChange}/>

@@ -59,3 +55,3 @@ <button onClick={clear}>clear</button>

onChange: function(date, dateString) {
console.log(dateString, 'change')
console.log('change',dateString)
DATE = dateString

@@ -62,0 +58,0 @@ VALUE = dateString

@@ -7,2 +7,3 @@ 'use strict'

var copyUtils = require('copy-utils')
var copy = copyUtils.copy

@@ -100,3 +101,3 @@ var copyList = copyUtils.copyList

getViewDate: function() {
return this.state.viewMoment || this.props.viewDate || this.props.date || this.now
return this.state.viewMoment || this.viewMoment || this.props.viewDate || this.props.date || this.now
},

@@ -111,3 +112,3 @@

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

@@ -222,7 +223,7 @@ props.renderDay = this.props.renderDay

React.createElement("tr", {className: "dp-row"},
React.createElement("td", {className: "dp-prev-nav dp-nav-cell dp-cell", onClick: this.handlePrevNav}, prev),
React.createElement("td", {className: "dp-prev-nav dp-nav-cell dp-cell", onClick: this.handleNavPrev}, prev),
React.createElement("td", {className: "dp-nav-view dp-cell ", colSpan: colspan, onClick: this.handleViewChange}, headerText),
React.createElement("td", {className: "dp-next-nav dp-nav-cell dp-cell", onClick: this.handleNextNav}, next)
React.createElement("td", {className: "dp-next-nav dp-nav-cell dp-cell", onClick: this.handleNavNext}, next)
)

@@ -276,3 +277,3 @@ ))

handlePrevNav: function(event) {
handleNavPrev: function(event) {
var viewMoment = this.getPrev()

@@ -292,3 +293,3 @@

handleNextNav: function(event) {
handleNavNext: function(event) {
var viewMoment = this.getNext()

@@ -311,2 +312,16 @@

var viewDate = moment(this.getViewDate())
//it's not enough to compare months, since the year can change as well
//
//also it's ok to hardcode the format here
var viewMonth = viewDate.format('YYYY-MM')
var dateMonth = date.format('YYYY-MM')
if (dateMonth > viewMonth){
this.handleNavNext(event)
} else if (dateMonth < viewMonth){
this.handleNavPrev(event)
}
var text = date.format(this.props.dateFormat)

@@ -313,0 +328,0 @@

{
"name": "react-date-picker",
"version": "1.4.3",
"version": "1.4.4",
"description": "React Date Picker",

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

@@ -7,2 +7,3 @@ 'use strict'

var copyUtils = require('copy-utils')
var copy = copyUtils.copy

@@ -100,3 +101,3 @@ var copyList = copyUtils.copyList

getViewDate: function() {
return this.state.viewMoment || this.props.viewDate || this.props.date || this.now
return this.state.viewMoment || this.viewMoment || this.props.viewDate || this.props.date || this.now
},

@@ -111,3 +112,3 @@

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

@@ -222,7 +223,7 @@ props.renderDay = this.props.renderDay

<tr className="dp-row">
<td className="dp-prev-nav dp-nav-cell dp-cell" onClick={this.handlePrevNav}>{prev}</td>
<td className="dp-prev-nav dp-nav-cell dp-cell" onClick={this.handleNavPrev}>{prev}</td>
<td className="dp-nav-view dp-cell " colSpan={colspan} onClick={this.handleViewChange}>{headerText}</td>
<td className="dp-next-nav dp-nav-cell dp-cell" onClick={this.handleNextNav}>{next}</td>
<td className="dp-next-nav dp-nav-cell dp-cell" onClick={this.handleNavNext}>{next}</td>
</tr>

@@ -276,3 +277,3 @@ </tbody></table>

handlePrevNav: function(event) {
handleNavPrev: function(event) {
var viewMoment = this.getPrev()

@@ -292,3 +293,3 @@

handleNextNav: function(event) {
handleNavNext: function(event) {
var viewMoment = this.getNext()

@@ -311,2 +312,16 @@

var viewDate = moment(this.getViewDate())
//it's not enough to compare months, since the year can change as well
//
//also it's ok to hardcode the format here
var viewMonth = viewDate.format('YYYY-MM')
var dateMonth = date.format('YYYY-MM')
if (dateMonth > viewMonth){
this.handleNavNext(event)
} else if (dateMonth < viewMonth){
this.handleNavPrev(event)
}
var text = date.format(this.props.dateFormat)

@@ -313,0 +328,0 @@

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 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