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

react-date-picker

Package Overview
Dependencies
Maintainers
2
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.3 to 2.0.4

106

dist/react-date-picker.js

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

var asConfig = __webpack_require__(8)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -89,4 +89,2 @@ var MonthView = __webpack_require__(3)

var getWeekDayNames = __webpack_require__(9)
function emptyFn(){}

@@ -207,4 +205,2 @@

console.log(props.locale,'!!!');
props.renderDay = this.props.renderDay

@@ -304,2 +300,3 @@ props.onRenderDay = this.props.onRenderDay

gotoDate: function(value) {
this.setView('month')

@@ -521,5 +518,5 @@

var moment = __webpack_require__(2)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)
var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)

@@ -727,3 +724,6 @@ var toMoment = __webpack_require__(7)

names = names(weekStartDay, props.locale)
} else {
} else if (Array.isArray(names)){
names = [].concat(names)
var index = weekStartDay

@@ -779,6 +779,6 @@

var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)
var toMoment = __webpack_require__(7)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -903,8 +903,8 @@ var TODAY

var moment = __webpack_require__(2)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)
var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)
var toMoment = __webpack_require__(7)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -1098,3 +1098,3 @@ var TODAY

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

@@ -1133,5 +1133,5 @@ /**

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

@@ -1181,35 +1181,2 @@

'use strict'
var moment = __webpack_require__(2)
var DEFAULT_WEEK_START_DAY = moment().startOf('week').format('d') * 1
module.exports = function getWeekDayNames(startDay, locale){
var weekDays
if (locale){
var data = moment.localeData(locale)
weekDays = data && data._weekdaysShort? data._weekdaysShort: weekDays
}
weekDays = weekDays || moment.weekdaysShort()
var names = weekDays
var index = startDay == null? DEFAULT_WEEK_START_DAY: startDay
while (index > 0){
names.push(names.shift())
index--
}
return names
}
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';

@@ -1244,3 +1211,3 @@

/***/ },
/* 11 */
/* 10 */
/***/ function(module, exports, __webpack_require__) {

@@ -1250,3 +1217,3 @@

var CONFIG = __webpack_require__(12)
var CONFIG = __webpack_require__(11)
var toMoment = __webpack_require__(7)

@@ -1273,3 +1240,3 @@

/***/ },
/* 12 */
/* 11 */
/***/ function(module, exports, __webpack_require__) {

@@ -1279,3 +1246,3 @@

var getWeekDayNames = __webpack_require__(9)
var getWeekDayNames = __webpack_require__(12)

@@ -1328,4 +1295,37 @@ // console.log(getWeekDayNames())

/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
var moment = __webpack_require__(2)
var DEFAULT_WEEK_START_DAY = moment().startOf('week').format('d') * 1
module.exports = function getWeekDayNames(startDay, locale){
var weekDays
if (locale){
var data = moment.localeData(locale)
weekDays = data && data._weekdaysShort? data._weekdaysShort: weekDays
}
weekDays = (weekDays || moment.weekdaysShort()).concat()
var names = weekDays
var index = startDay == null? DEFAULT_WEEK_START_DAY: startDay
while (index > 0){
names.push(names.shift())
index--
}
return names
}
/***/ }
/******/ ])
});

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

var asConfig = __webpack_require__(8)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -89,4 +89,2 @@ var MonthView = __webpack_require__(3)

var getWeekDayNames = __webpack_require__(9)
function emptyFn(){}

@@ -207,4 +205,2 @@

console.log(props.locale,'!!!');
props.renderDay = this.props.renderDay

@@ -304,2 +300,3 @@ props.onRenderDay = this.props.onRenderDay

gotoDate: function(value) {
this.setView('month')

@@ -521,5 +518,5 @@

var moment = __webpack_require__(2)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)
var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)

@@ -727,3 +724,6 @@ var toMoment = __webpack_require__(7)

names = names(weekStartDay, props.locale)
} else {
} else if (Array.isArray(names)){
names = [].concat(names)
var index = weekStartDay

@@ -779,6 +779,6 @@

var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)
var toMoment = __webpack_require__(7)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -903,8 +903,8 @@ var TODAY

var moment = __webpack_require__(2)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)
var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)
var toMoment = __webpack_require__(7)
var assign = __webpack_require__(10)
var assign = __webpack_require__(9)

@@ -1098,3 +1098,3 @@ var TODAY

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

