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

react-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-date-picker - npm Package Compare versions

Comparing version 2.1.8 to 2.1.9

119

dist/react-date-picker.nomoment.js

@@ -512,2 +512,121 @@ (function webpackUniversalModuleDefinition(root, factory) {

var PT = React.PropTypes;
DatePicker.propTypes = {
/**
* Function to be called when user selects a date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {Event} event
*
* @type {Function}
*/
onChange: PT.func,
/**
* Function to be called when the user navigates to the next/prev month/year/decade
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the current view (eg: "month")
* @param {Number} direction 1 or -1. 1 if the right arrow, to nav to next period was pressed. -1 if the left arrow, to nav to the prev period was pressed.
* @param {Event} event
*
* @type {Function}
*/
onNav: PT.func,
/**
* Function to be called when the user selects a year/month.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the view displayed after following the selection. For now, either "year" or "month"
*
* @type {Function}
*/
onSelect: PT.func,
/**
* A function that should return a React DOM for the day cell. The first param is the props object.
* You can use this to have full control over what gets rendered for a day.
*
* @param {Object} dayProps The props object passed to day rendering
*
* @type {Function}
*/
renderDay: PT.func,
/**
* A function that can manipulate the props object for a day, and SHOULD return a props object (a new one, or the same).
* Use this for CUSTOM DAY STYLING.
* You can use this to take full control over the styles/css classes/attributes applied to the day cell in the month view.
*
* @param {Object} dayProps
* @return {Object} dayProps
*
* @type {Function}
*/
onRenderDay: PT.func,
/******************************************/
/********** VIEW-related props ************/
/******************************************/
/**
* The default view to show in the picker. This is an uncontrolled prop.
* If none specified, the default view will be "month"
*
* @type {String}
*/
defaultView: PT.string,
/**
* The view to show in the picker. This is a CONTROLLED prop!
*
* When using this controlled prop, make sure you update it when `onViewChange` function is called
* if you want to navigate to another view, as expected.
*
* @type {String}
*/
view: PT.string,
/**
* A function to be called when navigating to another view date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view the name of the view displayed after the navigation occurs.
*
* @type {Function}
*/
onViewDateChange: PT.func,
/**
* A function to be called when the view is changed.
* If you're using the controlled `view` prop, make sure you update the `view` prop in this function if you want to navigate to another view, as expected.
*
* @param {String} nextView One of "month", "year", "decade"
*
* @type {Function}
*/
onViewChange: PT.func,
/**
* Defaults to true. If specified as false, will not navigate to the date that was clicked, even if that date is in the prev/next month
* @type {Boolean}
*/
navOnDateClick: PT.bool
};
module.exports = DatePicker;

@@ -514,0 +633,0 @@

2

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

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment"),require("React")):"function"==typeof define&&define.amd?define(["moment","React"],t):"object"==typeof exports?exports.DatePicker=t(require("moment"),require("React")):e.DatePicker=t(e.moment,e.React)}(this,function(e,t){return function(e){function t(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=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},o=n(5),i=n(2),s=n(1),l=n(6),c=n(11),d=n(12),u=n(9),p=n(10),h=n(4),m=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f=n(3),y={month:c,year:d,decade:u},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({},l(),{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(),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(){var e=this.props.views||y;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,n){return h(t,n||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.date=this.getDate();var n=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 a=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var c=e,c=l(e);return c.dateString=n,c.localeData=e.localeData,c.onSelect=this.handleSelect,c.onChange=this.handleChange,o.createElement("div",r({className:a,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(c))),this.renderFooter(e)))},prepareStyle:function(e){var t=s({},e.defaultStyle,e.style);return t},renderFooter:function(e){if(!this.props.hideFooter){this.props.today&&console.warn('Please use "todayText" prop instead of "today"!'),this.props.gotoSelected&&console.warn('Please use "gotoSelectedText" prop instead of "gotoSelected"!');var t,n=this.props.todayText||"Today",a=this.props.gotoSelectedText||"Go to selected",r={todayText:n,gotoSelectedText:a,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",{tabIndex:"1",role:"link",className:"dp-footer-today",onClick:r.gotoToday,onKeyUp:f(r.gotoToday)},n),o.createElement("div",{tabIndex:"1",role:"link",className:"dp-footer-selected",onClick:r.gotoSelected,onKeyUp:f(r.gotoSelected)},a))}},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 n=this.getViewDate(),a=this.getView().getHeaderText(n,t),r=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return o.createElement(p,{prevText:i,nextText:s,colspan:r,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)}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 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);m(this.props,"date")||this.setState({defaultDate:i}),(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)}}});v.views=y,e.exports=v},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function a(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return r.call(e,t)})}var r=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var r,o,i=n(e),s=1;s<arguments.length;s++){r=arguments[s],o=a(Object(r));for(var l=0;l<o.length;l++)i[o[l]]=r[o[l]]}return i}},function(t,n){t.exports=e},function(e,t){"use strict";e.exports=function(e){return function(t){"Enter"==t.key&&e(t)}}},function(e,t,n){"use strict";var a=n(2),r=n(7);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,n){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(7),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(13);e.exports={weekDayNames:a,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,n){"use strict";function a(e,t){return o(e).format(t)}var r=n(7),o=n(4);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";function a(){}var r,o=n(5),i=n(2),s=n(1),l=n(8),c=n(6),d=(n(4),n(3)),s=n(1),u=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return c()},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=l.year(t,e.yearFormat),i=["dp-cell dp-year"],s=+t;s==e.moment&&i.push("dp-value"),n||i.push("dp-prev"),n==a.length-1&&i.push("dp-next");var c=this.handleClick.bind(this,e,t);return o.createElement("td",{role:"link",tabIndex:"1",key:r,className:i.join(" "),onClick:c,onKeyUp:d(c)},r)},handleClick:function(e,t,n){n.target.value=t,(e.onSelect||a)(t,n)}});u.getHeaderText=function(e,t){var n=i(e).get("year"),a=n%10;return n=n-a-1,n+" - "+(n+11)},e.exports=u},function(e,t,n){"use strict";var a=n(5),r=a.PropTypes,o=n(3);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",{tabIndex:"1",role:"link",className:"dp-prev-nav dp-nav-cell dp-cell",onClick:e.onPrev,onKeyUp:o(e.onPrev)},e.prevText),a.createElement("td",{tabIndex:"1",role:"link",className:"dp-nav-view dp-cell",colSpan:e.colspan,onClick:e.onChange,onKeyUp:o(e.onChange)},e.children),a.createElement("td",{tabIndex:"1",role:"link",className:"dp-next-nav dp-nav-cell dp-cell",onClick:e.onNext,onKeyUp:o(e.onNext)},e.nextText)))))}})},function(e,t,n){"use strict";function a(){}Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(5),i=n(2),s=n(1),l=n(8),c=n(6),d=n(3),u=n(4),p=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=s({},this.props);this.toMoment=function(t,n){return u(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&&i.isMoment(e.minDate)&&e.minDate.startOf("day"),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 l=this.getDaysInMonth(n);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(e,l)))},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=l.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 s=this.toMoment(t),c=this.handleClick.bind(this,e,t,i),u={role:"link",tabIndex:1,key:n,text:n,date:s,moment:s,className:a.join(" "),style:{},onClick:c,onKeyUp:d(c),children:n};"function"==typeof e.onRenderDay&&(u=e.onRenderDay(u));var p=o.DOM.td,h=e.renderDay||p,m=h(u);return void 0===m&&(m=p(u)),m},getWeekDayNames:function(e){e=e||this.props;var t=e.weekDayNames,n=this.weekStartDay;if("function"==typeof t)t=t(n,e.locale);else if(Array.isArray(t)){t=[].concat(t);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,t){return o.createElement("td",{key:t,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))}});p.getHeaderText=function(e,t){return u(e,null,{locale:t.locale}).format("MMMM YYYY")},t["default"]=p,e.exports=t["default"]},function(e,t,n){"use strict";function a(){}var r,o=n(5),i=n(2),s=n(8),l=n(6),c=n(4),d=n(3),u=n(1),p=o.createClass({displayName:"YearView",getDefaultProps:function(){return l()},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=u({},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;r==e.moment&&a.push("dp-value");var i=this.handleClick.bind(this,e,t);return o.createElement("td",{tabIndex:"1",role:"link",key:n,className:a.join(" "),onClick:i,onKeyUp:d(i)},n)},handleClick:function(e,t,n){n.target.value=t,(e.onSelect||a)(t,n)}});p.getHeaderText=function(e,t){return c(e,null,{locale:t.locale}).format("YYYY")},e.exports=p},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()).concat();for(var i=n,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(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=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},o=n(5),i=n(2),s=n(1),c=n(6),l=n(11),d=n(12),u=n(9),p=n(10),h=n(4),f=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m=n(3),y={month:l,year:d,decade:u},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(),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(){var e=this.props.views||y;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=f(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=f(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,n){return h(t,n||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.date=this.getDate();var n=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 a=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var l=e,l=c(e);return l.dateString=n,l.localeData=e.localeData,l.onSelect=this.handleSelect,l.onChange=this.handleChange,o.createElement("div",r({className:a,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(l))),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",r={todayText:n,gotoSelectedText:a,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",{tabIndex:"1",role:"link",className:"dp-footer-today",onClick:r.gotoToday,onKeyUp:m(r.gotoToday)},n),o.createElement("div",{tabIndex:"1",role:"link",className:"dp-footer-selected",onClick:r.gotoSelected,onKeyUp:m(r.gotoSelected)},a))}},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 n=this.getViewDate(),a=this.getView().getHeaderText(n,t),r=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return o.createElement(p,{prevText:i,nextText:s,colspan:r,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)}f(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);f(this.props,"date")||this.setState({defaultDate:i}),(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)}}});v.views=y;var w=o.PropTypes;v.propTypes={onChange:w.func,onNav:w.func,onSelect:w.func,renderDay:w.func,onRenderDay:w.func,defaultView:w.string,view:w.string,onViewDateChange:w.func,onViewChange:w.func,navOnDateClick:w.bool},e.exports=v},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function a(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return r.call(e,t)})}var r=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var r,o,i=n(e),s=1;s<arguments.length;s++){r=arguments[s],o=a(Object(r));for(var c=0;c<o.length;c++)i[o[c]]=r[o[c]]}return i}},function(t,n){t.exports=e},function(e,t){"use strict";e.exports=function(e){return function(t){"Enter"==t.key&&e(t)}}},function(e,t,n){"use strict";var a=n(2),r=n(7);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,n){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(7),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(13);e.exports={weekDayNames:a,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,n){"use strict";function a(e,t){return o(e).format(t)}var r=n(7),o=n(4);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";function a(){}var r,o=n(5),i=n(2),s=n(1),c=n(8),l=n(6),d=(n(4),n(3)),s=n(1),u=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;s==e.moment&&i.push("dp-value"),n||i.push("dp-prev"),n==a.length-1&&i.push("dp-next");var l=this.handleClick.bind(this,e,t);return o.createElement("td",{role:"link",tabIndex:"1",key:r,className:i.join(" "),onClick:l,onKeyUp:d(l)},r)},handleClick:function(e,t,n){n.target.value=t,(e.onSelect||a)(t,n)}});u.getHeaderText=function(e,t){var n=i(e).get("year"),a=n%10;return n=n-a-1,n+" - "+(n+11)},e.exports=u},function(e,t,n){"use strict";var a=n(5),r=a.PropTypes,o=n(3);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",{tabIndex:"1",role:"link",className:"dp-prev-nav dp-nav-cell dp-cell",onClick:e.onPrev,onKeyUp:o(e.onPrev)},e.prevText),a.createElement("td",{tabIndex:"1",role:"link",className:"dp-nav-view dp-cell",colSpan:e.colspan,onClick:e.onChange,onKeyUp:o(e.onChange)},e.children),a.createElement("td",{tabIndex:"1",role:"link",className:"dp-next-nav dp-nav-cell dp-cell",onClick:e.onNext,onKeyUp:o(e.onNext)},e.nextText)))))}})},function(e,t,n){"use strict";function a(){}Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(5),i=n(2),s=n(1),c=n(8),l=n(6),d=n(3),u=n(4),p=o.createClass({displayName:"MonthView",formatAsDay:function(e,t){return e.format(t||"D")},getDefaultProps:function(){return l()},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=s({},this.props);this.toMoment=function(t,n){return u(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&&i.isMoment(e.minDate)&&e.minDate.startOf("day"),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 c=this.getDaysInMonth(n);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(e,c)))},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=c.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 s=this.toMoment(t),l=this.handleClick.bind(this,e,t,i),u={role:"link",tabIndex:1,key:n,text:n,date:s,moment:s,className:a.join(" "),style:{},onClick:l,onKeyUp:d(l),children:n};"function"==typeof e.onRenderDay&&(u=e.onRenderDay(u));var p=o.DOM.td,h=e.renderDay||p,f=h(u);return void 0===f&&(f=p(u)),f},getWeekDayNames:function(e){e=e||this.props;var t=e.weekDayNames,n=this.weekStartDay;if("function"==typeof t)t=t(n,e.locale);else if(Array.isArray(t)){t=[].concat(t);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,t){return o.createElement("td",{key:t,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))}});p.getHeaderText=function(e,t){return u(e,null,{locale:t.locale}).format("MMMM YYYY")},t["default"]=p,e.exports=t["default"]},function(e,t,n){"use strict";function a(){}var r,o=n(5),i=n(2),s=n(8),c=n(6),l=n(4),d=n(3),u=n(1),p=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=u({},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;r==e.moment&&a.push("dp-value");var i=this.handleClick.bind(this,e,t);return o.createElement("td",{tabIndex:"1",role:"link",key:n,className:a.join(" "),onClick:i,onKeyUp:d(i)},n)},handleClick:function(e,t,n){n.target.value=t,(e.onSelect||a)(t,n)}});p.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("YYYY")},e.exports=p},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()).concat();for(var i=n,s=null==e?r:e;s>0;)i.push(i.shift()),s--;return i}}])});

