From 927a0a6c814e9d5317995d3daafeffd966cb317e Mon Sep 17 00:00:00 2001
From: tanjinzhou <415800467@qq.com>
Date: Tue, 10 Sep 2019 18:57:08 +0800
Subject: [PATCH] cr cxxx- exxx
---
components/calendar/index.jsx | 23 +++++------
components/card/Grid.jsx | 2 +-
components/card/Meta.jsx | 2 +-
components/checkbox/Group.jsx | 22 +++-------
components/collapse/Collapse.jsx | 3 +-
components/date-picker/RangePicker.jsx | 19 ++++-----
components/date-picker/WeekPicker.jsx | 7 ++++
.../__snapshots__/other.test.js.snap | 8 ++++
.../date-picker/__tests__/other.test.js | 41 +++++++++++++++++++
components/date-picker/createPicker.js | 22 ++++------
components/date-picker/locale/example.json | 6 ++-
components/drawer/index.en-US.md | 1 +
components/drawer/index.jsx | 9 ++--
components/drawer/index.zh-CN.md | 1 +
.../dropdown-button.test.js.snap | 2 +-
components/dropdown/dropdown-button.jsx | 8 +++-
components/dropdown/dropdown.jsx | 14 +++----
components/dropdown/index.en-US.md | 4 +-
components/dropdown/index.zh-CN.md | 4 +-
components/empty/index.jsx | 7 ++--
package.json | 2 +-
types/card.d.ts | 8 ++++
types/collapse/collapse.d.ts | 6 +++
types/drawer.d.ts | 6 +++
types/dropdown/dropdown-button.d.ts | 4 +-
types/dropdown/dropdown.d.ts | 4 +-
26 files changed, 149 insertions(+), 86 deletions(-)
diff --git a/components/calendar/index.jsx b/components/calendar/index.jsx
index 2ca4e9ca3..2f71432e5 100644
--- a/components/calendar/index.jsx
+++ b/components/calendar/index.jsx
@@ -159,7 +159,17 @@ const Calendar = {
return inRange;
};
},
-
+ getDefaultLocale() {
+ const result = {
+ ...enUS,
+ ...this.$props.locale,
+ };
+ result.lang = {
+ ...result.lang,
+ ...(this.$props.locale || {}).lang,
+ };
+ return result;
+ },
renderCalendar(locale, localeCode) {
const props = getOptionProps(this);
const { sValue: value, sMode: mode, $listeners, $scopedSlots } = this;
@@ -230,17 +240,6 @@ const Calendar = {
);
},
- getDefaultLocale() {
- const result = {
- ...enUS,
- ...this.$props.locale,
- };
- result.lang = {
- ...result.lang,
- ...(this.$props.locale || {}).lang,
- };
- return result;
- },
},
render() {
diff --git a/components/card/Grid.jsx b/components/card/Grid.jsx
index 23b05f5cc..d71e11c02 100644
--- a/components/card/Grid.jsx
+++ b/components/card/Grid.jsx
@@ -5,7 +5,7 @@ export default {
name: 'ACardGrid',
__ANT_CARD_GRID: true,
props: {
- prefixCls: PropTypes.string.def('ant-card'),
+ prefixCls: PropTypes.string,
},
inject: {
configProvider: { default: () => ({}) },
diff --git a/components/card/Meta.jsx b/components/card/Meta.jsx
index d75c28b3b..c0371f556 100644
--- a/components/card/Meta.jsx
+++ b/components/card/Meta.jsx
@@ -5,7 +5,7 @@ import { ConfigConsumerProps } from '../config-provider';
export default {
name: 'ACardMeta',
props: {
- prefixCls: PropTypes.string.def('ant-card'),
+ prefixCls: PropTypes.string,
title: PropTypes.any,
description: PropTypes.any,
},
diff --git a/components/checkbox/Group.jsx b/components/checkbox/Group.jsx
index 8cc4c1c6d..3e28ff908 100644
--- a/components/checkbox/Group.jsx
+++ b/components/checkbox/Group.jsx
@@ -1,3 +1,4 @@
+import PropTypes from '../_util/vue-types';
import Checkbox from './Checkbox';
import hasProp from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
@@ -9,22 +10,11 @@ export default {
prop: 'value',
},
props: {
- prefixCls: {
- type: String,
- },
- defaultValue: {
- default: undefined,
- type: Array,
- },
- value: {
- default: undefined,
- type: Array,
- },
- options: {
- default: () => [],
- type: Array,
- },
- disabled: Boolean,
+ prefixCls: PropTypes.string,
+ defaultValue: PropTypes.array,
+ value: PropTypes.array,
+ options: PropTypes.array.def([]),
+ disabled: PropTypes.bool,
},
provide() {
return {
diff --git a/components/collapse/Collapse.jsx b/components/collapse/Collapse.jsx
index b47579413..29309d14d 100644
--- a/components/collapse/Collapse.jsx
+++ b/components/collapse/Collapse.jsx
@@ -17,7 +17,6 @@ export default {
event: 'change',
},
props: initDefaultProps(collapseProps(), {
- prefixCls: 'ant-collapse',
bordered: true,
openAnimation: animation,
}),
@@ -30,7 +29,7 @@ export default {
const icon = expandIcon || (
);
- return isValidElement(expandIcon ? icon[0] : icon)
+ return isValidElement(Array.isArray(expandIcon) ? icon[0] : icon)
? cloneElement(icon, {
class: `${prefixCls}-arrow`,
})
diff --git a/components/date-picker/RangePicker.jsx b/components/date-picker/RangePicker.jsx
index 62662a142..fdc26cf33 100644
--- a/components/date-picker/RangePicker.jsx
+++ b/components/date-picker/RangePicker.jsx
@@ -111,23 +111,18 @@ export default {
};
}
this.setState(state);
- this.prevState = { ...this.$data, ...state };
},
open(val) {
const state = { sOpen: val };
this.setState(state);
- this.prevState = { ...this.$data, ...state };
},
- },
- mounted() {
- this.prevState = { ...this.$data };
- },
- updated() {
- this.$nextTick(() => {
- if (!hasProp(this, 'open') && this.prevState.sOpen && !this.sOpen) {
- this.focus();
- }
- });
+ sOpen(val, oldVal) {
+ this.$nextTick(() => {
+ if (!hasProp(this, 'open') && oldVal && !val) {
+ this.focus();
+ }
+ });
+ },
},
methods: {
clearSelection(e) {
diff --git a/components/date-picker/WeekPicker.jsx b/components/date-picker/WeekPicker.jsx
index 280c79db3..77c773e0e 100644
--- a/components/date-picker/WeekPicker.jsx
+++ b/components/date-picker/WeekPicker.jsx
@@ -63,6 +63,13 @@ export default {
this.setState(state);
this.prevState = { ...this.$data, ...state };
},
+ _open(val, oldVal) {
+ this.$nextTick(() => {
+ if (!hasProp(this, 'open') && oldVal && !val) {
+ this.focus();
+ }
+ });
+ },
},
mounted() {
this.prevState = { ...this.$data };
diff --git a/components/date-picker/__tests__/__snapshots__/other.test.js.snap b/components/date-picker/__tests__/__snapshots__/other.test.js.snap
index 0865167ef..72967e867 100644
--- a/components/date-picker/__tests__/__snapshots__/other.test.js.snap
+++ b/components/date-picker/__tests__/__snapshots__/other.test.js.snap
@@ -230,3 +230,11 @@ exports[`MonthPicker and WeekPicker render WeekPicker 1`] = `
`;
+
+exports[`Picker format by locale date 1`] = ``;
+
+exports[`Picker format by locale dateTime 1`] = ``;
+
+exports[`Picker format by locale month 1`] = ``;
+
+exports[`Picker format by locale week 1`] = ``;
diff --git a/components/date-picker/__tests__/other.test.js b/components/date-picker/__tests__/other.test.js
index eecfc632b..e40ee2db1 100644
--- a/components/date-picker/__tests__/other.test.js
+++ b/components/date-picker/__tests__/other.test.js
@@ -2,9 +2,50 @@ import { mount } from '@vue/test-utils';
import { asyncExpect } from '@/tests/utils';
import moment from 'moment';
import DatePicker from '../';
+import LocaleProvider from '../../locale-provider';
+import locale from '../../locale-provider/zh_CN';
const { MonthPicker, WeekPicker } = DatePicker;
+describe('Picker format by locale', () => {
+ const myLocale = {
+ ...locale,
+ DatePicker: {
+ ...locale.DatePicker,
+ dateFormat: 'YYYY 年 M 月 D 日',
+ dateTimeFormat: 'YYYY 年 M 月 D 日 H 时 m 分 s 秒',
+ weekFormat: 'YYYY 年 W 周',
+ monthFormat: 'YYYY 年 M 月',
+ },
+ };
+
+ const date = moment('2000-01-01', 'YYYY-MM-DD');
+ function matchPicker(name, Picker, props) {
+ it(name, async () => {
+ const wrapper = mount(
+ {
+ render() {
+ return (
+
+
+
+ );
+ },
+ },
+ { sync: false },
+ );
+ await asyncExpect(() => {
+ expect(wrapper.html()).toMatchSnapshot();
+ });
+ });
+ }
+
+ matchPicker('date', DatePicker);
+ matchPicker('dateTime', DatePicker, { showTime: true });
+ matchPicker('week', WeekPicker);
+ matchPicker('month', MonthPicker);
+});
+
describe('MonthPicker and WeekPicker', () => {
it('render MonthPicker', async () => {
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
diff --git a/components/date-picker/createPicker.js b/components/date-picker/createPicker.js
index 7e48dcf47..94563db2e 100644
--- a/components/date-picker/createPicker.js
+++ b/components/date-picker/createPicker.js
@@ -58,7 +58,6 @@ export default function createPicker(TheCalendar, props) {
state.showDate = props.value;
}
this.setState(state);
- this.prevState = { ...this.$data, ...state };
},
value(val) {
const state = {};
@@ -67,23 +66,18 @@ export default function createPicker(TheCalendar, props) {
state.showDate = val;
}
this.setState(state);
- this.prevState = { ...this.$data, ...state };
},
- },
- mounted() {
- this.prevState = { ...this.$data };
- },
- updated() {
- this.$nextTick(() => {
- if (!hasProp(this, 'open') && this.prevState._open && !this._open) {
- this.focus();
- }
- });
+ _open(val, oldVal) {
+ this.$nextTick(() => {
+ if (!hasProp(this, 'open') && oldVal && !val) {
+ this.focus();
+ }
+ });
+ },
},
methods: {
renderFooter(...args) {
- const { $scopedSlots, $slots } = this;
- const { _prefixCls: prefixCls } = this;
+ const { $scopedSlots, $slots, _prefixCls: prefixCls } = this;
const renderExtraFooter =
this.renderExtraFooter || $scopedSlots.renderExtraFooter || $slots.renderExtraFooter;
return renderExtraFooter ? (
diff --git a/components/date-picker/locale/example.json b/components/date-picker/locale/example.json
index b7b0aa3a7..4c260f922 100644
--- a/components/date-picker/locale/example.json
+++ b/components/date-picker/locale/example.json
@@ -31,5 +31,9 @@
},
"timePickerLocale": {
"placeholder": "Select time"
- }
+ },
+ "dateFormat": "YYYY-MM-DD",
+ "dateTimeFormat": "YYYY-MM-DD HH:mm:ss",
+ "weekFormat": "YYYY-wo",
+ "monthFormat": "YYYY-MM"
}
diff --git a/components/drawer/index.en-US.md b/components/drawer/index.en-US.md
index 87ba67625..9a41e70e6 100644
--- a/components/drawer/index.en-US.md
+++ b/components/drawer/index.en-US.md
@@ -12,6 +12,7 @@
| visible | Whether the Drawer dialog is visible or not. | boolean | false |
| wrapClassName | The class name of the container of the Drawer dialog. | string | - |
| wrapStyle | The style of the container of the Drawer dialog. | object | - |
+| bodyStyle | Style of floating layer, typically used for adjusting its position. | object | - |
| width | Width of the Drawer dialog. | string\|number | 256 |
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - |
| zIndex | The `z-index` of the Drawer. | Number | 1000 |
diff --git a/components/drawer/index.jsx b/components/drawer/index.jsx
index b40648fc8..eb8bb3024 100644
--- a/components/drawer/index.jsx
+++ b/components/drawer/index.jsx
@@ -17,6 +17,7 @@ const Drawer = {
mask: PropTypes.bool.def(true),
maskStyle: PropTypes.object,
wrapStyle: PropTypes.object,
+ bodyStyle: PropTypes.object,
title: PropTypes.any,
visible: PropTypes.bool,
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).def(256),
@@ -106,13 +107,11 @@ const Drawer = {
}
},
getRcDrawerStyle() {
- const { zIndex, placement, maskStyle, wrapStyle } = this.$props;
+ const { zIndex, placement } = this.$props;
const { _push: push } = this.$data;
return {
- ...maskStyle,
zIndex,
transform: push ? this.getPushTransform(placement) : undefined,
- ...wrapStyle,
};
},
renderHeader(prefixCls) {
@@ -143,7 +142,7 @@ const Drawer = {
return null;
}
this.destroyClose = false;
- const { placement } = this.$props;
+ const { placement, bodyStyle } = this.$props;
const containerStyle =
placement === 'left' || placement === 'right'
@@ -167,7 +166,7 @@ const Drawer = {
onTransitionend={this.onDestroyTransitionEnd}
>
{this.renderHeader(prefixCls)}
-
diff --git a/components/drawer/index.zh-CN.md b/components/drawer/index.zh-CN.md
index 1d01962ea..d4977e9e9 100644
--- a/components/drawer/index.zh-CN.md
+++ b/components/drawer/index.zh-CN.md
@@ -12,6 +12,7 @@
| visible | Drawer 是否可见 | boolean | - |
| wrapClassName | 对话框外层容器的类名 | string | - |
| wrapStyle | 对话框外层容器的`style` | object | - |
+| bodyStyle | 可用于设置 Drawer 的样式,调整浮层位置等 | object | - |
| width | 宽度 | string \| number | 256 |
| height | 高度, 在 `placement` 为 `top` 或 `bottom` 时使用 | string \| number | 256 |
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 |
diff --git a/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap b/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap
index eadae95a5..9f4c160b0 100644
--- a/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap
+++ b/components/dropdown/__tests__/__snapshots__/dropdown-button.test.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DropdownButton should support href like Button 1`] = `
-