@@ -1133,5 +1133,5 @@ /**

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

@@ -1181,35 +1181,2 @@

'use strict'
var moment = __webpack_require__(2)
var DEFAULT_WEEK_START_DAY = moment().startOf('week').format('d') * 1
module.exports = function getWeekDayNames(startDay, locale){
var weekDays
if (locale){
var data = moment.localeData(locale)
weekDays = data && data._weekdaysShort? data._weekdaysShort: weekDays
}
weekDays = weekDays || moment.weekdaysShort()
var names = weekDays
var index = startDay == null? DEFAULT_WEEK_START_DAY: startDay
while (index > 0){
names.push(names.shift())
index--
}
return names
}
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';

@@ -1244,3 +1211,3 @@

/***/ },
/* 11 */
/* 10 */
/***/ function(module, exports, __webpack_require__) {

@@ -1250,3 +1217,3 @@

var CONFIG = __webpack_require__(12)
var CONFIG = __webpack_require__(11)
var toMoment = __webpack_require__(7)

@@ -1273,3 +1240,3 @@

/***/ },
/* 12 */
/* 11 */
/***/ function(module, exports, __webpack_require__) {

@@ -1279,3 +1246,3 @@

var getWeekDayNames = __webpack_require__(9)
var getWeekDayNames = __webpack_require__(12)

@@ -1328,4 +1295,37 @@ // console.log(getWeekDayNames())

/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
var moment = __webpack_require__(2)
var DEFAULT_WEEK_START_DAY = moment().startOf('week').format('d') * 1
module.exports = function getWeekDayNames(startDay, locale){
var weekDays
if (locale){
var data = moment.localeData(locale)
weekDays = data && data._weekdaysShort? data._weekdaysShort: weekDays
}
weekDays = (weekDays || moment.weekdaysShort()).concat()
var names = weekDays
var index = startDay == null? DEFAULT_WEEK_START_DAY: startDay
while (index > 0){
names.push(names.shift())
index--
}
return names
}
/***/ }
/******/ ])
});

