rc-calendar
Advanced tools
Comparing version 9.8.1 to 9.8.2
@@ -296,3 +296,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
disabledDate: disabledDate, | ||
okDisabled: props.showOk && !this.isAllowedDate(selectedValue), | ||
okDisabled: props.showOk !== false && (!selectedValue || !this.isAllowedDate(selectedValue)), | ||
onOk: this.onOk, | ||
@@ -299,0 +299,0 @@ onSelect: this.onSelect, |
@@ -54,43 +54,46 @@ import React from 'react'; | ||
var str = event.target.value; | ||
this.setState({ | ||
str: str | ||
}); | ||
var value = void 0; | ||
var _props = this.props, | ||
disabledDate = _props.disabledDate, | ||
format = _props.format, | ||
onChange = _props.onChange; | ||
onChange = _props.onChange, | ||
selectedValue = _props.selectedValue; | ||
if (str) { | ||
var parsed = moment(str, format, true); | ||
if (!parsed.isValid()) { | ||
this.setState({ | ||
invalid: true | ||
}); | ||
return; | ||
} | ||
value = this.props.value.clone(); | ||
value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second()); | ||
// 没有内容,合法并直接退出 | ||
if (value && (!disabledDate || !disabledDate(value))) { | ||
var originalValue = this.props.selectedValue; | ||
if (originalValue && value) { | ||
if (!originalValue.isSame(value)) { | ||
onChange(value); | ||
} | ||
} else if (originalValue !== value) { | ||
onChange(value); | ||
} | ||
} else { | ||
this.setState({ | ||
invalid: true | ||
}); | ||
return; | ||
} | ||
} else { | ||
if (!str) { | ||
onChange(null); | ||
this.setState({ | ||
invalid: false, | ||
str: str | ||
}); | ||
return; | ||
} | ||
this.setState({ | ||
invalid: false | ||
}); | ||
// 不合法直接退出 | ||
var parsed = moment(str, format, true); | ||
if (!parsed.isValid()) { | ||
this.setState({ | ||
invalid: true, | ||
str: str | ||
}); | ||
return; | ||
} | ||
var value = this.props.value.clone(); | ||
value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second()); | ||
if (!value || disabledDate && disabledDate(value)) { | ||
this.setState({ | ||
invalid: true, | ||
str: str | ||
}); | ||
return; | ||
} | ||
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) { | ||
this.setState({ | ||
str: str | ||
}); | ||
onChange(value); | ||
} | ||
}, | ||
@@ -97,0 +100,0 @@ onClear: function onClear() { |
@@ -339,3 +339,3 @@ 'use strict'; | ||
disabledDate: disabledDate, | ||
okDisabled: props.showOk && !this.isAllowedDate(selectedValue), | ||
okDisabled: props.showOk !== false && (!selectedValue || !this.isAllowedDate(selectedValue)), | ||
onOk: this.onOk, | ||
@@ -342,0 +342,0 @@ onSelect: this.onSelect, |
@@ -75,43 +75,46 @@ 'use strict'; | ||
var str = event.target.value; | ||
this.setState({ | ||
str: str | ||
}); | ||
var value = void 0; | ||
var _props = this.props, | ||
disabledDate = _props.disabledDate, | ||
format = _props.format, | ||
onChange = _props.onChange; | ||
onChange = _props.onChange, | ||
selectedValue = _props.selectedValue; | ||
if (str) { | ||
var parsed = (0, _moment2['default'])(str, format, true); | ||
if (!parsed.isValid()) { | ||
this.setState({ | ||
invalid: true | ||
}); | ||
return; | ||
} | ||
value = this.props.value.clone(); | ||
value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second()); | ||
// 没有内容,合法并直接退出 | ||
if (value && (!disabledDate || !disabledDate(value))) { | ||
var originalValue = this.props.selectedValue; | ||
if (originalValue && value) { | ||
if (!originalValue.isSame(value)) { | ||
onChange(value); | ||
} | ||
} else if (originalValue !== value) { | ||
onChange(value); | ||
} | ||
} else { | ||
this.setState({ | ||
invalid: true | ||
}); | ||
return; | ||
} | ||
} else { | ||
if (!str) { | ||
onChange(null); | ||
this.setState({ | ||
invalid: false, | ||
str: str | ||
}); | ||
return; | ||
} | ||
this.setState({ | ||
invalid: false | ||
}); | ||
// 不合法直接退出 | ||
var parsed = (0, _moment2['default'])(str, format, true); | ||
if (!parsed.isValid()) { | ||
this.setState({ | ||
invalid: true, | ||
str: str | ||
}); | ||
return; | ||
} | ||
var value = this.props.value.clone(); | ||
value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second()); | ||
if (!value || disabledDate && disabledDate(value)) { | ||
this.setState({ | ||
invalid: true, | ||
str: str | ||
}); | ||
return; | ||
} | ||
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) { | ||
this.setState({ | ||
str: str | ||
}); | ||
onChange(value); | ||
} | ||
}, | ||
@@ -118,0 +121,0 @@ onClear: function onClear() { |
{ | ||
"name": "rc-calendar", | ||
"version": "9.8.1", | ||
"version": "9.8.2", | ||
"description": "React Calendar", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1491241
22741