feat: update vc-calendar to 9.10.10

pull/666/head
wangxueliang 2019-03-02 11:12:36 +08:00
parent 2d2bd79f82
commit 015fca4e1b
5 changed files with 28 additions and 11 deletions

View File

@ -1,4 +1,4 @@
// based on rc-calendar 9.10.8 // based on rc-calendar 9.10.10
import Vue from 'vue'; import Vue from 'vue';
import ref from 'vue-ref'; import ref from 'vue-ref';
import Calendar from './src/'; import Calendar from './src/';

View File

@ -58,7 +58,7 @@ function generateOptions(length, extraOptionGen) {
return arr; return arr;
} }
function onInputSelect(direction, value) { function onInputSelect(direction, value, cause) {
if (!value) { if (!value) {
return; return;
} }
@ -70,7 +70,7 @@ function onInputSelect(direction, value) {
selectedValue[1 - index] = this.showTimePicker ? selectedValue[index] : undefined; selectedValue[1 - index] = this.showTimePicker ? selectedValue[index] : undefined;
} }
this.__emit('inputSelect', selectedValue); this.__emit('inputSelect', selectedValue);
this.fireSelectValueChange(selectedValue); this.fireSelectValueChange(selectedValue, null, cause || { source: 'dateInput' });
} }
const RangeCalendar = { const RangeCalendar = {
@ -369,16 +369,26 @@ const RangeCalendar = {
} }
}, },
onStartInputSelect(...oargs) { onStartInputChange(...oargs) {
const args = ['left'].concat(oargs); const args = ['left'].concat(oargs);
return onInputSelect.apply(this, args); return onInputSelect.apply(this, args);
}, },
onEndInputSelect(...oargs) { onEndInputChange(...oargs) {
const args = ['right'].concat(oargs); const args = ['right'].concat(oargs);
return onInputSelect.apply(this, args); 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) { onStartValueChange(leftValue) {
const value = [...this.sValue]; const value = [...this.sValue];
value[0] = leftValue; value[0] = leftValue;
@ -502,7 +512,7 @@ const RangeCalendar = {
return v1.diff(v2, 'days'); return v1.diff(v2, 'days');
}, },
fireSelectValueChange(selectedValue, direct) { fireSelectValueChange(selectedValue, direct, cause) {
const { timePicker, prevSelectedValue } = this; const { timePicker, prevSelectedValue } = this;
if (timePicker) { if (timePicker) {
const timePickerProps = getOptionProps(timePicker); const timePickerProps = getOptionProps(timePicker);
@ -540,7 +550,7 @@ const RangeCalendar = {
firstSelectedValue: null, firstSelectedValue: null,
}); });
this.fireHoverValueChange([]); this.fireHoverValueChange([]);
this.__emit('select', selectedValue); this.__emit('select', selectedValue, cause);
} }
if (!hasProp(this, 'selectedValue')) { if (!hasProp(this, 'selectedValue')) {
this.setState({ this.setState({
@ -677,6 +687,7 @@ const RangeCalendar = {
clearIcon, clearIcon,
}, },
on: { on: {
inputChange: this.onStartInputChange,
inputSelect: this.onStartInputSelect, inputSelect: this.onStartInputSelect,
valueChange: this.onStartValueChange, valueChange: this.onStartValueChange,
panelChange: this.onStartPanelChange, panelChange: this.onStartPanelChange,
@ -701,6 +712,7 @@ const RangeCalendar = {
clearIcon, clearIcon,
}, },
on: { on: {
inputChange: this.onEndInputChange,
inputSelect: this.onEndInputSelect, inputSelect: this.onEndInputSelect,
valueChange: this.onEndValueChange, valueChange: this.onEndValueChange,
panelChange: this.onEndPanelChange, panelChange: this.onEndPanelChange,

View File

@ -138,9 +138,12 @@ const DateInput = {
})); }));
}, },
onKeyDown({ keyCode }) { onKeyDown({ keyCode }) {
const { value } = this.$props; const { value, disabledDate } = this.$props;
if (keyCode === KeyCode.ENTER) { if (keyCode === KeyCode.ENTER) {
this.__emit('select', value.clone()); const validateDate = !disabledDate || !disabledDate(value);
if(validateDate) {
this.__emit('select', value.clone());
}
} }
}, },
getRootDOMNode() { getRootDOMNode() {

View File

@ -59,6 +59,7 @@ const CalendarPart = {
} = props; } = props;
const clearIcon = getComponentFromProp(this, 'clearIcon'); const clearIcon = getComponentFromProp(this, 'clearIcon');
const { const {
inputChange = noop,
inputSelect = noop, inputSelect = noop,
valueChange = noop, valueChange = noop,
panelChange = noop, panelChange = noop,
@ -91,7 +92,7 @@ const CalendarPart = {
value: selectedValue[index], value: selectedValue[index],
}, },
on: { on: {
change: inputSelect, change: inputChange,
}, },
}); });
} }
@ -109,6 +110,8 @@ const CalendarPart = {
showClear={false} showClear={false}
selectedValue={selectedValue[index]} selectedValue={selectedValue[index]}
onChange={inputSelect} onChange={inputSelect}
onChange={inputChange}
onSelect={inputSelect}
clearIcon={clearIcon} clearIcon={clearIcon}
/> />
); );

View File

@ -1,4 +1,3 @@
// based on rc-upload 2.4.4
// export this package's api // export this package's api
import Upload from './Upload'; import Upload from './Upload';