@@ -483,2 +483,121 @@ 'use strict';

var PT = React.PropTypes;
DatePicker.propTypes = {
/**
* Function to be called when user selects a date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {Event} event
*
* @type {Function}
*/
onChange: PT.func,
/**
* Function to be called when the user navigates to the next/prev month/year/decade
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the current view (eg: "month")
* @param {Number} direction 1 or -1. 1 if the right arrow, to nav to next period was pressed. -1 if the left arrow, to nav to the prev period was pressed.
* @param {Event} event
*
* @type {Function}
*/
onNav: PT.func,
/**
* Function to be called when the user selects a year/month.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the view displayed after following the selection. For now, either "year" or "month"
*
* @type {Function}
*/
onSelect: PT.func,
/**
* A function that should return a React DOM for the day cell. The first param is the props object.
* You can use this to have full control over what gets rendered for a day.
*
* @param {Object} dayProps The props object passed to day rendering
*
* @type {Function}
*/
renderDay: PT.func,
/**
* A function that can manipulate the props object for a day, and SHOULD return a props object (a new one, or the same).
* Use this for CUSTOM DAY STYLING.
* You can use this to take full control over the styles/css classes/attributes applied to the day cell in the month view.
*
* @param {Object} dayProps
* @return {Object} dayProps
*
* @type {Function}
*/
onRenderDay: PT.func,
/******************************************/
/********** VIEW-related props ************/
/******************************************/
/**
* The default view to show in the picker. This is an uncontrolled prop.
* If none specified, the default view will be "month"
*
* @type {String}
*/
defaultView: PT.string,
/**
* The view to show in the picker. This is a CONTROLLED prop!
*
* When using this controlled prop, make sure you update it when `onViewChange` function is called
* if you want to navigate to another view, as expected.
*
* @type {String}
*/
view: PT.string,
/**
* A function to be called when navigating to another view date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view the name of the view displayed after the navigation occurs.
*
* @type {Function}
*/
onViewDateChange: PT.func,
/**
* A function to be called when the view is changed.
* If you're using the controlled `view` prop, make sure you update the `view` prop in this function if you want to navigate to another view, as expected.
*
* @param {String} nextView One of "month", "year", "decade"
*
* @type {Function}
*/
onViewChange: PT.func,
/**
* Defaults to true. If specified as false, will not navigate to the date that was clicked, even if that date is in the prev/next month
* @type {Boolean}
*/
navOnDateClick: PT.bool
};
module.exports = DatePicker;
{
"name": "react-date-picker",
"version": "2.1.8",
"description": "React Date Picker",
"version": "2.1.9",
"description": "A carefully crafted date picker for React",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -9,3 +9,3 @@ react-date-picker

> A carefully crafted date picker for React
> A date picker built especially for React, with love.

@@ -12,0 +12,0 @@ [![Date picker](./react-date-picker.png)](http://zippyui.github.io/react-date-picker)

@@ -477,2 +477,122 @@ 'use strict'

var PT = React.PropTypes
DatePicker.propTypes = {
/**
* Function to be called when user selects a date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {Event} event
*
* @type {Function}
*/
onChange: PT.func,
/**
* Function to be called when the user navigates to the next/prev month/year/decade
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the current view (eg: "month")
* @param {Number} direction 1 or -1. 1 if the right arrow, to nav to next period was pressed. -1 if the left arrow, to nav to the prev period was pressed.
* @param {Event} event
*
* @type {Function}
*/
onNav: PT.func,
/**
* Function to be called when the user selects a year/month.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view The name of the view displayed after following the selection. For now, either "year" or "month"
*
* @type {Function}
*/
onSelect: PT.func,
/**
* A function that should return a React DOM for the day cell. The first param is the props object.
* You can use this to have full control over what gets rendered for a day.
*
* @param {Object} dayProps The props object passed to day rendering
*
* @type {Function}
*/
renderDay: PT.func,
/**
* A function that can manipulate the props object for a day, and SHOULD return a props object (a new one, or the same).
* Use this for CUSTOM DAY STYLING.
* You can use this to take full control over the styles/css classes/attributes applied to the day cell in the month view.
*
* @param {Object} dayProps
* @return {Object} dayProps
*
* @type {Function}
*/
onRenderDay: PT.func,
/******************************************/
/********** VIEW-related props ************/
/******************************************/
/**
* The default view to show in the picker. This is an uncontrolled prop.
* If none specified, the default view will be "month"
*
* @type {String}
*/
defaultView: PT.string,
/**
* The view to show in the picker. This is a CONTROLLED prop!
*
* When using this controlled prop, make sure you update it when `onViewChange` function is called
* if you want to navigate to another view, as expected.
*
* @type {String}
*/
view: PT.string,
/**
* A function to be called when navigating to another view date.
*
* Called with the following params:
*
* @param {String} dateText Date formatted as string
* @param {Moment} moment Moment.js instance
* @param {String} view the name of the view displayed after the navigation occurs.
*
* @type {Function}
*/
onViewDateChange: PT.func,
/**
* A function to be called when the view is changed.
* If you're using the controlled `view` prop, make sure you update the `view` prop in this function if you want to navigate to another view, as expected.
*
* @param {String} nextView One of "month", "year", "decade"
*
* @type {Function}
*/
onViewChange: PT.func,
/**
* Defaults to true. If specified as false, will not navigate to the date that was clicked, even if that date is in the prev/next month
* @type {Boolean}
*/
navOnDateClick: PT.bool
}
module.exports = DatePicker

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

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