Socket
Socket
Sign inDemoInstall

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.0 to 2.0.1

31

dist/react-date-picker.js

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

props.onChange = this.handleChange
props.onSelect = this.handleSelect
// props.onChange = this.handleChange
// props.onSelect = this.handleSelect

@@ -207,5 +207,8 @@ var className = (this.props.className || '') + ' date-picker'

var viewProps = props
var viewProps = asConfig(props)
viewProps.localeData = props.localeData
viewProps.onSelect = this.handleSelect
viewProps.onChange = this.handleChange

@@ -215,3 +218,3 @@ return (

React.createElement("div", {className: "dp-inner", style: {width: '100%', height: '100%', display: 'flex', flexFlow: 'column'}},
this.renderHeader(view),
this.renderHeader(view, props),

@@ -305,6 +308,8 @@ React.createElement("div", {className: "dp-body", style: {flex: 1}},

renderHeader: function(view) {
renderHeader: function(view, props) {
props = props || this.props
var viewDate = this.getViewDate()
var headerText = this.getView().getHeaderText(viewDate)
var headerText = this.getView().getHeaderText(viewDate, props.locale)

@@ -746,4 +751,4 @@ var colspan = this.getViewColspan()

MonthView.getHeaderText = function(moment) {
return toMoment(moment).format('MMMM YYYY')
MonthView.getHeaderText = function(moment, props) {
return toMoment(moment, null, {locale: props.locale}).format('MMMM YYYY')
}

@@ -864,3 +869,3 @@

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -872,4 +877,4 @@

YearView.getHeaderText = function(moment) {
return toMoment(moment).format('YYYY')
YearView.getHeaderText = function(moment, props) {
return toMoment(moment, null, { locale: props.locale }).format('YYYY')
}

@@ -1003,3 +1008,3 @@

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -1010,3 +1015,3 @@ ;(props.onSelect || emptyFn)(date, event)

DecadeView.getHeaderText = function(value) {
DecadeView.getHeaderText = function(value, props) {
var year = moment(value).get('year')

@@ -1108,3 +1113,3 @@ var offset = year % 10

// value:
return moment(value == null? new Date(): value)//, undefined, locale, strict)
return moment(value == null? new Date(): value, undefined, locale, strict)
}

@@ -1111,0 +1116,0 @@

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

props.onChange = this.handleChange
props.onSelect = this.handleSelect
// props.onChange = this.handleChange
// props.onSelect = this.handleSelect

@@ -207,5 +207,8 @@ var className = (this.props.className || '') + ' date-picker'

var viewProps = props
var viewProps = asConfig(props)
viewProps.localeData = props.localeData
viewProps.onSelect = this.handleSelect
viewProps.onChange = this.handleChange

@@ -215,3 +218,3 @@ return (

React.createElement("div", {className: "dp-inner", style: {width: '100%', height: '100%', display: 'flex', flexFlow: 'column'}},
this.renderHeader(view),
this.renderHeader(view, props),

@@ -305,6 +308,8 @@ React.createElement("div", {className: "dp-body", style: {flex: 1}},

renderHeader: function(view) {
renderHeader: function(view, props) {
props = props || this.props
var viewDate = this.getViewDate()
var headerText = this.getView().getHeaderText(viewDate)
var headerText = this.getView().getHeaderText(viewDate, props.locale)

@@ -746,4 +751,4 @@ var colspan = this.getViewColspan()

MonthView.getHeaderText = function(moment) {
return toMoment(moment).format('MMMM YYYY')
MonthView.getHeaderText = function(moment, props) {
return toMoment(moment, null, {locale: props.locale}).format('MMMM YYYY')
}

@@ -864,3 +869,3 @@

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -872,4 +877,4 @@

YearView.getHeaderText = function(moment) {
return toMoment(moment).format('YYYY')
YearView.getHeaderText = function(moment, props) {
return toMoment(moment, null, { locale: props.locale }).format('YYYY')
}

@@ -1003,3 +1008,3 @@

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -1010,3 +1015,3 @@ ;(props.onSelect || emptyFn)(date, event)

DecadeView.getHeaderText = function(value) {
DecadeView.getHeaderText = function(value, props) {
var year = moment(value).get('year')

@@ -1108,3 +1113,3 @@ var offset = year % 10

// value:
return moment(value == null? new Date(): value)//, undefined, locale, strict)
return moment(value == null? new Date(): value, undefined, locale, strict)
}

@@ -1111,0 +1116,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(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),d=n(12),l=n(9),h=n(10),u=n(3),p=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={month:c,year:d,decade:l},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=this.toMoment(e||this.viewMoment||this.props.date||new Date)},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),e.renderDay=this.props.renderDay,e.onRenderDay=this.props.onRenderDay,e.onChange=this.handleChange,e.onSelect=this.handleSelect;var n=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var a=i(e);return a.localeData=e.localeData,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),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(){var e=this.getViewDate(),t=this.getView().getHeaderText(e),n=this.getViewColspan(),a=this.props.navPrev,o=this.props.navNext;return r.createElement(h,{prevText:a,nextText:o,colspan:n,onPrev:this.handleNavPrev,onNext:this.handleNavNext,onChange:this.handleViewChange},t)},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)}},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),d=n(5),s=(n(3),n(1)),l=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return d()},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){t.target.value=e,(props.onSelect||a)(e,t)}});l.getHeaderText=function(e){var t=i(e).get("year"),n=t%10;return t=t-n-1,t+" - "+(t+11)},e.exports=l},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),d=n(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,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 d(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 d=o.DOM.td,l=e.renderDay||d,h=l(c);return void 0===h&&(h=d(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))}});l.getHeaderText=function(e){return d(e).format("MMMM YYYY")},e.exports=l},function(e,t,n){"use strict";function a(){}var r,o=n(4),i=n(2),s=n(7),c=n(5),d=n(3),l=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=l({},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){t.target.value=e,(props.onSelect||a)(e,t)}});h.getHeaderText=function(e){return d(e).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=(a(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(),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=this.toMoment(e||this.viewMoment||this.props.date||new Date)},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.locale),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();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 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}])});

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

