diff --git a/components/_util/BaseMixin.js b/components/_util/BaseMixin.js index d1e94aeda..629368e99 100644 --- a/components/_util/BaseMixin.js +++ b/components/_util/BaseMixin.js @@ -1,23 +1,20 @@ +import { getOptionProps } from './props-util'; + export default { - // directives: { - // ref: { - // bind: function (el, binding, vnode) { - // binding.value(vnode.componentInstance ? vnode.componentInstance : vnode.elm) - // }, - // update: function (el, binding, vnode) { - // binding.value(vnode.componentInstance ? vnode.componentInstance : vnode.elm) - // }, - // unbind: function (el, binding, vnode) { - // binding.value(null) - // }, - // }, - // }, methods: { - setState(state, callback) { - const newState = typeof state === 'function' ? state(this.$data, this.$props) : state; - // if (this.getDerivedStateFromProps) { - // Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), { ...this.$data, ...newState }, true) || {}) - // } + setState(state = {}, callback) { + let newState = typeof state === 'function' ? state(this.$data, this.$props) : state; + if (this.getDerivedStateFromProps) { + const s = this.getDerivedStateFromProps(getOptionProps(this), { + ...this.$data, + ...newState, + }); + if (s === null) { + return; + } else { + newState = { ...newState, ...(s || {}) }; + } + } Object.assign(this.$data, newState); this.$forceUpdate(); this.$nextTick(() => { diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 3e1fb9f80..6c532beec 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -8013,43 +8013,43 @@ exports[`Locale Provider should display the text as hr 1`] = `
do | -2ª | -3ª | -4ª | -5ª | -6ª | -sá | +Do | +2ª | +3ª | +4ª | +5ª | +6ª | +Sá | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ |
27
|
- + |
28
|
- + |
29
|
- + |
30
|
- + |
31
|
- + |
01
|
- + |
02
@@ -16717,43 +16717,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|
+ |
03
|
- + |
04
|
- + |
05
|
- + |
06
|
- + |
07
|
- + |
08
|
- + |
09
@@ -16761,43 +16761,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|
+ |
10
|
- + |
11
|
- + |
12
|
- + |
13
|
- + |
14
|
- + |
15
|
- + |
16
@@ -16805,43 +16805,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|
+ |
17
|
- + |
18
|
- + |
19
|
- + |
20
|
- + |
21
|
- + |
22
|
- + |
23
@@ -16849,43 +16849,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|
+ |
24
|
- + |
25
|
- + |
26
|
- + |
27
|
- + |
28
|
- + |
29
|
- + |
30
@@ -16893,43 +16893,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|
+ |
01
|
- + |
02
|
- + |
03
|
- + |
04
|
- + |
05
|
- + |
06
|
- + |
07
diff --git a/components/vc-calendar/index.js b/components/vc-calendar/index.js
index 685b89bba..d00e1f038 100644
--- a/components/vc-calendar/index.js
+++ b/components/vc-calendar/index.js
@@ -1,4 +1,4 @@
-// based on rc-calendar 9.15.8
+// based on rc-calendar 9.15.10
import Vue from 'vue';
import ref from 'vue-ref';
import Calendar from './src/';
diff --git a/components/vc-calendar/src/Calendar.jsx b/components/vc-calendar/src/Calendar.jsx
index 06a06cfce..c3d6b7a9e 100644
--- a/components/vc-calendar/src/Calendar.jsx
+++ b/components/vc-calendar/src/Calendar.jsx
@@ -22,6 +22,7 @@ const getMomentObjectIfValid = date => {
};
const Calendar = {
+ name: 'Calendar',
props: {
locale: PropTypes.object.def(enUs),
format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
@@ -358,6 +359,7 @@ const Calendar = {
showDateInput={props.showDateInput}
timePicker={timePicker}
selectedValue={sSelectedValue}
+ timePickerDisabled={!sSelectedValue}
value={sValue}
disabledDate={disabledDate}
okDisabled={
diff --git a/components/vc-calendar/src/FullCalendar.jsx b/components/vc-calendar/src/FullCalendar.jsx
index a1e04649d..279389401 100644
--- a/components/vc-calendar/src/FullCalendar.jsx
+++ b/components/vc-calendar/src/FullCalendar.jsx
@@ -9,6 +9,7 @@ import CommonMixin from './mixin/CommonMixin';
import CalendarHeader from './full-calendar/CalendarHeader';
import enUs from './locale/en_US';
const FullCalendar = {
+ name: 'FullCalendar',
props: {
locale: PropTypes.object.def(enUs),
format: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
diff --git a/components/vc-calendar/src/MonthCalendar.jsx b/components/vc-calendar/src/MonthCalendar.jsx
index f0a219614..43acc7415 100644
--- a/components/vc-calendar/src/MonthCalendar.jsx
+++ b/components/vc-calendar/src/MonthCalendar.jsx
@@ -8,6 +8,7 @@ import CalendarMixin from './mixin/CalendarMixin';
import CommonMixin from './mixin/CommonMixin';
import enUs from './locale/en_US';
const MonthCalendar = {
+ name: 'MonthCalendar',
props: {
locale: PropTypes.object.def(enUs),
format: PropTypes.string,
diff --git a/components/vc-calendar/src/date/DateInput.jsx b/components/vc-calendar/src/date/DateInput.jsx
index 21abf5770..70e553b3e 100644
--- a/components/vc-calendar/src/date/DateInput.jsx
+++ b/components/vc-calendar/src/date/DateInput.jsx
@@ -39,10 +39,10 @@ const DateInput = {
},
watch: {
selectedValue() {
- this.updateState();
+ this.setState();
},
format() {
- this.updateState();
+ this.setState();
},
},
@@ -62,19 +62,21 @@ const DateInput = {
return dateInputInstance;
},
methods: {
- updateState() {
+ getDerivedStateFromProps(nextProps, state) {
+ let newState = {};
if (dateInputInstance) {
cachedSelectionStart = dateInputInstance.selectionStart;
cachedSelectionEnd = dateInputInstance.selectionEnd;
}
// when popup show, click body will call this, bug!
- const selectedValue = this.selectedValue;
- if (!this.$data.hasFocus) {
- this.setState({
+ const selectedValue = nextProps.selectedValue;
+ if (!state.hasFocus) {
+ newState = {
str: formatDate(selectedValue, this.format),
invalid: false,
- });
+ };
}
+ return newState;
},
onClear() {
this.setState({
diff --git a/components/vc-calendar/src/full-calendar/CalendarHeader.jsx b/components/vc-calendar/src/full-calendar/CalendarHeader.jsx
index 55f6401c0..a4b9c8159 100644
--- a/components/vc-calendar/src/full-calendar/CalendarHeader.jsx
+++ b/components/vc-calendar/src/full-calendar/CalendarHeader.jsx
@@ -3,6 +3,7 @@ import BaseMixin from '../../../_util/BaseMixin';
import { getMonthName } from '../util';
const CalendarHeader = {
+ name: 'CalendarHeader',
mixins: [BaseMixin],
props: {
value: PropTypes.object,
diff --git a/components/vc-calendar/src/month/MonthTable.jsx b/components/vc-calendar/src/month/MonthTable.jsx
index 605a66a8a..ca1b943a8 100644
--- a/components/vc-calendar/src/month/MonthTable.jsx
+++ b/components/vc-calendar/src/month/MonthTable.jsx
@@ -5,15 +5,10 @@ import { getTodayTime, getMonthName } from '../util/index';
const ROW = 4;
const COL = 3;
-function chooseMonth(month) {
- const next = this.sValue.clone();
- next.month(month);
- this.setAndSelectValue(next);
-}
-
function noop() {}
const MonthTable = {
+ name: 'MonthTable',
mixins: [BaseMixin],
props: {
cellRender: PropTypes.func,
@@ -42,7 +37,11 @@ const MonthTable = {
});
this.__emit('select', value);
},
-
+ chooseMonth(month) {
+ const next = this.sValue.clone();
+ next.month(month);
+ this.setAndSelectValue(next);
+ },
months() {
const value = this.sValue;
const current = value.clone();
@@ -107,7 +106,7 @@ const MonthTable = {
this.chooseMonth(monthData.value)}
title={monthData.title}
class={classNameMap}
>
| |