@@ -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(a){if(n[a])return n[a].exports;var r=n[a]={exports:{},id:a,loaded:!1};return e[a].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function a(){}var r=n(4),o=n(2),i=n(5),s=n(1),c=n(11),l=n(12),d=n(9),h=n(10),u=n(3),p=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={month:c,year:l,decade:d},f=(n(8),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(){return null!=this.props.view?this.props.view:this.state.view||"month"},addViewIndex:function(e){var t=this.getViewName(),n=this.getViewOrder(),a=n.indexOf(t);return a+=e,a%n.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,n){return u(t,n||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),console.log(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 a=e,a=i(e);return a.localeData=e.localeData,a.onSelect=this.handleSelect,a.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(a))),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,n=this.props.todayText||"Today",a=this.props.gotoSelectedText||"Go to selected",o={todayText:n,gotoSelectedText:a,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},n),r.createElement("div",{className:"dp-footer-selected",onClick:this.gotoSelected},a))}},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 n=this.getViewDate(),a=this.getView().getHeaderText(n,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},a)},handleRenderDay:function(e){return(this.props.renderDay||a)(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 n=e.format(this.props.dateFormat),a=this.getViewName();t(n,e,a)}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 n=-1==e?this.getPrev():this.getNext();if(this.setViewDate(n),"function"==typeof this.props.onNav){var a=n.format(this.props.dateFormat),r=this.getViewName();this.props.onNav(a,n,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 n=this.toMoment(this.getViewDate()),r=n.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||a)(i,e,t)},handleSelect:function(e,t){var n=this.getViewName(),a={decade:"year",year:"month"}[n],r=e.get(a),o=this.toMoment(this.getViewDate()).set(a,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 n,a,r=t(e),o=1;o<arguments.length;o++){n=arguments[o],a=Object.keys(Object(n));for(var i=0;i<a.length;i++)r[a[i]]=n[a[i]]}return r}},function(t){t.exports=e},function(e,t,n){"use strict";var a=n(2),r=n(6);e.exports=function(e,t,n){var o=!(!n||!n.strict),i=n&&n.locale;return t=t||r.dateFormat,"string"==typeof e?a(e,t,i,o):a(null==e?new Date:e,void 0,i,o)}},function(e){e.exports=t},function(e,t,n){"use strict";function a(e,t,n){return e&&n.forEach(function(n){t[n]=e[n]}),t}var r=n(1),o=n(6),i=Object.keys(o);e.exports=function(e,t){var n=i;return t&&(n=Object.keys(t)),t=t||o,e?a(e,r({},t),n):r({},t)}},function(e,t,n){"use strict";var a=n(8);e.exports={weekDayNames:a,weekStartDay:null,locale:null,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,n){"use strict";function a(e,t){return o(e).format(t)}var r=n(6),o=n(3);e.exports={day:function(e,t){return a(e,t||r.dayFormat)},month:function(e,t){return a(e,t||r.monthFormat)},year:function(e,t){return a(e,t||r.yearFormat)}}},function(e,t,n){"use strict";var a=n(2),r=1*a().startOf("week").format("d");e.exports=function(e,t){var n;if(t){var o=a.localeData(t);n=o&&o._weekdaysShort?o._weekdaysShort:n}n=n||a.weekdaysShort();for(var i=n,s=null==e?r:e;s>0;)i.push(i.shift()),s--;return i}},function(e,t,n){"use strict";function a(){}var r,o=n(4),i=n(2),s=n(1),c=n(7),l=n(5),s=(n(3),n(1)),d=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return l()},getYearsInDecade:function(e){var t=i(e).get("year"),n=t%10;t=t-n-1;for(var a=[],r=0,o=i(t,"YYYY").startOf("year");12>r;r++)a.push(i(o)),o.add(1,"year");return a},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 n=this.getYearsInDecade(t);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(e,n)))},renderYears:function(e,t){for(var n=t.map(function(t,n,a){return this.renderYear(e,t,n,a)},this),a=t.length,r=[],i=Math.ceil(a/4),s=0;i>s;s++)r.push(n.slice(4*s,4*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderYear:function(e,t,n,a){var r=c.year(t,e.yearFormat),i=["dp-cell dp-year"],s=+t;return s==e.moment&&i.push("dp-value"),n||i.push("dp-prev"),n==a.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,n){n.target.value=t,(e.onSelect||a)(t,n)}});d.getHeaderText=function(e){var t=i(e).get("year"),n=t%10;return t=t-n-1,t+" - "+(t+11)},e.exports=d},function(e,t,n){"use strict";var a=n(4),r=a.PropTypes;e.exports=a.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 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:e.onPrev},e.prevText),a.createElement("td",{className:"dp-nav-view dp-cell",colSpan:e.colspan,onClick:e.onChange},e.children),a.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:e.onNext},e.nextText)))))}})},function(e,t,n){"use strict";function a(){}var r,o=n(4),i=(n(2),n(1)),s=n(7),c=n(5),l=n(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,n=this.toMoment(e).day(t);return n},getDaysInMonth:function(e){var t=this.toMoment(e).startOf("month"),n=this.getWeekStartMoment(t),a=[],r=0;for(t.add(-1,"days").isBefore(n)&&n.add(-1,"weeks");42>r;r++)a.push(this.toMoment(n)),n.add(1,"days");return a},render:function(){var e=i({},this.props);this.toMoment=function(t,n){return l(t,n||e.dateFormat,{locale:e.locale})},r=+this.toMoment().startOf("day");var t=e.dateFormat,n=e.viewMoment=this.toMoment(e.viewDate,t),a=e.weekStartDay;null==a&&(a=e.localeData._week?e.localeData._week.dow:null),this.weekStartDay=e.weekStartDay=a,e.minDate&&(e.minDate=+this.toMoment(e.minDate,t)),e.maxDate&&(e.maxDate=+this.toMoment(e.maxDate,t)),this.monthFirst=this.toMoment(n).startOf("month"),this.monthLast=this.toMoment(n).endOf("month"),e.date&&(e.moment=this.toMoment(e.date).startOf("day"));var s=this.getDaysInMonth(n);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 n=t.map(function(t){return this.renderDay(e,t)},this),a=t.length,r=[],i=Math.ceil(a/7),s=0;i>s;s++)r.push(n.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 n=s.day(t,e.dayFormat),a=["dp-cell dp-day"],i=+t;i==r?a.push("dp-current"):i<this.monthFirst?a.push("dp-prev"):i>this.monthLast&&a.push("dp-next"),e.minDate&&t<e.minDate&&a.push("dp-disabled dp-before-min"),e.maxDate&&t>e.maxDate&&a.push("dp-disabled dp-after-max"),i==e.moment&&a.push("dp-value");var c={key:n,text:n,date:t,className:a.join(" "),style:{},onClick:this.handleClick.bind(this,e,t,i),children:n};"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,n=this.weekStartDay;if("function"==typeof t)t=t(n,e.locale);else for(var a=n;a>0;)t.push(t.shift()),a--;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,n,r){e.minDate&&n<e.minDate||e.maxDate&&n>e.maxDate||(r.target.value=t,(e.onChange||a)(t,r))}});d.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("MMMM YYYY")},e.exports=d},function(e,t,n){"use strict";function a(){}var r,o=n(4),i=n(2),s=n(7),c=n(5),l=n(3),d=n(1),h=o.createClass({displayName:"YearView",getDefaultProps:function(){return c()},getMonthsInYear:function(e){for(var t=i(e).startOf("year"),n=[],a=0;12>a;a++)n.push(i(t)),t.add(1,"month");return n},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 n=this.getMonthsInYear(t);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(e,n)))},renderMonths:function(e,t){for(var n=t.map(function(t){return this.renderMonth(e,t)},this),a=t.length,r=[],i=Math.ceil(a/4),s=0;i>s;s++)r.push(n.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 n=s.month(t,e.monthFormat),a=["dp-cell dp-month"],r=+t;return r==e.moment&&a.push("dp-value"),o.createElement("td",{key:n,className:a.join(" "),onClick:this.handleClick.bind(this,e,t)},n)},handleClick:function(e,t,n){n.target.value=t,(e.onSelect||a)(t,n)}});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}},getViewName:function(){return null!=this.props.view?this.props.view:this.state.view||"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:"month",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}])});

