@@ -14,6 +14,13 @@ import enUs from './locale/en_US';
1414import { getTimeConfig , getTodayTime , syncTime } from './util' ;
1515import { goStartMonth , goEndMonth , goTime } from './util/toTime' ;
1616
17+ const getMomentObjectIfValid = date => {
18+ if ( moment . isMoment ( date ) && date . isValid ( ) ) {
19+ return date ;
20+ }
21+ return false ;
22+ } ;
23+
1724const Calendar = {
1825 props : {
1926 locale : PropTypes . object . def ( enUs ) ,
@@ -46,6 +53,7 @@ const Calendar = {
4653 renderSidebar : PropTypes . func . def ( ( ) => null ) ,
4754 clearIcon : PropTypes . any ,
4855 focusablePanel : PropTypes . bool . def ( true ) ,
56+ inputMode : PropTypes . string ,
4957 } ,
5058
5159 mixins : [ BaseMixin , CommonMixin , CalendarMixin ] ,
@@ -54,7 +62,10 @@ const Calendar = {
5462 const props = this . $props ;
5563 return {
5664 sMode : this . mode || 'date' ,
57- sValue : props . value || props . defaultValue || moment ( ) ,
65+ sValue :
66+ getMomentObjectIfValid ( props . value ) ||
67+ getMomentObjectIfValid ( props . defaultValue ) ||
68+ moment ( ) ,
5869 sSelectedValue : props . selectedValue || props . defaultSelectedValue ,
5970 } ;
6071 } ,
@@ -63,9 +74,11 @@ const Calendar = {
6374 this . setState ( { sMode : val } ) ;
6475 } ,
6576 value ( val ) {
66- const sValue = val || this . defaultValue || getNowByCurrentStateValue ( this . sValue ) ;
6777 this . setState ( {
68- sValue,
78+ sValue :
79+ getMomentObjectIfValid ( val ) ||
80+ getMomentObjectIfValid ( this . defaultValue ) ||
81+ getNowByCurrentStateValue ( this . sValue ) ,
6982 } ) ;
7083 } ,
7184 selectedValue ( val ) {
@@ -190,6 +203,25 @@ const Calendar = {
190203 source : 'todayButton' ,
191204 } ) ;
192205 } ,
206+
207+ onBlur ( event ) {
208+ setTimeout ( ( ) => {
209+ const dateInput = DateInput . getInstance ( ) ;
210+ const rootInstance = this . rootInstance ;
211+
212+ if (
213+ ! rootInstance ||
214+ rootInstance . contains ( document . activeElement ) ||
215+ ( dateInput && dateInput . contains ( document . activeElement ) )
216+ ) {
217+ // focused element is still part of Calendar
218+ return ;
219+ }
220+
221+ this . $emit ( 'blur' , event ) ;
222+ } , 0 ) ;
223+ } ,
224+
193225 getRootDOMNode ( ) {
194226 return this . $el ;
195227 } ,
@@ -217,6 +249,9 @@ const Calendar = {
217249 sSelectedValue,
218250 sMode,
219251 renderFooter,
252+ inputMode,
253+ monthCellRender,
254+ monthCellContentRender,
220255 $props : props ,
221256 } = this ;
222257 const clearIcon = getComponentFromProp ( this , 'clearIcon' ) ;
@@ -267,6 +302,7 @@ const Calendar = {
267302 onChange = { this . onDateInputChange }
268303 clearIcon = { clearIcon }
269304 onSelect = { this . onDateInputSelect }
305+ inputMode = { inputMode }
270306 />
271307 ) : null ;
272308 const children = [ ] ;
@@ -286,6 +322,8 @@ const Calendar = {
286322 renderFooter = { renderFooter }
287323 showTimePicker = { showTimePicker }
288324 prefixCls = { prefixCls }
325+ monthCellRender = { monthCellRender }
326+ monthCellContentRender = { monthCellContentRender }
289327 />
290328 { timePicker && showTimePicker ? (
291329 < div class = { `${ prefixCls } -time-picker` } >
0 commit comments