react-mobile-datepicker
Advanced tools
Comparing version 3.0.10 to 3.0.11
@@ -0,1 +1,7 @@ | ||
[3.0.11](../../releases/tag/3.0.11) 2018-05-12 10:57:46 | ||
----------------------------------------------------------- | ||
- [b6d6b5e](../../commit/b6d6b5e) ✨ [feature] map month number to month name(https://github.com/lanjingling0510/react-mobile-datepicker/issues/26) | ||
[3.0.10](../../releases/tag/3.0.10) 2018-04-24 22:50:29 | ||
@@ -2,0 +8,0 @@ ----------------------------------------------------------- |
@@ -471,2 +471,8 @@ (function (global, factory) { | ||
}; | ||
var isArray = function isArray(val) { | ||
return Object.prototype.toString.apply(val) === '[object Array]'; | ||
}; | ||
var isFunction = function isFunction(val) { | ||
return Object.prototype.toString.apply(val) === '[object Function]'; | ||
}; | ||
@@ -523,3 +529,13 @@ /** | ||
// 设置时间选择器单元的类别 | ||
_this.typeName = getTimeType(props.format); | ||
if (isArray(props.format)) { | ||
_this.typeName = getTimeType(props.format[0]); | ||
_this.format = props.format[0]; | ||
if (isFunction(props.format[1])) { | ||
_this.formatTransform = props.format[1]; | ||
} | ||
} else { | ||
_this.format = props.format; | ||
_this.typeName = getTimeType(props.format); | ||
} | ||
_this.renderDatepickerItem = _this.renderDatepickerItem.bind(_this); | ||
@@ -787,2 +803,7 @@ _this.handleContentTouch = _this.handleContentTouch.bind(_this); | ||
var formatDate = convertDate(date, this.format); | ||
if (this.formatTransform) { | ||
formatDate = this.formatTransform(formatDate); | ||
} | ||
return React__default.createElement( | ||
@@ -793,3 +814,3 @@ 'li', | ||
className: className }, | ||
convertDate(date, this.props.format) | ||
formatDate | ||
); | ||
@@ -796,0 +817,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.reactMobileDatePicker=t(e.React,e.ReactDOM)}(this,function(e,n){"use strict";var f="default"in e?e.default:e;function o(e){if("[object Date]"!==Object.prototype.toString.call(e,null))throw new Error("参数类型不对")}function k(e,t){var n=t,r={"M+":e.getMonth()+1,"D+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds()};for(var a in/(Y+)/.test(t)&&(n=n.replace(RegExp.$1,e.getFullYear().toString().substr(4-RegExp.$1.length))),r)new RegExp("("+a+")").test(t)&&(n=n.replace(RegExp.$1,1===RegExp.$1.length?r[a]:("00"+r[a]).substr(r[a].toString().length)));return n}function r(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+24*t*60*60*1e3)}n=n&&n.hasOwnProperty("default")?n.default:n,function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".datepicker-modal {\n position: fixed;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, .6);\n z-index: 999;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n\n.datepicker {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n z-index: 1;\n font-size: 16px;\n text-align: center;\n font-family: arial,verdana,sans-serif;\n -webkit-box-sizing: content-box;\n box-sizing: content-box;\n -webkit-font-smoothing: antialiased;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.datepicker .datepicker-header {\n padding: 0 .5em;\n min-height: 2em;\n line-height: 2em;\n font-size: 1.125em;\n }\n\n.datepicker .datepicker-navbar {\n padding: 0 .5em .5em .5em;\n overflow: hidden;\n }\n\n.datepicker .datepicker-navbar-btn {\n height: 2.5em;\n line-height: 2.5em;\n float: right;\n padding: 0 1em;\n cursor: pointer;\n }\n\n.datepicker .datepicker-content {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n padding: .5em .25em;\n }\n\n.datepicker .datepicker-col-1 {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n margin: 0 .25em;\n }\n\n.datepicker .datepicker-viewport {\n height: 200px;\n position: relative;\n overflow: hidden\n }\n\n.datepicker .datepicker-viewport::after {\n content: '';\n position: absolute;\n z-index: 2;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n pointer-events: none;\n}\n\n.datepicker .datepicker-wheel {\n position: absolute;\n height: 40px;\n top: 50%;\n margin-top: -20px;\n width: 100%;\n }\n\n.datepicker .datepicker-scroll {\n list-style-type: none;\n padding: 0\n }\n\n.datepicker .datepicker-scroll>li {\n height: 40px;\n line-height: 40px;\n font-size: 1.375em;\n cursor: pointer;\n}\n\n.datepicker {\n\n /* default */\n}\n\n.datepicker.default {\n background-color: #f7f7f7;\n}\n\n.datepicker.default .datepicker-header {\n color: #4eccc4;\n}\n\n.datepicker.default .datepicker-wheel {\n border-top: 1px solid #4eccc4;\n border-bottom: 1px solid #4eccc4;\n}\n\n.datepicker.default .datepicker-scroll li {\n color: rgb(59, 59, 59);\n }\n\n.datepicker.default .datepicker-scroll li.disabled {\n color: rgb(191, 191, 191);\n }\n\n.datepicker.default .datepicker-navbar-btn {\n color: #4eccc4;\n}\n\n.datepicker {\n\n /* dark */\n}\n\n.datepicker.dark {\n background-color: #263238;\n}\n\n.datepicker.dark .datepicker-header {\n color: #50ccc4;\n}\n\n.datepicker.dark .datepicker-wheel {\n border-top: 1px solid #50ccc4;\n border-bottom: 1px solid #50ccc4;\n}\n\n.datepicker.dark .datepicker-scroll li {\n color: rgb(201, 203, 204);\n }\n\n.datepicker.dark .datepicker-scroll li.disabled {\n color: rgb(87, 96, 100);\n }\n\n.datepicker.dark .datepicker-navbar-btn {\n color: #50ccc4;\n}\n\n.datepicker {\n\n /* ios */\n}\n\n.datepicker.ios {\n background-color: #f7f7f7;\n}\n\n.datepicker.ios .datepicker-col-1 {margin: 0;\n}\n\n.datepicker.ios .datepicker-header {\n color: rgb(59, 59, 59);\n padding: 0 3.5em;\n}\n\n.datepicker.ios .datepicker-viewport::after {\n background: -webkit-gradient(linear,left top, left bottom,from(#f7f7f7),color-stop(52%, rgba(245, 245, 245, 0)),color-stop(48%, rgba(245, 245, 245, 0)),to(#f7f7f7));\n background: linear-gradient(#f7f7f7,rgba(245, 245, 245, 0)52%,rgba(245, 245, 245, 0)48%,#f7f7f7);\n}\n\n.datepicker.ios .datepicker-wheel {\n border-top: 1px solid #dbdbdb;\n border-bottom: 1px solid #dbdbdb;\n}\n\n.datepicker.ios .datepicker-scroll li {\n color: rgb(59, 59, 59);\n }\n\n.datepicker.ios .datepicker-scroll li.disabled {\n color: rgb(191, 191, 191);\n }\n\n.datepicker.ios .datepicker-navbar {\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 100%;\n padding: 0;\n border-bottom: 1px solid #acacac;\n}\n\n.datepicker.ios .datepicker-navbar-btn {\n color: #007aff;\n}\n\n.datepicker.ios .datepicker-navbar-btn:nth-child(2) {\n float: left;\n}\n\n.datepicker.ios .datepicker-content {\n padding-top: 48px;\n}\n\n.datepicker.ios .datepicker-header + .datepicker-content {\n padding-top: 0;\n}\n\n.datepicker {\n\n /* android */\n}\n\n.datepicker.android, .datepicker.android-dark {\n background-color: #f5f5f5;\n}\n\n.datepicker.android .datepicker-header, .datepicker.android-dark .datepicker-header {\n color: #31b6e7;\n border-bottom: 2px solid #31b6e7;\n}\n\n.datepicker.android .datepicker-col-1, .datepicker.android-dark .datepicker-col-1 {margin: 0 .625em;\n}\n\n.datepicker.android .datepicker-viewport::after, .datepicker.android-dark .datepicker-viewport::after {\n background-image: -webkit-gradient(linear,left top, left bottom,from(#f5f5f5),color-stop(52%, rgba(245, 245, 245, 0)),color-stop(48%, rgba(245, 245, 245, 0)),to(#f5f5f5));\n background-image: linear-gradient(#f5f5f5,rgba(245, 245, 245, 0)52%,rgba(245, 245, 245, 0)48%,#f5f5f5);\n}\n\n.datepicker.android .datepicker-wheel, .datepicker.android-dark .datepicker-wheel {\n border-top: 2px solid #31b6e7;\n border-bottom: 2px solid #31b6e7;\n}\n\n.datepicker.android .datepicker-scroll li, .datepicker.android-dark .datepicker-scroll li {\n font-size: 1.125em;\n color: rgb(56, 56, 56);\n }\n\n.datepicker.android .datepicker-scroll li.disabled, .datepicker.android-dark .datepicker-scroll li.disabled {\n color: rgb(188, 188, 188);\n }\n\n.datepicker.android .datepicker-navbar, .datepicker.android-dark .datepicker-navbar {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n border-top: 1px solid #d9d4d4;\n padding: 0;\n}\n\n.datepicker.android .datepicker-navbar-btn, .datepicker.android-dark .datepicker-navbar-btn {\n padding: 0;\n color: #000;\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n}\n\n.datepicker.android .datepicker-navbar-btn:nth-child(2), .datepicker.android-dark .datepicker-navbar-btn:nth-child(2) {\n border-left: 1px solid #d9d4d4;\n}\n\n.datepicker {\n\n /* android-dark */\n}\n\n.datepicker.android-dark {\n background-color: #292829;\n}\n\n.datepicker.android-dark .datepicker-viewport::after {\n background-image: -webkit-gradient(linear,left top, left bottom,from(#282828),color-stop(52%, rgba(40, 40, 40, 0)),color-stop(48%, rgba(40, 40, 40, 0)),to(#282828));\n background-image: linear-gradient(#282828,rgba(40, 40, 40, 0)52%,rgba(40, 40, 40, 0)48%,#282828);\n}\n\n.datepicker.android-dark .datepicker-scroll li {\n color: rgb(199, 199, 199);\n }\n\n.datepicker.android-dark .datepicker-scroll li.disabled {\n color: rgb(88, 88, 88);\n }\n\n.datepicker.android-dark .datepicker-navbar { border-color: #424542;\n}\n\n.datepicker.android-dark .datepicker-navbar-btn {\n color: #fff;\n}\n\n.datepicker.android-dark .datepicker-navbar-btn:nth-child(2) {\n border-color: #424542;\n}\n",{});var i=Object.freeze({convertDate:k,nextYear:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getFullYear()+t,e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())},nextMonth:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;o(e);var n=e.getFullYear(),r=e.getMonth()+t,a=Math.min(e.getDate(),new Date(n,r+1,0).getDate());return new Date(n,r,a,e.getHours(),e.getMinutes(),e.getSeconds())},nextDate:r,nextHour:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+60*t*60*1e3)},nextMinute:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+60*t*1e3)},nextSecond:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+1e3*t)}});function a(t,n){if(t===n)return!0;var e=Object.keys(t),r=Object.keys(n);return e.length===r.length&&e.every(function(e){return t.hasOwnProperty(e)&&t[e]===n[e]})}function d(e){e.prototype.shouldComponentUpdate=function(e,t){return d.shouldComponentUpdate(e,t,this.props,this.state)}}function c(e){var t=["-webkit-","-moz-","-ms-"],n={},r=/transform|transition/;for(var a in e)if(e.hasOwnProperty(a)){var o=e[a];if(r.test(a))for(var i=0;i<t.length;i++){n[(t[i]+a).replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}).replace("-","")]=o.replace(r,t[i]+"$&")}n[a]=o}return n}function s(e,t){var n=c(t);for(var r in n)n.hasOwnProperty(r)&&(e.style[r]=n[r])}d.shouldComponentUpdate=function(e,t,n,r){return!a(n,e)||!a(r,t)};!function(){function s(e){this.value=e}function e(a){var o,i;function d(e,t){try{var n=a[e](t),r=n.value;r instanceof s?Promise.resolve(r.value).then(function(e){d("next",e)},function(e){d("throw",e)}):c(n.done?"return":"normal",n.value)}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?d(o.key,o.arg):i=null}this._invoke=function(r,a){return new Promise(function(e,t){var n={key:r,arg:a,resolve:e,reject:t,next:null};i?i=i.next=n:(o=i=n,d(r,a))})},"function"!=typeof a.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(e){return this._invoke("next",e)},e.prototype.throw=function(e){return this._invoke("throw",e)},e.prototype.return=function(e){return this._invoke("return",e)}}();var l=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},p=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},m=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},v=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},b=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},g=40,y=Math.floor(5),x=-g*y,w=function(e){return void 0===e},C=function(e){var t={Y:"Year",M:"Month",D:"Date",h:"Hour",m:"Minute",s:"Second"};for(var n in t)if(t.hasOwnProperty(n)&&~e.indexOf(n))return t[n];throw new Error("时间格式必须包含 Y, M, D, h, m 或 s字母")},T=function(e){function n(e){l(this,n);var t=v(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.animating=!1,t.touchY=0,t.translateY=0,t.currentIndex=y,t.moveDateCount=0,t.state={translateY:x,marginTop:(t.currentIndex-y)*g},t.typeName=C(e.format),t.renderDatepickerItem=t.renderDatepickerItem.bind(t),t.handleContentTouch=t.handleContentTouch.bind(t),t.handleContentMouseDown=t.handleContentMouseDown.bind(t),t.handleContentMouseMove=t.handleContentMouseMove.bind(t),t.handleContentMouseUp=t.handleContentMouseUp.bind(t),t}return h(n,e),p(n,[{key:"componentWillMount",value:function(){this._iniDates(this.props.value)}},{key:"componentDidMount",value:function(){var e=this.viewport;e.addEventListener("touchstart",this.handleContentTouch,!1),e.addEventListener("touchmove",this.handleContentTouch,!1),e.addEventListener("touchend",this.handleContentTouch,!1),e.addEventListener("mousedown",this.handleContentMouseDown,!1)}},{key:"componentWillReceiveProps",value:function(e){e.value.getTime()!==this.props.value.getTime()&&(this._iniDates(e.value),this.currentIndex=y,this.setState({translateY:x,marginTop:(this.currentIndex-y)*g}))}},{key:"shouldComponentUpdate",value:function(e,t){return e.value.getTime()!==this.props.value.getTime()||!a(t,this.state)}},{key:"componentWillUnmount",value:function(){var e=this.viewport;e.removeEventListener("touchstart",this.handleContentTouch,!1),e.removeEventListener("touchmove",this.handleContentTouch,!1),e.removeEventListener("touchend",this.handleContentTouch,!1),e.removeEventListener("mousedown",this.handleContentMouseDown,!1)}},{key:"_iniDates",value:function(n){var r=this,a=this.typeName,e=Array.apply(void 0,b(Array(10))).map(function(e,t){return i["next"+a](n,(t-y)*r.props.step)});this.setState({dates:e})}},{key:"_updateDates",value:function(e){var t=this.typeName,n=this.state.dates;1===e?(this.currentIndex++,this.setState({dates:[].concat(b(n.slice(1)),[i["next"+t](n[n.length-1],this.props.step)]),marginTop:(this.currentIndex-y)*g})):(this.currentIndex--,this.setState({dates:[i["next"+t](n[0],-this.props.step)].concat(b(n.slice(0,n.length-1))),marginTop:(this.currentIndex-y)*g}))}},{key:"_checkIsUpdateDates",value:function(e,t){return 1===e?this.currentIndex*g+g/2<-t:this.currentIndex*g-g/2>-t}},{key:"_clearTransition",value:function(e){s(e,{transition:""})}},{key:"_moveToNext",value:function(e){var t=this.state.dates[y],n=this.props,r=n.max,a=n.min;-1===e&&t.getTime()<a.getTime()&&this.moveDateCount?this._updateDates(1):1===e&&t.getTime()>r.getTime()&&this.moveDateCount&&this._updateDates(-1),this._moveTo(this.refs.scroll,this.currentIndex)}},{key:"_moveTo",value:function(e,t){var n=this;this.animating=!0,s(e,{transition:"transform .2s ease-out"}),this.setState({translateY:-t*g}),setTimeout(function(){n.animating=!1,n.props.onSelect(n.state.dates[y]),n._clearTransition(n.refs.scroll)},200)}},{key:"handleStart",value:function(e){this.touchY=w(e.targetTouches)||w(e.targetTouches[0])?e.pageY:e.targetTouches[0].pageY,this.translateY=this.state.translateY,this.moveDateCount=0}},{key:"handleMove",value:function(e){var t=(w(e.targetTouches)||w(e.targetTouches[0])?e.pageY:e.targetTouches[0].pageY)-this.touchY,n=this.translateY+t,r=0<t?-1:1,a=this.state.dates[y],o=this.props,i=o.max,d=o.min;a.getTime()<d.getTime()||a.getTime()>i.getTime()||(this._checkIsUpdateDates(r,n)&&(this.moveDateCount=0<r?this.moveDateCount+1:this.moveDateCount-1,this._updateDates(r)),this.setState({translateY:n}))}},{key:"handleEnd",value:function(e){var t=0<(e.pageY||e.changedTouches[0].pageY)-this.touchY?-1:1;this._moveToNext(t)}},{key:"handleContentTouch",value:function(e){e.preventDefault(),this.animating||("touchstart"===e.type?this.handleStart(e):"touchmove"===e.type?this.handleMove(e):"touchend"===e.type&&this.handleEnd(e))}},{key:"handleContentMouseDown",value:function(e){this.animating||(this.handleStart(e),document.addEventListener("mousemove",this.handleContentMouseMove),document.addEventListener("mouseup",this.handleContentMouseUp))}},{key:"handleContentMouseMove",value:function(e){this.animating||this.handleMove(e)}},{key:"handleContentMouseUp",value:function(e){this.animating||(this.handleEnd(e),document.removeEventListener("mousemove",this.handleContentMouseMove),document.removeEventListener("mouseup",this.handleContentMouseUp))}},{key:"renderDatepickerItem",value:function(e,t){var n=e<this.props.min||e>this.props.max?"disabled":"";return f.createElement("li",{key:t,className:n},k(e,this.props.format))}},{key:"render",value:function(){var t=this,e=c({transform:"translateY("+this.state.translateY+"px)",marginTop:this.state.marginTop});return f.createElement("div",{className:"datepicker-col-1"},f.createElement("div",{ref:function(e){return t.viewport=e},className:"datepicker-viewport"},f.createElement("div",{className:"datepicker-wheel"},f.createElement("ul",{ref:"scroll",className:"datepicker-scroll",style:e},this.state.dates.map(this.renderDatepickerItem)))))}}]),n}(e.Component),D=function(e){function n(e){l(this,n);var t=v(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state={value:r(t.props.value)},t.handleFinishBtnClick=t.handleFinishBtnClick.bind(t),t.handleDateSelect=t.handleDateSelect.bind(t),t}return h(n,e),p(n,[{key:"componentWillReceiveProps",value:function(e){var t=r(e.value);t.getTime()!==this.state.value.getTime()&&this.setState({value:t})}},{key:"shouldComponentUpdate",value:function(e,t){return r(t.value).getTime()!==this.state.value.getTime()||d.shouldComponentUpdate(e,t,this.props,this.state)}},{key:"handleFinishBtnClick",value:function(){this.props.onSelect(this.state.value)}},{key:"handleDateSelect",value:function(e){this.setState({value:e})}},{key:"render",value:function(){var n=this,e=this.props,r=e.min,a=e.max,t=e.theme,o=e.dateFormat,i=e.confirmText,d=e.cancelText,c=e.showFormat,s=e.showHeader,l=e.customHeader,p=e.dateSteps,u=this.state.value,h=-1===["default","dark","ios","android","android-dark"].indexOf(t)?"default":t;return f.createElement("div",{className:"datepicker "+h},s&&f.createElement("div",{className:"datepicker-header"},l||k(u,c)),f.createElement("div",{className:"datepicker-content"},o.map(function(e,t){return f.createElement(T,{key:t,step:p[t]||1,value:u,min:r,max:a,format:e,onSelect:n.handleDateSelect})})),f.createElement("div",{className:"datepicker-navbar"},f.createElement("a",{className:"datepicker-navbar-btn",onClick:this.handleFinishBtnClick},i),f.createElement("a",{className:"datepicker-navbar-btn",onClick:this.props.onCancel},d)))}}]),n}(e.Component),E=n.unstable_renderSubtreeIntoContainer,M=function(e){function t(){return l(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return h(t,e),p(t,[{key:"componentDidMount",value:function(){this._div=document.createElement("div"),this._div.classList.add("Modal-Portal"),document.body.appendChild(this._div),this.renderPortal(this.props)}},{key:"componentWillReceiveProps",value:function(e){this.renderPortal(e)}},{key:"componentWillUnmount",value:function(){n.unmountComponentAtNode(this._div),this._div.parentNode.removeChild(this._div)}},{key:"renderPortal",value:function(e){var t=f.cloneElement(this.props.children,u({},e,{key:"portal"}),null);this.portal=E(this,t,this._div)}},{key:"render",value:function(){return f.createElement("noscript",null)}}]),t}(e.Component);function _(e){var t=e.isOpen,n=m(e,["isOpen"]);return f.createElement("div",{style:{display:t?"":"none"},onClick:function(e){e.target===e.currentTarget&&n.onCancel()},className:"datepicker-modal"},f.createElement(D,n))}function t(e){var t=e.isPopup,n=m(e,["isPopup"]);return t?f.createElement(M,n,f.createElement(_,null)):f.createElement(D,n)}return M.defaultProps={isOpen:!1},t.defaultProps={isPopup:!0,isOpen:!1,theme:"default",value:new Date,min:new Date(1970,0,1),max:new Date(2050,0,1),showHeader:!0,dateFormat:["YYYY","M","D"],dateSteps:[1,1,1],showFormat:"YYYY/MM/DD",confirmText:"完成",cancelText:"取消",onSelect:function(){},onCancel:function(){}},t}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.reactMobileDatePicker=t(e.React,e.ReactDOM)}(this,function(e,n){"use strict";var f="default"in e?e.default:e;function o(e){if("[object Date]"!==Object.prototype.toString.call(e,null))throw new Error("参数类型不对")}function m(e,t){var n=t,r={"M+":e.getMonth()+1,"D+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds()};for(var a in/(Y+)/.test(t)&&(n=n.replace(RegExp.$1,e.getFullYear().toString().substr(4-RegExp.$1.length))),r)new RegExp("("+a+")").test(t)&&(n=n.replace(RegExp.$1,1===RegExp.$1.length?r[a]:("00"+r[a]).substr(r[a].toString().length)));return n}function r(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+24*t*60*60*1e3)}n=n&&n.hasOwnProperty("default")?n.default:n,function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".datepicker-modal {\n position: fixed;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, .6);\n z-index: 999;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n\n.datepicker {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n z-index: 1;\n font-size: 16px;\n text-align: center;\n font-family: arial,verdana,sans-serif;\n -webkit-box-sizing: content-box;\n box-sizing: content-box;\n -webkit-font-smoothing: antialiased;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.datepicker .datepicker-header {\n padding: 0 .5em;\n min-height: 2em;\n line-height: 2em;\n font-size: 1.125em;\n }\n\n.datepicker .datepicker-navbar {\n padding: 0 .5em .5em .5em;\n overflow: hidden;\n }\n\n.datepicker .datepicker-navbar-btn {\n height: 2.5em;\n line-height: 2.5em;\n float: right;\n padding: 0 1em;\n cursor: pointer;\n }\n\n.datepicker .datepicker-content {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n padding: .5em .25em;\n }\n\n.datepicker .datepicker-col-1 {\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n margin: 0 .25em;\n }\n\n.datepicker .datepicker-viewport {\n height: 200px;\n position: relative;\n overflow: hidden\n }\n\n.datepicker .datepicker-viewport::after {\n content: '';\n position: absolute;\n z-index: 2;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n pointer-events: none;\n}\n\n.datepicker .datepicker-wheel {\n position: absolute;\n height: 40px;\n top: 50%;\n margin-top: -20px;\n width: 100%;\n }\n\n.datepicker .datepicker-scroll {\n list-style-type: none;\n padding: 0\n }\n\n.datepicker .datepicker-scroll>li {\n height: 40px;\n line-height: 40px;\n font-size: 1.375em;\n cursor: pointer;\n}\n\n.datepicker {\n\n /* default */\n}\n\n.datepicker.default {\n background-color: #f7f7f7;\n}\n\n.datepicker.default .datepicker-header {\n color: #4eccc4;\n}\n\n.datepicker.default .datepicker-wheel {\n border-top: 1px solid #4eccc4;\n border-bottom: 1px solid #4eccc4;\n}\n\n.datepicker.default .datepicker-scroll li {\n color: rgb(59, 59, 59);\n }\n\n.datepicker.default .datepicker-scroll li.disabled {\n color: rgb(191, 191, 191);\n }\n\n.datepicker.default .datepicker-navbar-btn {\n color: #4eccc4;\n}\n\n.datepicker {\n\n /* dark */\n}\n\n.datepicker.dark {\n background-color: #263238;\n}\n\n.datepicker.dark .datepicker-header {\n color: #50ccc4;\n}\n\n.datepicker.dark .datepicker-wheel {\n border-top: 1px solid #50ccc4;\n border-bottom: 1px solid #50ccc4;\n}\n\n.datepicker.dark .datepicker-scroll li {\n color: rgb(201, 203, 204);\n }\n\n.datepicker.dark .datepicker-scroll li.disabled {\n color: rgb(87, 96, 100);\n }\n\n.datepicker.dark .datepicker-navbar-btn {\n color: #50ccc4;\n}\n\n.datepicker {\n\n /* ios */\n}\n\n.datepicker.ios {\n background-color: #f7f7f7;\n}\n\n.datepicker.ios .datepicker-col-1 {margin: 0;\n}\n\n.datepicker.ios .datepicker-header {\n color: rgb(59, 59, 59);\n padding: 0 3.5em;\n}\n\n.datepicker.ios .datepicker-viewport::after {\n background: -webkit-gradient(linear,left top, left bottom,from(#f7f7f7),color-stop(52%, rgba(245, 245, 245, 0)),color-stop(48%, rgba(245, 245, 245, 0)),to(#f7f7f7));\n background: linear-gradient(#f7f7f7,rgba(245, 245, 245, 0)52%,rgba(245, 245, 245, 0)48%,#f7f7f7);\n}\n\n.datepicker.ios .datepicker-wheel {\n border-top: 1px solid #dbdbdb;\n border-bottom: 1px solid #dbdbdb;\n}\n\n.datepicker.ios .datepicker-scroll li {\n color: rgb(59, 59, 59);\n }\n\n.datepicker.ios .datepicker-scroll li.disabled {\n color: rgb(191, 191, 191);\n }\n\n.datepicker.ios .datepicker-navbar {\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 100%;\n padding: 0;\n border-bottom: 1px solid #acacac;\n}\n\n.datepicker.ios .datepicker-navbar-btn {\n color: #007aff;\n}\n\n.datepicker.ios .datepicker-navbar-btn:nth-child(2) {\n float: left;\n}\n\n.datepicker.ios .datepicker-content {\n padding-top: 48px;\n}\n\n.datepicker.ios .datepicker-header + .datepicker-content {\n padding-top: 0;\n}\n\n.datepicker {\n\n /* android */\n}\n\n.datepicker.android, .datepicker.android-dark {\n background-color: #f5f5f5;\n}\n\n.datepicker.android .datepicker-header, .datepicker.android-dark .datepicker-header {\n color: #31b6e7;\n border-bottom: 2px solid #31b6e7;\n}\n\n.datepicker.android .datepicker-col-1, .datepicker.android-dark .datepicker-col-1 {margin: 0 .625em;\n}\n\n.datepicker.android .datepicker-viewport::after, .datepicker.android-dark .datepicker-viewport::after {\n background-image: -webkit-gradient(linear,left top, left bottom,from(#f5f5f5),color-stop(52%, rgba(245, 245, 245, 0)),color-stop(48%, rgba(245, 245, 245, 0)),to(#f5f5f5));\n background-image: linear-gradient(#f5f5f5,rgba(245, 245, 245, 0)52%,rgba(245, 245, 245, 0)48%,#f5f5f5);\n}\n\n.datepicker.android .datepicker-wheel, .datepicker.android-dark .datepicker-wheel {\n border-top: 2px solid #31b6e7;\n border-bottom: 2px solid #31b6e7;\n}\n\n.datepicker.android .datepicker-scroll li, .datepicker.android-dark .datepicker-scroll li {\n font-size: 1.125em;\n color: rgb(56, 56, 56);\n }\n\n.datepicker.android .datepicker-scroll li.disabled, .datepicker.android-dark .datepicker-scroll li.disabled {\n color: rgb(188, 188, 188);\n }\n\n.datepicker.android .datepicker-navbar, .datepicker.android-dark .datepicker-navbar {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n border-top: 1px solid #d9d4d4;\n padding: 0;\n}\n\n.datepicker.android .datepicker-navbar-btn, .datepicker.android-dark .datepicker-navbar-btn {\n padding: 0;\n color: #000;\n -webkit-box-flex: 1;\n -ms-flex: 1;\n flex: 1;\n}\n\n.datepicker.android .datepicker-navbar-btn:nth-child(2), .datepicker.android-dark .datepicker-navbar-btn:nth-child(2) {\n border-left: 1px solid #d9d4d4;\n}\n\n.datepicker {\n\n /* android-dark */\n}\n\n.datepicker.android-dark {\n background-color: #292829;\n}\n\n.datepicker.android-dark .datepicker-viewport::after {\n background-image: -webkit-gradient(linear,left top, left bottom,from(#282828),color-stop(52%, rgba(40, 40, 40, 0)),color-stop(48%, rgba(40, 40, 40, 0)),to(#282828));\n background-image: linear-gradient(#282828,rgba(40, 40, 40, 0)52%,rgba(40, 40, 40, 0)48%,#282828);\n}\n\n.datepicker.android-dark .datepicker-scroll li {\n color: rgb(199, 199, 199);\n }\n\n.datepicker.android-dark .datepicker-scroll li.disabled {\n color: rgb(88, 88, 88);\n }\n\n.datepicker.android-dark .datepicker-navbar { border-color: #424542;\n}\n\n.datepicker.android-dark .datepicker-navbar-btn {\n color: #fff;\n}\n\n.datepicker.android-dark .datepicker-navbar-btn:nth-child(2) {\n border-color: #424542;\n}\n",{});var i=Object.freeze({convertDate:m,nextYear:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getFullYear()+t,e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())},nextMonth:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;o(e);var n=e.getFullYear(),r=e.getMonth()+t,a=Math.min(e.getDate(),new Date(n,r+1,0).getDate());return new Date(n,r,a,e.getHours(),e.getMinutes(),e.getSeconds())},nextDate:r,nextHour:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+60*t*60*1e3)},nextMinute:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+60*t*1e3)},nextSecond:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return o(e),new Date(e.getTime()+1e3*t)}});function a(t,n){if(t===n)return!0;var e=Object.keys(t),r=Object.keys(n);return e.length===r.length&&e.every(function(e){return t.hasOwnProperty(e)&&t[e]===n[e]})}function d(e){e.prototype.shouldComponentUpdate=function(e,t){return d.shouldComponentUpdate(e,t,this.props,this.state)}}function c(e){var t=["-webkit-","-moz-","-ms-"],n={},r=/transform|transition/;for(var a in e)if(e.hasOwnProperty(a)){var o=e[a];if(r.test(a))for(var i=0;i<t.length;i++){n[(t[i]+a).replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}).replace("-","")]=o.replace(r,t[i]+"$&")}n[a]=o}return n}function s(e,t){var n=c(t);for(var r in n)n.hasOwnProperty(r)&&(e.style[r]=n[r])}d.shouldComponentUpdate=function(e,t,n,r){return!a(n,e)||!a(r,t)};!function(){function s(e){this.value=e}function e(a){var o,i;function d(e,t){try{var n=a[e](t),r=n.value;r instanceof s?Promise.resolve(r.value).then(function(e){d("next",e)},function(e){d("throw",e)}):c(n.done?"return":"normal",n.value)}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?d(o.key,o.arg):i=null}this._invoke=function(r,a){return new Promise(function(e,t){var n={key:r,arg:a,resolve:e,reject:t,next:null};i?i=i.next=n:(o=i=n,d(r,a))})},"function"!=typeof a.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(e){return this._invoke("next",e)},e.prototype.throw=function(e){return this._invoke("throw",e)},e.prototype.return=function(e){return this._invoke("return",e)}}();var l=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},p=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},k=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},v=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},b=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},g=40,y=Math.floor(5),x=-g*y,w=function(e){return void 0===e},T=function(e){return"[object Array]"===Object.prototype.toString.apply(e)},C=function(e){return"[object Function]"===Object.prototype.toString.apply(e)},D=function(e){var t={Y:"Year",M:"Month",D:"Date",h:"Hour",m:"Minute",s:"Second"};for(var n in t)if(t.hasOwnProperty(n)&&~e.indexOf(n))return t[n];throw new Error("时间格式必须包含 Y, M, D, h, m 或 s字母")},E=function(e){function n(e){l(this,n);var t=v(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.animating=!1,t.touchY=0,t.translateY=0,t.currentIndex=y,t.moveDateCount=0,t.state={translateY:x,marginTop:(t.currentIndex-y)*g},T(e.format)?(t.typeName=D(e.format[0]),t.format=e.format[0],C(e.format[1])&&(t.formatTransform=e.format[1])):(t.format=e.format,t.typeName=D(e.format)),t.renderDatepickerItem=t.renderDatepickerItem.bind(t),t.handleContentTouch=t.handleContentTouch.bind(t),t.handleContentMouseDown=t.handleContentMouseDown.bind(t),t.handleContentMouseMove=t.handleContentMouseMove.bind(t),t.handleContentMouseUp=t.handleContentMouseUp.bind(t),t}return h(n,e),p(n,[{key:"componentWillMount",value:function(){this._iniDates(this.props.value)}},{key:"componentDidMount",value:function(){var e=this.viewport;e.addEventListener("touchstart",this.handleContentTouch,!1),e.addEventListener("touchmove",this.handleContentTouch,!1),e.addEventListener("touchend",this.handleContentTouch,!1),e.addEventListener("mousedown",this.handleContentMouseDown,!1)}},{key:"componentWillReceiveProps",value:function(e){e.value.getTime()!==this.props.value.getTime()&&(this._iniDates(e.value),this.currentIndex=y,this.setState({translateY:x,marginTop:(this.currentIndex-y)*g}))}},{key:"shouldComponentUpdate",value:function(e,t){return e.value.getTime()!==this.props.value.getTime()||!a(t,this.state)}},{key:"componentWillUnmount",value:function(){var e=this.viewport;e.removeEventListener("touchstart",this.handleContentTouch,!1),e.removeEventListener("touchmove",this.handleContentTouch,!1),e.removeEventListener("touchend",this.handleContentTouch,!1),e.removeEventListener("mousedown",this.handleContentMouseDown,!1)}},{key:"_iniDates",value:function(n){var r=this,a=this.typeName,e=Array.apply(void 0,b(Array(10))).map(function(e,t){return i["next"+a](n,(t-y)*r.props.step)});this.setState({dates:e})}},{key:"_updateDates",value:function(e){var t=this.typeName,n=this.state.dates;1===e?(this.currentIndex++,this.setState({dates:[].concat(b(n.slice(1)),[i["next"+t](n[n.length-1],this.props.step)]),marginTop:(this.currentIndex-y)*g})):(this.currentIndex--,this.setState({dates:[i["next"+t](n[0],-this.props.step)].concat(b(n.slice(0,n.length-1))),marginTop:(this.currentIndex-y)*g}))}},{key:"_checkIsUpdateDates",value:function(e,t){return 1===e?this.currentIndex*g+g/2<-t:this.currentIndex*g-g/2>-t}},{key:"_clearTransition",value:function(e){s(e,{transition:""})}},{key:"_moveToNext",value:function(e){var t=this.state.dates[y],n=this.props,r=n.max,a=n.min;-1===e&&t.getTime()<a.getTime()&&this.moveDateCount?this._updateDates(1):1===e&&t.getTime()>r.getTime()&&this.moveDateCount&&this._updateDates(-1),this._moveTo(this.refs.scroll,this.currentIndex)}},{key:"_moveTo",value:function(e,t){var n=this;this.animating=!0,s(e,{transition:"transform .2s ease-out"}),this.setState({translateY:-t*g}),setTimeout(function(){n.animating=!1,n.props.onSelect(n.state.dates[y]),n._clearTransition(n.refs.scroll)},200)}},{key:"handleStart",value:function(e){this.touchY=w(e.targetTouches)||w(e.targetTouches[0])?e.pageY:e.targetTouches[0].pageY,this.translateY=this.state.translateY,this.moveDateCount=0}},{key:"handleMove",value:function(e){var t=(w(e.targetTouches)||w(e.targetTouches[0])?e.pageY:e.targetTouches[0].pageY)-this.touchY,n=this.translateY+t,r=0<t?-1:1,a=this.state.dates[y],o=this.props,i=o.max,d=o.min;a.getTime()<d.getTime()||a.getTime()>i.getTime()||(this._checkIsUpdateDates(r,n)&&(this.moveDateCount=0<r?this.moveDateCount+1:this.moveDateCount-1,this._updateDates(r)),this.setState({translateY:n}))}},{key:"handleEnd",value:function(e){var t=0<(e.pageY||e.changedTouches[0].pageY)-this.touchY?-1:1;this._moveToNext(t)}},{key:"handleContentTouch",value:function(e){e.preventDefault(),this.animating||("touchstart"===e.type?this.handleStart(e):"touchmove"===e.type?this.handleMove(e):"touchend"===e.type&&this.handleEnd(e))}},{key:"handleContentMouseDown",value:function(e){this.animating||(this.handleStart(e),document.addEventListener("mousemove",this.handleContentMouseMove),document.addEventListener("mouseup",this.handleContentMouseUp))}},{key:"handleContentMouseMove",value:function(e){this.animating||this.handleMove(e)}},{key:"handleContentMouseUp",value:function(e){this.animating||(this.handleEnd(e),document.removeEventListener("mousemove",this.handleContentMouseMove),document.removeEventListener("mouseup",this.handleContentMouseUp))}},{key:"renderDatepickerItem",value:function(e,t){var n=e<this.props.min||e>this.props.max?"disabled":"",r=m(e,this.format);return this.formatTransform&&(r=this.formatTransform(r)),f.createElement("li",{key:t,className:n},r)}},{key:"render",value:function(){var t=this,e=c({transform:"translateY("+this.state.translateY+"px)",marginTop:this.state.marginTop});return f.createElement("div",{className:"datepicker-col-1"},f.createElement("div",{ref:function(e){return t.viewport=e},className:"datepicker-viewport"},f.createElement("div",{className:"datepicker-wheel"},f.createElement("ul",{ref:"scroll",className:"datepicker-scroll",style:e},this.state.dates.map(this.renderDatepickerItem)))))}}]),n}(e.Component),M=function(e){function n(e){l(this,n);var t=v(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state={value:r(t.props.value)},t.handleFinishBtnClick=t.handleFinishBtnClick.bind(t),t.handleDateSelect=t.handleDateSelect.bind(t),t}return h(n,e),p(n,[{key:"componentWillReceiveProps",value:function(e){var t=r(e.value);t.getTime()!==this.state.value.getTime()&&this.setState({value:t})}},{key:"shouldComponentUpdate",value:function(e,t){return r(t.value).getTime()!==this.state.value.getTime()||d.shouldComponentUpdate(e,t,this.props,this.state)}},{key:"handleFinishBtnClick",value:function(){this.props.onSelect(this.state.value)}},{key:"handleDateSelect",value:function(e){this.setState({value:e})}},{key:"render",value:function(){var n=this,e=this.props,r=e.min,a=e.max,t=e.theme,o=e.dateFormat,i=e.confirmText,d=e.cancelText,c=e.showFormat,s=e.showHeader,l=e.customHeader,p=e.dateSteps,u=this.state.value,h=-1===["default","dark","ios","android","android-dark"].indexOf(t)?"default":t;return f.createElement("div",{className:"datepicker "+h},s&&f.createElement("div",{className:"datepicker-header"},l||m(u,c)),f.createElement("div",{className:"datepicker-content"},o.map(function(e,t){return f.createElement(E,{key:t,step:p[t]||1,value:u,min:r,max:a,format:e,onSelect:n.handleDateSelect})})),f.createElement("div",{className:"datepicker-navbar"},f.createElement("a",{className:"datepicker-navbar-btn",onClick:this.handleFinishBtnClick},i),f.createElement("a",{className:"datepicker-navbar-btn",onClick:this.props.onCancel},d)))}}]),n}(e.Component),_=n.unstable_renderSubtreeIntoContainer,S=function(e){function t(){return l(this,t),v(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return h(t,e),p(t,[{key:"componentDidMount",value:function(){this._div=document.createElement("div"),this._div.classList.add("Modal-Portal"),document.body.appendChild(this._div),this.renderPortal(this.props)}},{key:"componentWillReceiveProps",value:function(e){this.renderPortal(e)}},{key:"componentWillUnmount",value:function(){n.unmountComponentAtNode(this._div),this._div.parentNode.removeChild(this._div)}},{key:"renderPortal",value:function(e){var t=f.cloneElement(this.props.children,u({},e,{key:"portal"}),null);this.portal=_(this,t,this._div)}},{key:"render",value:function(){return f.createElement("noscript",null)}}]),t}(e.Component);function O(e){var t=e.isOpen,n=k(e,["isOpen"]);return f.createElement("div",{style:{display:t?"":"none"},onClick:function(e){e.target===e.currentTarget&&n.onCancel()},className:"datepicker-modal"},f.createElement(M,n))}function t(e){var t=e.isPopup,n=k(e,["isPopup"]);return t?f.createElement(S,n,f.createElement(O,null)):f.createElement(M,n)}return S.defaultProps={isOpen:!1},t.defaultProps={isPopup:!0,isOpen:!1,theme:"default",value:new Date,min:new Date(1970,0,1),max:new Date(2050,0,1),showHeader:!0,dateFormat:["YYYY","M","D"],dateSteps:[1,1,1],showFormat:"YYYY/MM/DD",confirmText:"完成",cancelText:"取消",onSelect:function(){},onCancel:function(){}},t}); | ||
//# sourceMappingURL=dist/react-mobile-datepicker.min.js.map |
@@ -16,2 +16,4 @@ | ||
const isUndefined = val => typeof val === 'undefined'; | ||
const isArray = val => Object.prototype.toString.apply(val) === '[object Array]'; | ||
const isFunction = val => Object.prototype.toString.apply(val) === '[object Function]'; | ||
@@ -48,3 +50,3 @@ /** | ||
max: Object, | ||
format: string, | ||
format: string | Array<*>, | ||
step: number, | ||
@@ -78,3 +80,15 @@ onSelect: Function, | ||
// 设置时间选择器单元的类别 | ||
this.typeName = getTimeType(props.format); | ||
if (isArray(props.format)) { | ||
this.typeName = getTimeType(props.format[0]); | ||
this.format = props.format[0]; | ||
if (isFunction(props.format[1])) { | ||
this.formatTransform = props.format[1]; | ||
} | ||
} | ||
else { | ||
this.format = props.format; | ||
this.typeName = getTimeType(props.format); | ||
} | ||
this.renderDatepickerItem = this.renderDatepickerItem.bind(this); | ||
@@ -317,2 +331,7 @@ this.handleContentTouch = this.handleContentTouch.bind(this); | ||
let formatDate = TimeUtil.convertDate(date, this.format); | ||
if (this.formatTransform) { | ||
formatDate = this.formatTransform(formatDate); | ||
} | ||
return ( | ||
@@ -322,3 +341,3 @@ <li | ||
className={className}> | ||
{TimeUtil.convertDate(date, this.props.format)} | ||
{formatDate} | ||
</li> | ||
@@ -325,0 +344,0 @@ ); |
{ | ||
"name": "react-mobile-datepicker", | ||
"version": "3.0.10", | ||
"version": "3.0.11", | ||
"description": "一个移动端时间选择器react组件", | ||
@@ -5,0 +5,0 @@ "main": "./dist/react-mobile-datepicker.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
564473
2166