@@ -16,2 +16,20 @@ 'use strict'

var TODAY = {
en: 'Today',
fr: 'Aujourd\'hui',
de: 'Heute',
es: 'Hoy',
ro: 'Azi'
}
var GO2SELECTED = {
en: 'Go to selected',
es: 'Vaya a Favoritos',
de: 'Zum ausgewählten',
fr: 'Aller a la liste',
ro: 'Mergi la selectie'
}
var App = React.createClass({

@@ -64,2 +82,4 @@

var today = TODAY[LOCALE]
return <div style={{margin: 10}}>

@@ -86,3 +106,4 @@

locale={LOCALE}
xweekDayNames={['SUND','mon','marti','miercuri','joi','vineri','sam']}
todayText={today}
weekDayNames={['SUND','mon','marti','miercuri','joi','vineri','sam']}
minDate='2013-04-04' maxDate='2015-10-10' date={v} onChange={this.onChange}/>

@@ -89,0 +110,0 @@

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

var getWeekDayNames = require('./utils/getWeekDayNames')
function emptyFn(){}

@@ -150,4 +148,2 @@

console.log(props.locale,'!!!');
props.renderDay = this.props.renderDay

@@ -247,2 +243,3 @@ props.onRenderDay = this.props.onRenderDay

gotoDate: function(value) {
this.setView('month')

@@ -249,0 +246,0 @@

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

names = names(weekStartDay, props.locale)
} else {
} else if (Array.isArray(names)){
names = [].concat(names)
var index = weekStartDay

@@ -213,0 +216,0 @@

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

weekDays = weekDays || moment.weekdaysShort()
weekDays = (weekDays || moment.weekdaysShort()).concat()

@@ -20,0 +20,0 @@ var names = weekDays

{
"name": "react-date-picker",
"version": "2.0.3",
"version": "2.0.4",
"description": "React Date Picker",

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

@@ -81,2 +81,4 @@ react-date-picker

* `locale`: String
* todayText: String
* gotoSelectedText: String

@@ -83,0 +85,0 @@ ## Props

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

var getWeekDayNames = require('./utils/getWeekDayNames')
function emptyFn(){}

@@ -150,4 +148,2 @@

console.log(props.locale,'!!!');
props.renderDay = this.props.renderDay

@@ -247,2 +243,3 @@ props.onRenderDay = this.props.onRenderDay

gotoDate: function(value) {
this.setView('month')

@@ -249,0 +246,0 @@

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

names = names(weekStartDay, props.locale)
} else {
} else if (Array.isArray(names)){
names = [].concat(names)
var index = weekStartDay

@@ -213,0 +216,0 @@

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

weekDays = weekDays || moment.weekdaysShort()
weekDays = (weekDays || moment.weekdaysShort()).concat()

@@ -20,0 +20,0 @@ var names = weekDays

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