From 0ce9d646a7396d7854e9c61f33224899e88fbaf3 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 28 Nov 2018 21:58:42 +0800 Subject: [PATCH 1/2] feat: update back-top badge breadcrumb button calendar card carousel cascader collapse --- .../__tests__/__snapshots__/demo.test.js.snap | 76 ++- components/anchor/demo/index.vue | 2 +- components/back-top/demo/index.vue | 1 + components/badge/Badge.jsx | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 8 +- components/badge/demo/index.vue | 2 + .../__tests__/__snapshots__/demo.test.js.snap | 2 +- components/breadcrumb/demo/index.vue | 1 + .../__tests__/__snapshots__/demo.test.js.snap | 67 ++- .../__snapshots__/index.test.js.snap | 30 +- components/button/button.jsx | 23 +- components/button/demo/index.vue | 1 + components/button/index.en-US.md | 2 +- components/button/index.zh-CN.md | 4 +- components/calendar/Header.jsx | 2 +- .../__snapshots__/index.test.js.snap | 306 ++++++++++++ components/calendar/__tests__/index.test.js | 12 + components/calendar/demo/index.vue | 1 + components/calendar/index.en-US.md | 2 +- components/calendar/index.jsx | 15 +- components/calendar/locale/mn_MN.js | 2 + .../__tests__/__snapshots__/demo.test.js.snap | 8 +- .../__snapshots__/index.test.js.snap | 14 + components/card/__tests__/index.test.js | 12 + components/card/demo/index.vue | 1 + .../__tests__/__snapshots__/demo.test.js.snap | 10 +- components/carousel/demo/index.vue | 1 + components/carousel/index.en-US.md | 2 +- components/carousel/index.jsx | 4 +- components/carousel/index.zh-CN.md | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 64 ++- .../__snapshots__/index.test.js.snap | 7 +- .../__tests__/__snapshots__/demo.test.js.snap | 5 +- components/collapse/demo/index.vue | 1 + .../__snapshots__/DatePicker.test.js.snap | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 5 +- .../__tests__/__snapshots__/demo.test.js.snap | 36 +- .../__tests__/__snapshots__/demo.test.js.snap | 28 +- .../__tests__/__snapshots__/demo.test.js.snap | 10 +- .../__snapshots__/index.test.js.snap | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 96 ++-- .../__tests__/__snapshots__/demo.test.js.snap | 18 +- .../__tests__/__snapshots__/demo.test.js.snap | 10 +- .../__snapshots__/index.test.js.snap | 438 ++++++++++++------ .../__tests__/__snapshots__/demo.test.js.snap | 92 ++-- .../__snapshots__/index.test.js.snap | 5 +- .../__tests__/__snapshots__/demo.test.js.snap | 50 +- .../__snapshots__/index.test.js.snap | 6 +- .../__tests__/__snapshots__/demo.test.js.snap | 242 +++++++--- .../__tests__/__snapshots__/demo.test.js.snap | 8 +- .../__tests__/__snapshots__/demo.test.js.snap | 4 +- .../__tests__/__snapshots__/demo.test.js.snap | 8 +- .../__tests__/__snapshots__/demo.test.js.snap | 2 +- .../__snapshots__/Table.filter.test.js.snap | 2 +- .../__snapshots__/Table.sorter.test.js.snap | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 62 ++- .../__tests__/__snapshots__/demo.test.js.snap | 22 +- .../__tests__/__snapshots__/demo.test.js.snap | 24 +- .../__tests__/__snapshots__/demo.test.js.snap | 9 +- .../__tests__/__snapshots__/demo.test.js.snap | 42 +- .../__snapshots__/index.test.js.snap | 12 +- .../__snapshots__/search.test.js.snap | 7 +- .../__tests__/__snapshots__/demo.test.js.snap | 20 +- .../__tests__/__snapshots__/demo.test.js.snap | 34 +- .../__snapshots__/uploadlist.test.js.snap | 44 +- 65 files changed, 1541 insertions(+), 493 deletions(-) create mode 100644 components/calendar/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/calendar/locale/mn_MN.js diff --git a/components/alert/__tests__/__snapshots__/demo.test.js.snap b/components/alert/__tests__/__snapshots__/demo.test.js.snap index 23160bc1e..9a54cd606 100644 --- a/components/alert/__tests__/__snapshots__/demo.test.js.snap +++ b/components/alert/__tests__/__snapshots__/demo.test.js.snap @@ -2,10 +2,18 @@ exports[`renders ./components/alert/demo/banner.md correctly 1`] = `
-
Warning text

-
Very long warning text warning text text text text text text text

+
Warning text

+
Very long warning text warning text text text text text text text

Warning text without icon

-
Error text
+
Error text
`; @@ -13,13 +21,31 @@ exports[`renders ./components/alert/demo/basic.md correctly 1`] = `
-
Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text
-
Error TextError Description Error Description Error Description Error Description Error Description Error Description
+
Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text
+
Error TextError Description Error Description Error Description Error Description Error Description Error Description
`; exports[`renders ./components/alert/demo/close-text.md correctly 1`] = `
Info TextClose Now
`; +exports[`renders ./components/alert/demo/custom-icon.md correctly 1`] = ` +
+
showIcon = false
+
Success Tips
+
Informational Notes
+
Warning
+
Error
+
Success TipsDetailed description and advices about successful copywriting.
+
Informational NotesAdditional description and informations about copywriting.
+
WarningThis is a warning notice about copywriting.
+
ErrorThis is an error message about copywriting.
+
+`; + exports[`renders ./components/alert/demo/description.md correctly 1`] = `
Success Text

@@ -33,20 +59,42 @@ exports[`renders ./components/alert/demo/description.md correctly 1`] = ` exports[`renders ./components/alert/demo/icon.md correctly 1`] = `

-
Success Tips
-
Informational Notes
-
Warning
-
Error
-
Success TipsDetailed description and advices about successful copywriting.
-
Informational NotesAdditional description and informations about copywriting.
-
WarningThis is a warning notice about copywriting.
-
ErrorThis is an error message about copywriting.
+
Success Tips
+
Informational Notes
+
Warning
+
Error
+
Success TipsDetailed description and advices about successful copywriting.
+
Informational NotesAdditional description and informations about copywriting.
+
WarningThis is a warning notice about copywriting.
+
ErrorThis is an error message about copywriting.
`; exports[`renders ./components/alert/demo/smooth-closed.md correctly 1`] = `
-
Alert Message Text
+
Alert Message Text
`; diff --git a/components/anchor/demo/index.vue b/components/anchor/demo/index.vue index 941f1f6c6..9b7fdd9af 100644 --- a/components/anchor/demo/index.vue +++ b/components/anchor/demo/index.vue @@ -28,7 +28,7 @@ export default { subtitle: '锚点', cols: 2, type: 'Other', - zhType: '其它', + zhType: '其他', title: 'Anchor', render () { return ( diff --git a/components/back-top/demo/index.vue b/components/back-top/demo/index.vue index e6a93f968..eb9648fc5 100644 --- a/components/back-top/demo/index.vue +++ b/components/back-top/demo/index.vue @@ -21,6 +21,7 @@ const md = { export default { category: 'Components', type: 'Other', + zhType: '其他', subtitle: '回到顶部', title: 'BackTop', render () { diff --git a/components/badge/Badge.jsx b/components/badge/Badge.jsx index 258cd0b24..e9c9d5f25 100644 --- a/components/badge/Badge.jsx +++ b/components/badge/Badge.jsx @@ -73,7 +73,7 @@ export default { [`${prefixCls}-not-a-wrapper`]: !children.length, }) const styleWithOffset = offset ? { - marginLeft: typeof offset[0] === 'number' ? `${offset[0]}px` : offset[0], + right: -parseInt(offset[0], 10), marginTop: typeof offset[1] === 'number' ? `${offset[1]}px` : offset[1], ...numberStyle, } : numberStyle diff --git a/components/badge/__tests__/__snapshots__/demo.test.js.snap b/components/badge/__tests__/__snapshots__/demo.test.js.snap index 719178a71..6e4863e27 100644 --- a/components/badge/__tests__/__snapshots__/demo.test.js.snap +++ b/components/badge/__tests__/__snapshots__/demo.test.js.snap @@ -5,13 +5,17 @@ exports[`renders ./components/badge/demo/basic.md correctly 1`] = `

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

-
+
`; -exports[`renders ./components/badge/demo/dot.md correctly 1`] = ``; +exports[`renders ./components/badge/demo/dot.md correctly 1`] = ``; exports[`renders ./components/badge/demo/link.md correctly 1`] = `

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

`; diff --git a/components/badge/demo/index.vue b/components/badge/demo/index.vue index 25ba23d82..99d19c522 100644 --- a/components/badge/demo/index.vue +++ b/components/badge/demo/index.vue @@ -29,6 +29,7 @@ category: 'Components', subtitle: '徽标数', type: 'Data Display', + zhType: '数据展示', title: 'Badge', render () { return ( @@ -61,6 +62,7 @@ border-radius: 4px; background: #eee; display: inline-block; + vertical-align: middle; } #components-badge-demo .ant-badge-not-a-wrapper:not(.ant-badge-status) { margin-right: 8px; diff --git a/components/breadcrumb/__tests__/__snapshots__/demo.test.js.snap b/components/breadcrumb/__tests__/__snapshots__/demo.test.js.snap index daafe045e..211a16938 100644 --- a/components/breadcrumb/__tests__/__snapshots__/demo.test.js.snap +++ b/components/breadcrumb/__tests__/__snapshots__/demo.test.js.snap @@ -12,7 +12,7 @@ exports[`renders ./components/breadcrumb/demo/separator.md correctly 1`] = ` `; exports[`renders ./components/breadcrumb/demo/withIcon.md correctly 1`] = ` -
/ Application List/ +
/ Application List/ Application /
`; diff --git a/components/breadcrumb/demo/index.vue b/components/breadcrumb/demo/index.vue index bbea90951..aec8c2f4a 100644 --- a/components/breadcrumb/demo/index.vue +++ b/components/breadcrumb/demo/index.vue @@ -31,6 +31,7 @@ category: 'Components', subtitle: '面包屑', type: 'Navigation', + zhType: '导航', title: 'Breadcrumb', render () { return ( diff --git a/components/button/__tests__/__snapshots__/demo.test.js.snap b/components/button/__tests__/__snapshots__/demo.test.js.snap index 3dab9dde4..4dff6fe2a 100644 --- a/components/button/__tests__/__snapshots__/demo.test.js.snap +++ b/components/button/__tests__/__snapshots__/demo.test.js.snap @@ -11,10 +11,19 @@ exports[`renders ./components/button/demo/button-group.md correctly 1`] = `

With Icon

-
-
+ Go forward
+
`; @@ -26,20 +35,60 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = ` exports[`renders ./components/button/demo/ghost.md correctly 1`] = `
`; -exports[`renders ./components/button/demo/icon.md correctly 1`] = `
`; +exports[`renders ./components/button/demo/icon.md correctly 1`] = ` +
+`; -exports[`renders ./components/button/demo/loading.md correctly 1`] = `


`; +exports[`renders ./components/button/demo/loading.md correctly 1`] = ` +


+`; exports[`renders ./components/button/demo/multiple.md correctly 1`] = `
+ Actions
`; exports[`renders ./components/button/demo/size.md correctly 1`] = `
-




-


+
+ Forward
`; diff --git a/components/button/__tests__/__snapshots__/index.test.js.snap b/components/button/__tests__/__snapshots__/index.test.js.snap index 0a9dc15e2..834e92354 100644 --- a/components/button/__tests__/__snapshots__/index.test.js.snap +++ b/components/button/__tests__/__snapshots__/index.test.js.snap @@ -6,15 +6,35 @@ exports[`Button fixbug renders {0} , 0 and {false} 2`] = ``; -exports[`Button renders Chinese characters correctly 1`] = ``; +exports[`Button renders Chinese characters correctly 1`] = ` + +`; -exports[`Button renders Chinese characters correctly 2`] = ``; +exports[`Button renders Chinese characters correctly 2`] = ` + +`; -exports[`Button renders Chinese characters correctly 3`] = ``; +exports[`Button renders Chinese characters correctly 3`] = ` + +`; -exports[`Button renders Chinese characters correctly 4`] = ``; +exports[`Button renders Chinese characters correctly 4`] = ` + +`; -exports[`Button renders Chinese characters correctly 5`] = ``; +exports[`Button renders Chinese characters correctly 5`] = ` + +`; exports[`Button renders correctly 1`] = ``; diff --git a/components/button/button.jsx b/components/button/button.jsx index 7a49ebffa..36a21e8fb 100644 --- a/components/button/button.jsx +++ b/components/button/button.jsx @@ -65,7 +65,10 @@ export default { methods: { fixTwoCNChar () { // Fix for HOC usage like - const node = this.$el + const node = this.$refs.buttonNode + if (!node) { + return + } const buttonText = node.textContent || node.innerText if (this.isNeedInserted() && isTwoCNChar(buttonText)) { if (!this.hasTwoCNChar) { @@ -76,9 +79,10 @@ export default { } }, handleClick (event) { - // this.clicked = true - // clearTimeout(this.timeout) - // this.timeout = setTimeout(() => (this.clicked = false), 500) + const { sLoading } = this.$data + if (sLoading) { + return + } this.$emit('click', event) }, insertSpace (child, needInserted) { @@ -101,6 +105,9 @@ export default { const { htmlType, classes, icon, disabled, handleClick, sLoading, $slots, $attrs, $listeners } = this + const now = new Date() + const isChristmas = now.getMonth() === 11 && now.getDate() === 25 + const title = isChristmas ? 'Ho Ho Ho!' : $attrs.title const buttonProps = { props: { }, @@ -108,8 +115,9 @@ export default { ...$attrs, type: htmlType, disabled, + title, }, - class: classes, + class: { ...classes, christmas: isChristmas }, on: { ...$listeners, click: handleClick, @@ -118,16 +126,17 @@ export default { const iconType = sLoading ? 'loading' : icon const iconNode = iconType ? : null const kids = $slots.default && $slots.default.length === 1 ? this.insertSpace($slots.default[0], this.isNeedInserted()) : $slots.default + if ('href' in $attrs) { return ( - + {iconNode}{kids} ) } else { return ( - diff --git a/components/button/demo/index.vue b/components/button/demo/index.vue index a39748f17..29c380c90 100644 --- a/components/button/demo/index.vue +++ b/components/button/demo/index.vue @@ -26,6 +26,7 @@ const md = { export default { category: 'Components', type: 'General', + zhType: '通用', title: 'Button', subtitle: '按钮', render () { diff --git a/components/button/index.en-US.md b/components/button/index.en-US.md index 01844a0d4..9c3ea1361 100644 --- a/components/button/index.en-US.md +++ b/components/button/index.en-US.md @@ -17,7 +17,7 @@ To get a customized button, just set `type`/`shape`/`size`/`loading`/`disabled`. ### events | Events Name | Description | Arguments | | --- | --- | --- | -| click | set the handler to handle `click` event | function(e) | +| click | set the handler to handle `click` event | (event) => void | `` will be rendered into ``, and all the properties which are not listed above will be transferred to the ``,并且除了上表中的属性,其它属性都会直接传到 ``。 +`Hello world!` 最终会被渲染为 ``,并且除了上表中的属性,其它属性都会直接传到原生 button 上。 diff --git a/components/calendar/Header.jsx b/components/calendar/Header.jsx index 43da7f308..bf0442c0b 100644 --- a/components/calendar/Header.jsx +++ b/components/calendar/Header.jsx @@ -84,7 +84,7 @@ export default { const currentYear = value.get('year') if (rangeEnd.get('year') === currentYear) { end = rangeEnd.get('month') + 1 - } else { + } else if (rangeStart.get('year') === currentYear) { start = rangeStart.get('month') } } diff --git a/components/calendar/__tests__/__snapshots__/index.test.js.snap b/components/calendar/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..7d8d9b783 --- /dev/null +++ b/components/calendar/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,306 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Calendar Calendar should support locale 1`] = ` +
+
+
+
+
+
2018年
+
+
+
+
+
+
+
Oct
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SuMoTuWeThFrSa
+
+
30
+
+
+
+
+
01
+
+
+
+
+
02
+
+
+
+
+
03
+
+
+
+
+
04
+
+
+
+
+
05
+
+
+
+
+
06
+
+
+
+
+
07
+
+
+
+
+
08
+
+
+
+
+
09
+
+
+
+
+
10
+
+
+
+
+
11
+
+
+
+
+
12
+
+
+
+
+
13
+
+
+
+
+
14
+
+
+
+
+
15
+
+
+
+
+
16
+
+
+
+
+
17
+
+
+
+
+
18
+
+
+
+
+
19
+
+
+
+
+
20
+
+
+
+
+
21
+
+
+
+
+
22
+
+
+
+
+
23
+
+
+
+
+
24
+
+
+
+
+
25
+
+
+
+
+
26
+
+
+
+
+
27
+
+
+
+
+
28
+
+
+
+
+
29
+
+
+
+
+
30
+
+
+
+
+
31
+
+
+
+
+
01
+
+
+
+
+
02
+
+
+
+
+
03
+
+
+
+
+
04
+
+
+
+
+
05
+
+
+
+
+
06
+
+
+
+
+
07
+
+
+
+
+
08
+
+
+
+
+
09
+
+
+
+
+
10
+
+
+
+
+
+
+`; diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js index be4cee1ac..b40eb9c1f 100644 --- a/components/calendar/__tests__/index.test.js +++ b/components/calendar/__tests__/index.test.js @@ -1,6 +1,7 @@ import Moment from 'moment' import { mount } from '@vue/test-utils' import { asyncExpect } from '@/tests/utils' +import MockDate from 'mockdate' import Vue from 'vue' import Calendar from '..' @@ -152,4 +153,15 @@ describe('Calendar', () => { done() }) }) + + it('Calendar should support locale', () => { + MockDate.set(Moment('2018-10-19')) + // eslint-disable-next-line + const zhCN = require('../locale/zh_CN').default; + const wrapper = mount(Calendar, { propsData: { + locale: zhCN, + }}) + expect(wrapper.html()).toMatchSnapshot() + MockDate.reset() + }) }) diff --git a/components/calendar/demo/index.vue b/components/calendar/demo/index.vue index 9be0423c9..f81368e01 100644 --- a/components/calendar/demo/index.vue +++ b/components/calendar/demo/index.vue @@ -28,6 +28,7 @@ When data is in the form of dates, such as schedules, timetables, prices calenda export default { category: 'Components', type: 'Data Display', + zhType: '数据展示', subtitle: '日历', cols: 1, title: 'Calendar', diff --git a/components/calendar/index.en-US.md b/components/calendar/index.en-US.md index c248c7404..7763009f8 100644 --- a/components/calendar/index.en-US.md +++ b/components/calendar/index.en-US.md @@ -4,7 +4,7 @@ **Note:** Part of the Calendar's locale is read from `value`. So, please set the locale of `moment` correctly. ````html -// The default locale is en-US, if you want to use other locale, just set locale in entry file globaly. +// The default locale is en-US, if you want to use other locale, just set locale in entry file globally. // import moment from 'moment'; // import 'moment/locale/zh-cn'; // moment.locale('zh-cn'); diff --git a/components/calendar/index.jsx b/components/calendar/index.jsx index f21e0f257..891df3a1e 100644 --- a/components/calendar/index.jsx +++ b/components/calendar/index.jsx @@ -41,7 +41,7 @@ export const CalendarProps = () => ({ // monthCellRender: PropTypes.func, // dateFullCellRender: PropTypes.func, // monthFullCellRender: PropTypes.func, - locale: PropTypes.any, + locale: PropTypes.object, // onPanelChange?: (date?: moment.Moment, mode?: CalendarMode) => void; // onSelect?: (date?: moment.Moment) => void; disabledDate: PropTypes.func, @@ -226,13 +226,24 @@ const Calendar = { ) }, + getDefaultLocale () { + const result = { + ...enUS, + ...this.$props.locale, + } + result.lang = { + ...result.lang, + ...(this.$props.locale || {}).lang, + } + return result + }, }, render () { return (
    -
  • -
  • -
  • +
  • +
  • +
`; @@ -268,7 +268,7 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
- diff --git a/components/card/__tests__/__snapshots__/index.test.js.snap b/components/card/__tests__/__snapshots__/index.test.js.snap index 3bf46ab53..7c2b47bf3 100644 --- a/components/card/__tests__/__snapshots__/index.test.js.snap +++ b/components/card/__tests__/__snapshots__/index.test.js.snap @@ -59,3 +59,17 @@ exports[`Card should still have padding when card which set padding to 0 is load
`; + +exports[`Card title should be vertically aligned 1`] = ` +
+
+
+
Card title
+
+
+
+
+

Card content

+
+
+`; diff --git a/components/card/__tests__/index.test.js b/components/card/__tests__/index.test.js index b1acbcc03..01a6ad63c 100644 --- a/components/card/__tests__/index.test.js +++ b/components/card/__tests__/index.test.js @@ -1,5 +1,6 @@ import { mount } from '@vue/test-utils' import Card from '../index' +import Button from '../../button/index' const testMethod = typeof window !== 'undefined' ? it : xit @@ -46,4 +47,15 @@ describe('Card', () => { }) expect(wrapper.html()).toMatchSnapshot() }) + + it('title should be vertically aligned', () => { + const wrapper = mount({ + render () { + return Button} style={{ width: '300px' }}> +

Card content

+
+ }, + }) + expect(wrapper.html()).toMatchSnapshot() + }) }) diff --git a/components/card/demo/index.vue b/components/card/demo/index.vue index 541dcb930..2fb1b9e89 100644 --- a/components/card/demo/index.vue +++ b/components/card/demo/index.vue @@ -33,6 +33,7 @@ const md = { export default { category: 'Components', type: 'Data Display', + zhType: '数据展示', title: 'Card', subtitle: '卡片', cols: 1, diff --git a/components/carousel/__tests__/__snapshots__/demo.test.js.snap b/components/carousel/__tests__/__snapshots__/demo.test.js.snap index fb9064677..9a61088a6 100644 --- a/components/carousel/__tests__/__snapshots__/demo.test.js.snap +++ b/components/carousel/__tests__/__snapshots__/demo.test.js.snap @@ -163,7 +163,10 @@ exports[`renders ./components/carousel/demo/basic.md correctly 1`] = ` exports[`renders ./components/carousel/demo/customArrows.md correctly 1`] = `