window.moment = require('moment')
require('moment/locale/ro')

@@ -67,3 +66,3 @@ var React = require('react')

xweekStartDay={0}
xlocale="fr"
locale="ro"
xweekDayNames={['SUND','mon','marti','miercuri','joi','vineri','sam']}

@@ -70,0 +69,0 @@ minDate='2013-04-04' maxDate='2015-10-10' date={v} onChange={this.onChange}/>

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

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -128,3 +128,3 @@ ;(props.onSelect || emptyFn)(date, event)

DecadeView.getHeaderText = function(value) {
DecadeView.getHeaderText = function(value, props) {
var year = moment(value).get('year')

@@ -131,0 +131,0 @@ var offset = year % 10

@@ -143,4 +143,4 @@ 'use strict'

props.onChange = this.handleChange
props.onSelect = this.handleSelect
// props.onChange = this.handleChange
// props.onSelect = this.handleSelect

@@ -151,5 +151,8 @@ var className = (this.props.className || '') + ' date-picker'

var viewProps = props
var viewProps = asConfig(props)
viewProps.localeData = props.localeData
viewProps.onSelect = this.handleSelect
viewProps.onChange = this.handleChange

@@ -159,3 +162,3 @@ return (

React.createElement("div", {className: "dp-inner", style: {width: '100%', height: '100%', display: 'flex', flexFlow: 'column'}},
this.renderHeader(view),
this.renderHeader(view, props),

@@ -249,6 +252,8 @@ React.createElement("div", {className: "dp-body", style: {flex: 1}},

renderHeader: function(view) {
renderHeader: function(view, props) {
props = props || this.props
var viewDate = this.getViewDate()
var headerText = this.getView().getHeaderText(viewDate)
var headerText = this.getView().getHeaderText(viewDate, props.locale)

@@ -255,0 +260,0 @@ var colspan = this.getViewColspan()

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

MonthView.getHeaderText = function(moment) {
return toMoment(moment).format('MMMM YYYY')
MonthView.getHeaderText = function(moment, props) {
return toMoment(moment, null, {locale: props.locale}).format('MMMM YYYY')
}
module.exports = MonthView

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

// value:
return moment(value == null? new Date(): value)//, undefined, locale, strict)
return moment(value == null? new Date(): value, undefined, locale, strict)
}

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

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -116,6 +116,6 @@

YearView.getHeaderText = function(moment) {
return toMoment(moment).format('YYYY')
YearView.getHeaderText = function(moment, props) {
return toMoment(moment, null, { locale: props.locale }).format('YYYY')
}
module.exports = YearView
{
"name": "react-date-picker",
"version": "2.0.0",
"version": "2.0.1",
"description": "React Date Picker",

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

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

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -128,3 +128,3 @@ ;(props.onSelect || emptyFn)(date, event)

DecadeView.getHeaderText = function(value) {
DecadeView.getHeaderText = function(value, props) {
var year = moment(value).get('year')

@@ -131,0 +131,0 @@ var offset = year % 10

@@ -143,4 +143,4 @@ 'use strict'

props.onChange = this.handleChange
props.onSelect = this.handleSelect
// props.onChange = this.handleChange
// props.onSelect = this.handleSelect

@@ -151,5 +151,8 @@ var className = (this.props.className || '') + ' date-picker'

var viewProps = props
var viewProps = asConfig(props)
viewProps.localeData = props.localeData
viewProps.onSelect = this.handleSelect
viewProps.onChange = this.handleChange

@@ -159,3 +162,3 @@ return (

<div className="dp-inner" style={{width: '100%', height: '100%', display: 'flex', flexFlow: 'column'}}>
{this.renderHeader(view)}
{this.renderHeader(view, props)}

@@ -249,6 +252,8 @@ <div className="dp-body" style={{flex: 1}}>

renderHeader: function(view) {
renderHeader: function(view, props) {
props = props || this.props
var viewDate = this.getViewDate()
var headerText = this.getView().getHeaderText(viewDate)
var headerText = this.getView().getHeaderText(viewDate, props.locale)

@@ -255,0 +260,0 @@ var colspan = this.getViewColspan()

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

MonthView.getHeaderText = function(moment) {
return toMoment(moment).format('MMMM YYYY')
MonthView.getHeaderText = function(moment, props) {
return toMoment(moment, null, {locale: props.locale}).format('MMMM YYYY')
}
module.exports = MonthView

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

// value:
return moment(value == null? new Date(): value)//, undefined, locale, strict)
return moment(value == null? new Date(): value, undefined, locale, strict)
}

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

handleClick: function(date, event) {
handleClick: function(props, date, event) {
event.target.value = date

@@ -116,6 +116,6 @@

YearView.getHeaderText = function(moment) {
return toMoment(moment).format('YYYY')
YearView.getHeaderText = function(moment, props) {
return toMoment(moment, null, { locale: props.locale }).format('YYYY')
}
module.exports = YearView

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