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.1.2 to 2.1.3

11

CHANGELOG.md
react-date-picker
=================
#### v2.1.3
* fix #33
#### v2.1.0
* remove normalize.css dependency
* remove 'sans-serif' font-family from css - font will be inherited from parent node
#### v2.0.12

@@ -28,2 +37,2 @@

* `onNav` is called with new args: moment, text, view, direction - where moment is a date as a momentjs instance, text is the date formatted as text, the view is the view name ('month','year','decade') and direction is 1 (nav to next period) or -1 (nav to prev period)
* `onSelect` is called with new args: moment, text, view
* `onSelect` is called with new args: moment, text, view

5

dist/react-date-picker.nomoment.js

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

this.toMoment = function (value, dateFormat) {
// debugger
return toMoment(value, dateFormat || props.dateFormat, { locale: props.locale });

@@ -908,4 +907,4 @@ };

return React.createElement('tr', { className: 'dp-row dp-week-day-names' }, names.map(function (name) {
return React.createElement('td', { key: name, className: 'dp-cell dp-week-day-name' }, name);
return React.createElement('tr', { className: 'dp-row dp-week-day-names' }, names.map(function (name, index) {
return React.createElement('td', { key: index, className: 'dp-cell dp-week-day-name' }, name);
}));

@@ -912,0 +911,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(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=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},o=a(4),i=a(2),s=a(1),c=a(5),d=a(10),l=a(11),h=a(8),u=a(9),p=a(3),m=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={month:d,year:l,decade:h},v=o.createClass({displayName:"DatePicker",propTypes:{todayText:o.PropTypes.string,gotoSelectedText:o.PropTypes.string,renderFooter:o.PropTypes.func,onChange:o.PropTypes.func,date:o.PropTypes.any,viewDate:o.PropTypes.any},getViewOrder:function(){return this.props.viewOrder||["month","year","decade"]},getDefaultProps:function(){var e=s({},c(),{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(){var e=this.props.views||f;return e[this.getViewName()]||e.month},getViewFactory:function(){var e=this.getView();return o.createFactory&&e&&e.prototype&&"function"==typeof e.prototype.render&&(e.__factory=e.__factory||o.createFactory(e),e=e.__factory),e},getViewDate:function(){var e=m(this.props,"viewDate")?this.props.viewDate:this.state.viewDate;return e=e||this.viewMoment||this.getDate()||new Date,i.isMoment(e)&&(e=+e),e=this.toMoment(e)},getDate:function(){var e;return e=m(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 p(t,a||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.date=this.getDate();var a=null==e.date?"":e.date.format(this.props.dateFormat);e.viewDate=this.viewMoment=this.getViewDate(),e.locale=this.props.locale,e.localeData=i.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 d=e,d=c(e);return d.dateString=a,d.localeData=e.localeData,d.onSelect=this.handleSelect,d.onChange=this.handleChange,o.createElement("div",r({className:n,style:e.style},this.props),o.createElement("div",{className:"dp-inner",style:{width:"100%",height:"100%"}},this.renderHeader(t,e),o.createElement("div",{className:"dp-body",style:{flex:1}},o.createElement("div",{className:"dp-anim-target"},t(d))),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",r={todayText:a,gotoSelectedText:n,gotoToday:this.gotoNow,gotoSelected:this.gotoSelected.bind(this,e),date:e.date,viewDate:e.viewDate};return"function"==typeof this.props.footerFactory&&(t=this.props.footerFactory(r)),void 0!==t?t:o.createElement("div",{className:"dp-footer"},o.createElement("div",{className:"dp-footer-today",onClick:r.gotoToday},a),o.createElement("div",{className:"dp-footer-selected",onClick:r.gotoSelected},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){if(!this.props.hideHeader){t=t||this.props;var a=this.getViewDate(),n=this.getView().getHeaderText(a,t),r=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return o.createElement(u,{prevText:i,nextText:s,colspan:r,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)}m(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);m(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)}}});v.views=f,e.exports=v},function(e,t,a){"use strict";function n(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,t){for(var a,r,o=n(e),i=1;i<arguments.length;i++){a=arguments[i],r=Object.keys(Object(a));for(var s=0;s<r.length;s++)o[r[s]]=a[r[s]]}return o}},function(t,a,n){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,a,n){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(12);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";function n(){}var r,o=a(4),i=a(2),s=a(1),c=a(7),d=a(5),s=(a(3),a(1)),l=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return d()},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)}});l.getHeaderText=function(e,t){var a=i(e).get("year"),n=a%10;return a=a-n-1,a+" - "+(a+11)},e.exports=l},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),d=a(3),l=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 d(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),d={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&&(d=e.onRenderDay(d));var l=o.DOM.td,h=e.renderDay||l,u=h(d);return void 0===u&&(u=l(d)),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))}});l.getHeaderText=function(e,t){return d(e,null,{locale:t.locale}).format("MMMM YYYY")},e.exports=l},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(7),c=a(5),d=a(3),l=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=l({},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 d(e,null,{locale:t.locale}).format("YYYY")},e.exports=h},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){"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=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},o=a(4),i=a(2),s=a(1),c=a(5),d=a(10),l=a(11),h=a(8),u=a(9),p=a(3),m=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={month:d,year:l,decade:h},v=o.createClass({displayName:"DatePicker",propTypes:{todayText:o.PropTypes.string,gotoSelectedText:o.PropTypes.string,renderFooter:o.PropTypes.func,onChange:o.PropTypes.func,date:o.PropTypes.any,viewDate:o.PropTypes.any},getViewOrder:function(){return this.props.viewOrder||["month","year","decade"]},getDefaultProps:function(){var e=s({},c(),{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(){var e=this.props.views||f;return e[this.getViewName()]||e.month},getViewFactory:function(){var e=this.getView();return o.createFactory&&e&&e.prototype&&"function"==typeof e.prototype.render&&(e.__factory=e.__factory||o.createFactory(e),e=e.__factory),e},getViewDate:function(){var e=m(this.props,"viewDate")?this.props.viewDate:this.state.viewDate;return e=e||this.viewMoment||this.getDate()||new Date,i.isMoment(e)&&(e=+e),e=this.toMoment(e)},getDate:function(){var e;return e=m(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 p(t,a||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.date=this.getDate();var a=null==e.date?"":e.date.format(this.props.dateFormat);e.viewDate=this.viewMoment=this.getViewDate(),e.locale=this.props.locale,e.localeData=i.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 d=e,d=c(e);return d.dateString=a,d.localeData=e.localeData,d.onSelect=this.handleSelect,d.onChange=this.handleChange,o.createElement("div",r({className:n,style:e.style},this.props),o.createElement("div",{className:"dp-inner",style:{width:"100%",height:"100%"}},this.renderHeader(t,e),o.createElement("div",{className:"dp-body",style:{flex:1}},o.createElement("div",{className:"dp-anim-target"},t(d))),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",r={todayText:a,gotoSelectedText:n,gotoToday:this.gotoNow,gotoSelected:this.gotoSelected.bind(this,e),date:e.date,viewDate:e.viewDate};return"function"==typeof this.props.footerFactory&&(t=this.props.footerFactory(r)),void 0!==t?t:o.createElement("div",{className:"dp-footer"},o.createElement("div",{className:"dp-footer-today",onClick:r.gotoToday},a),o.createElement("div",{className:"dp-footer-selected",onClick:r.gotoSelected},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){if(!this.props.hideHeader){t=t||this.props;var a=this.getViewDate(),n=this.getView().getHeaderText(a,t),r=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return o.createElement(u,{prevText:i,nextText:s,colspan:r,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)}m(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);m(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)}}});v.views=f,e.exports=v},function(e,t,a){"use strict";function n(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,t){for(var a,r,o=n(e),i=1;i<arguments.length;i++){a=arguments[i],r=Object.keys(Object(a));for(var s=0;s<r.length;s++)o[r[s]]=a[r[s]]}return o}},function(t,a,n){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,a,n){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(12);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";function n(){}var r,o=a(4),i=a(2),s=a(1),c=a(7),d=a(5),s=(a(3),a(1)),l=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return d()},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)}});l.getHeaderText=function(e,t){var a=i(e).get("year"),n=a%10;return a=a-n-1,a+" - "+(a+11)},e.exports=l},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),d=a(3),l=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 d(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),d={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&&(d=e.onRenderDay(d));var l=o.DOM.td,h=e.renderDay||l,u=h(d);return void 0===u&&(u=l(d)),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,t){return o.createElement("td",{key:t,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))}});l.getHeaderText=function(e,t){return d(e,null,{locale:t.locale}).format("MMMM YYYY")},e.exports=l},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(7),c=a(5),d=a(3),l=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=l({},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 d(e,null,{locale:t.locale}).format("YYYY")},e.exports=h},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}}])});

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

<DatePicker
weekDayNames={['S','M','T','W','T','F','S']}
locale ={LOCALE}

@@ -56,0 +57,0 @@ date ={VALUE}

@@ -84,3 +84,2 @@ 'use strict';

this.toMoment = function (value, dateFormat) {
// debugger
return toMoment(value, dateFormat || props.dateFormat, { locale: props.locale });

@@ -238,6 +237,6 @@ };

{ className: 'dp-row dp-week-day-names' },
names.map(function (name) {
names.map(function (name, index) {
return React.createElement(
'td',
{ key: name, className: 'dp-cell dp-week-day-name' },
{ key: index, className: 'dp-cell dp-week-day-name' },
name

@@ -244,0 +243,0 @@ );

{
"name": "react-date-picker",
"version": "2.1.2",
"version": "2.1.3",
"description": "React Date Picker",

@@ -16,3 +16,3 @@ "main": "lib/index.js",

"lib": "gulp",
"test-w": "mocha --recursive --reporter $(REPORTER) --require should --watch",
"test-w": "mocha --recursive --reporter spec --require should --watch",
"build": "npm run build-style && npm run dist && npm run dist-nomoment && npm run dist.min && npm run dist-nomoment.min && npm run lib"

@@ -33,3 +33,2 @@ },

"devDependencies": {
"stylus-normalizer": "^1.0.1",
"babel-loader": "^5.1.3",

@@ -45,5 +44,6 @@ "css-loader": "~0.9.0",

"node-libs-browser": "^0.5.2",
"should": "^5.2.0",
"should": "^6.0.3",
"style-loader": "~0.8.1",
"stylus-loader": "~0.4.0",
"stylus-normalizer": "^1.0.1",
"url-loader": "~0.5.5",

@@ -50,0 +50,0 @@ "webpack": "^1.9.10",

@@ -64,6 +64,6 @@ 'use strict'

getDaysInMonth: function(value){
var first = this.toMoment(value).startOf('month')
var start = this.getWeekStartMoment(first)
var first = this.toMoment(value).startOf('month')
var start = this.getWeekStartMoment(first)
var result = []
var i = 0
var i = 0

@@ -88,3 +88,2 @@ if (first.add(-1, 'days').isBefore(start)){

this.toMoment = function(value, dateFormat){
// debugger
return toMoment(value, dateFormat || props.dateFormat, { locale: props.locale })

@@ -235,3 +234,3 @@ }

<tr className="dp-row dp-week-day-names">
{names.map(name => <td key={name} className="dp-cell dp-week-day-name">{name}</td>)}
{names.map( (name, index) => <td key={index} className="dp-cell dp-week-day-name">{name}</td>)}
</tr>

@@ -238,0 +237,0 @@ )

@@ -88,2 +88,17 @@ 'use strict';

it('weekDayNames should be rendered correctly, even if there are two identical labels', function(){
var weekDayNames = ['S','M','T','W','T','F','S']
var picker = render(DatePicker({
defaultDate : '2014-03-25',
weekDayNames: weekDayNames
}))
findWithClass(picker, 'dp-week-day-names')
.getDOMNode()
.textContent
.should
.equal(weekDayNames.join(''))
})
})

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

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