diff --git a/components/vc-calendar/index.js b/components/vc-calendar/index.js index 24744582f..a81bab944 100644 --- a/components/vc-calendar/index.js +++ b/components/vc-calendar/index.js @@ -1,4 +1,4 @@ -// based on rc-calendar 9.10.8 +// based on rc-calendar 9.10.10 import Vue from 'vue'; import ref from 'vue-ref'; import Calendar from './src/'; diff --git a/components/vc-calendar/src/RangeCalendar.jsx b/components/vc-calendar/src/RangeCalendar.jsx index ec1d00b69..97d0974bd 100644 --- a/components/vc-calendar/src/RangeCalendar.jsx +++ b/components/vc-calendar/src/RangeCalendar.jsx @@ -58,7 +58,7 @@ function generateOptions(length, extraOptionGen) { return arr; } -function onInputSelect(direction, value) { +function onInputSelect(direction, value, cause) { if (!value) { return; } @@ -70,7 +70,7 @@ function onInputSelect(direction, value) { selectedValue[1 - index] = this.showTimePicker ? selectedValue[index] : undefined; } this.__emit('inputSelect', selectedValue); - this.fireSelectValueChange(selectedValue); + this.fireSelectValueChange(selectedValue, null, cause || { source: 'dateInput' }); } const RangeCalendar = { @@ -369,16 +369,26 @@ const RangeCalendar = { } }, - onStartInputSelect(...oargs) { + onStartInputChange(...oargs) { const args = ['left'].concat(oargs); return onInputSelect.apply(this, args); }, - onEndInputSelect(...oargs) { + onEndInputChange(...oargs) { const args = ['right'].concat(oargs); return onInputSelect.apply(this, args); }, + onStartInputSelect(value) { + const args = ['left', value, { source: 'dateInputSelect' }]; + return onInputSelect.apply(this, args); + }, + + onEndInputSelect(value) { + const args = ['right', value, { source: 'dateInputSelect' }]; + return onInputSelect.apply(this, args); + }, + onStartValueChange(leftValue) { const value = [...this.sValue]; value[0] = leftValue; @@ -502,7 +512,7 @@ const RangeCalendar = { return v1.diff(v2, 'days'); }, - fireSelectValueChange(selectedValue, direct) { + fireSelectValueChange(selectedValue, direct, cause) { const { timePicker, prevSelectedValue } = this; if (timePicker) { const timePickerProps = getOptionProps(timePicker); @@ -540,7 +550,7 @@ const RangeCalendar = { firstSelectedValue: null, }); this.fireHoverValueChange([]); - this.__emit('select', selectedValue); + this.__emit('select', selectedValue, cause); } if (!hasProp(this, 'selectedValue')) { this.setState({ @@ -677,6 +687,7 @@ const RangeCalendar = { clearIcon, }, on: { + inputChange: this.onStartInputChange, inputSelect: this.onStartInputSelect, valueChange: this.onStartValueChange, panelChange: this.onStartPanelChange, @@ -701,6 +712,7 @@ const RangeCalendar = { clearIcon, }, on: { + inputChange: this.onEndInputChange, inputSelect: this.onEndInputSelect, valueChange: this.onEndValueChange, panelChange: this.onEndPanelChange, diff --git a/components/vc-calendar/src/date/DateInput.jsx b/components/vc-calendar/src/date/DateInput.jsx index c146097ac..6cabb2c79 100644 --- a/components/vc-calendar/src/date/DateInput.jsx +++ b/components/vc-calendar/src/date/DateInput.jsx @@ -138,9 +138,12 @@ const DateInput = { })); }, onKeyDown({ keyCode }) { - const { value } = this.$props; + const { value, disabledDate } = this.$props; if (keyCode === KeyCode.ENTER) { - this.__emit('select', value.clone()); + const validateDate = !disabledDate || !disabledDate(value); + if(validateDate) { + this.__emit('select', value.clone()); + } } }, getRootDOMNode() { diff --git a/components/vc-calendar/src/range-calendar/CalendarPart.jsx b/components/vc-calendar/src/range-calendar/CalendarPart.jsx index b65a267ff..d4fa4d2fe 100644 --- a/components/vc-calendar/src/range-calendar/CalendarPart.jsx +++ b/components/vc-calendar/src/range-calendar/CalendarPart.jsx @@ -59,6 +59,7 @@ const CalendarPart = { } = props; const clearIcon = getComponentFromProp(this, 'clearIcon'); const { + inputChange = noop, inputSelect = noop, valueChange = noop, panelChange = noop, @@ -91,7 +92,7 @@ const CalendarPart = { value: selectedValue[index], }, on: { - change: inputSelect, + change: inputChange, }, }); } @@ -109,6 +110,8 @@ const CalendarPart = { showClear={false} selectedValue={selectedValue[index]} onChange={inputSelect} + onChange={inputChange} + onSelect={inputSelect} clearIcon={clearIcon} /> ); diff --git a/components/vc-upload/src/index.js b/components/vc-upload/src/index.js index db60d2324..1eeceb02e 100644 --- a/components/vc-upload/src/index.js +++ b/components/vc-upload/src/index.js @@ -1,4 +1,3 @@ -// based on rc-upload 2.4.4 // export this package's api import Upload from './Upload';