Skip to content

Commit 927a0a6

Browse files
committed
cr cxxx- exxx
1 parent c31aab0 commit 927a0a6

File tree

26 files changed

+149
-86
lines changed

26 files changed

+149
-86
lines changed

components/calendar/index.jsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,17 @@ const Calendar = {
159159
return inRange;
160160
};
161161
},
162-
162+
getDefaultLocale() {
163+
const result = {
164+
...enUS,
165+
...this.$props.locale,
166+
};
167+
result.lang = {
168+
...result.lang,
169+
...(this.$props.locale || {}).lang,
170+
};
171+
return result;
172+
},
163173
renderCalendar(locale, localeCode) {
164174
const props = getOptionProps(this);
165175
const { sValue: value, sMode: mode, $listeners, $scopedSlots } = this;
@@ -230,17 +240,6 @@ const Calendar = {
230240
</div>
231241
);
232242
},
233-
getDefaultLocale() {
234-
const result = {
235-
...enUS,
236-
...this.$props.locale,
237-
};
238-
result.lang = {
239-
...result.lang,
240-
...(this.$props.locale || {}).lang,
241-
};
242-
return result;
243-
},
244243
},
245244

246245
render() {

components/card/Grid.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: 'ACardGrid',
66
__ANT_CARD_GRID: true,
77
props: {
8-
prefixCls: PropTypes.string.def('ant-card'),
8+
prefixCls: PropTypes.string,
99
},
1010
inject: {
1111
configProvider: { default: () => ({}) },

components/card/Meta.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ConfigConsumerProps } from '../config-provider';
55
export default {
66
name: 'ACardMeta',
77
props: {
8-
prefixCls: PropTypes.string.def('ant-card'),
8+
prefixCls: PropTypes.string,
99
title: PropTypes.any,
1010
description: PropTypes.any,
1111
},

components/checkbox/Group.jsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import PropTypes from '../_util/vue-types';
12
import Checkbox from './Checkbox';
23
import hasProp from '../_util/props-util';
34
import { ConfigConsumerProps } from '../config-provider';
@@ -9,22 +10,11 @@ export default {
910
prop: 'value',
1011
},
1112
props: {
12-
prefixCls: {
13-
type: String,
14-
},
15-
defaultValue: {
16-
default: undefined,
17-
type: Array,
18-
},
19-
value: {
20-
default: undefined,
21-
type: Array,
22-
},
23-
options: {
24-
default: () => [],
25-
type: Array,
26-
},
27-
disabled: Boolean,
13+
prefixCls: PropTypes.string,
14+
defaultValue: PropTypes.array,
15+
value: PropTypes.array,
16+
options: PropTypes.array.def([]),
17+
disabled: PropTypes.bool,
2818
},
2919
provide() {
3020
return {

components/collapse/Collapse.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default {
1717
event: 'change',
1818
},
1919
props: initDefaultProps(collapseProps(), {
20-
prefixCls: 'ant-collapse',
2120
bordered: true,
2221
openAnimation: animation,
2322
}),
@@ -30,7 +29,7 @@ export default {
3029
const icon = expandIcon || (
3130
<Icon type="right" rotate={panelProps.isActive ? 90 : undefined} />
3231
);
33-
return isValidElement(expandIcon ? icon[0] : icon)
32+
return isValidElement(Array.isArray(expandIcon) ? icon[0] : icon)
3433
? cloneElement(icon, {
3534
class: `${prefixCls}-arrow`,
3635
})

components/date-picker/RangePicker.jsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,18 @@ export default {
111111
};
112112
}
113113
this.setState(state);
114-
this.prevState = { ...this.$data, ...state };
115114
},
116115
open(val) {
117116
const state = { sOpen: val };
118117
this.setState(state);
119-
this.prevState = { ...this.$data, ...state };
120118
},
121-
},
122-
mounted() {
123-
this.prevState = { ...this.$data };
124-
},
125-
updated() {
126-
this.$nextTick(() => {
127-
if (!hasProp(this, 'open') && this.prevState.sOpen && !this.sOpen) {
128-
this.focus();
129-
}
130-
});
119+
sOpen(val, oldVal) {
120+
this.$nextTick(() => {
121+
if (!hasProp(this, 'open') && oldVal && !val) {
122+
this.focus();
123+
}
124+
});
125+
},
131126
},
132127
methods: {
133128
clearSelection(e) {

components/date-picker/WeekPicker.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ export default {
6363
this.setState(state);
6464
this.prevState = { ...this.$data, ...state };
6565
},
66+
_open(val, oldVal) {
67+
this.$nextTick(() => {
68+
if (!hasProp(this, 'open') && oldVal && !val) {
69+
this.focus();
70+
}
71+
});
72+
},
6673
},
6774
mounted() {
6875
this.prevState = { ...this.$data };

components/date-picker/__tests__/__snapshots__/other.test.js.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,11 @@ exports[`MonthPicker and WeekPicker render WeekPicker 1`] = `
230230
</div>
231231
</div>
232232
`;
233+
234+
exports[`Picker format by locale date 1`] = `<span class="ant-calendar-picker"><div class=""><input readonly="true" placeholder="请选择日期" class="ant-calendar-picker-input ant-input"><i aria-label="图标: calendar" class="ant-calendar-picker-icon anticon anticon-calendar"><svg viewBox="64 64 896 896" data-icon="calendar" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"></path></svg></i></div></span>`;
235+
236+
exports[`Picker format by locale dateTime 1`] = `<span class="ant-calendar-picker"><div class=""><input readonly="true" placeholder="请选择日期" class="ant-calendar-picker-input ant-input"><i aria-label="图标: calendar" class="ant-calendar-picker-icon anticon anticon-calendar"><svg viewBox="64 64 896 896" data-icon="calendar" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"></path></svg></i></div></span>`;
237+
238+
exports[`Picker format by locale month 1`] = `<span class="ant-calendar-picker"><div class=""><input readonly="true" placeholder="请选择日期" class="ant-calendar-picker-input ant-input"><i aria-label="图标: calendar" class="ant-calendar-picker-icon anticon anticon-calendar"><svg viewBox="64 64 896 896" data-icon="calendar" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"></path></svg></i></div></span>`;
239+
240+
exports[`Picker format by locale week 1`] = `<span class="ant-calendar-picker"><span class="" style="display: inline-block; width: 100%;"><input readonly="true" placeholder="请选择日期" class="ant-calendar-picker-input ant-input"><i aria-label="图标: calendar" class="ant-calendar-picker-icon anticon anticon-calendar"><svg viewBox="64 64 896 896" data-icon="calendar" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"></path></svg></i></span></span>`;

components/date-picker/__tests__/other.test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,50 @@ import { mount } from '@vue/test-utils';
22
import { asyncExpect } from '@/tests/utils';
33
import moment from 'moment';
44
import DatePicker from '../';
5+
import LocaleProvider from '../../locale-provider';
6+
import locale from '../../locale-provider/zh_CN';
57

68
const { MonthPicker, WeekPicker } = DatePicker;
79

10+
describe('Picker format by locale', () => {
11+
const myLocale = {
12+
...locale,
13+
DatePicker: {
14+
...locale.DatePicker,
15+
dateFormat: 'YYYY 年 M 月 D 日',
16+
dateTimeFormat: 'YYYY 年 M 月 D 日 H 时 m 分 s 秒',
17+
weekFormat: 'YYYY 年 W 周',
18+
monthFormat: 'YYYY 年 M 月',
19+
},
20+
};
21+
22+
const date = moment('2000-01-01', 'YYYY-MM-DD');
23+
function matchPicker(name, Picker, props) {
24+
it(name, async () => {
25+
const wrapper = mount(
26+
{
27+
render() {
28+
return (
29+
<LocaleProvider locale={myLocale}>
30+
<Picker {...{ value: date, ...props }} />
31+
</LocaleProvider>
32+
);
33+
},
34+
},
35+
{ sync: false },
36+
);
37+
await asyncExpect(() => {
38+
expect(wrapper.html()).toMatchSnapshot();
39+
});
40+
});
41+
}
42+
43+
matchPicker('date', DatePicker);
44+
matchPicker('dateTime', DatePicker, { showTime: true });
45+
matchPicker('week', WeekPicker);
46+
matchPicker('month', MonthPicker);
47+
});
48+
849
describe('MonthPicker and WeekPicker', () => {
950
it('render MonthPicker', async () => {
1051
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');

components/date-picker/createPicker.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export default function createPicker(TheCalendar, props) {
5858
state.showDate = props.value;
5959
}
6060
this.setState(state);
61-
this.prevState = { ...this.$data, ...state };
6261
},
6362
value(val) {
6463
const state = {};
@@ -67,23 +66,18 @@ export default function createPicker(TheCalendar, props) {
6766
state.showDate = val;
6867
}
6968
this.setState(state);
70-
this.prevState = { ...this.$data, ...state };
7169
},
72-
},
73-
mounted() {
74-
this.prevState = { ...this.$data };
75-
},
76-
updated() {
77-
this.$nextTick(() => {
78-
if (!hasProp(this, 'open') && this.prevState._open && !this._open) {
79-
this.focus();
80-
}
81-
});
70+
_open(val, oldVal) {
71+
this.$nextTick(() => {
72+
if (!hasProp(this, 'open') && oldVal && !val) {
73+
this.focus();
74+
}
75+
});
76+
},
8277
},
8378
methods: {
8479
renderFooter(...args) {
85-
const { $scopedSlots, $slots } = this;
86-
const { _prefixCls: prefixCls } = this;
80+
const { $scopedSlots, $slots, _prefixCls: prefixCls } = this;
8781
const renderExtraFooter =
8882
this.renderExtraFooter || $scopedSlots.renderExtraFooter || $slots.renderExtraFooter;
8983
return renderExtraFooter ? (

0 commit comments

Comments
 (0)