From b249c690d7488bb29fb9d0a7cc61074c38d1b1b7 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 16 Jul 2020 22:48:26 +0800 Subject: [PATCH 01/51] feat(Tab): add scrollTo method (#6800) --- src/tab/README.md | 1 + src/tab/README.zh-CN.md | 7 ++--- src/tab/test/__snapshots__/index.spec.js.snap | 4 +-- src/tab/test/index.spec.js | 26 ++++++++++++++++++- src/tabs/index.js | 12 +++++++-- types/tabs.d.ts | 2 ++ 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/tab/README.md b/src/tab/README.md index ef80688fb..009dc2637 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -241,6 +241,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Tabs instance and call instance | Name | Description | Attribute | Return value | | --- | --- | --- | --- | | resize | Resize Tabs when container element resized | - | void | +| scrollTo `v2.9.3` | Go to specified tab in scrollspy mode | name | void | ### Tabs Slots diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index db16f8397..757ea4aeb 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -243,9 +243,10 @@ export default { 通过 ref 可以获取到 Tabs 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) -| 方法名 | 说明 | 参数 | 返回值 | -| ------ | -------------------------------------------- | ---- | ------ | -| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void | +| 方法名 | 说明 | 参数 | 返回值 | +| --- | --- | --- | --- | +| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void | +| scrollTo `v2.9.3` | 滚动到指定的标签页,在滚动导航模式下可用 | name: 标识符 | void | ### Tabs Slots diff --git a/src/tab/test/__snapshots__/index.spec.js.snap b/src/tab/test/__snapshots__/index.spec.js.snap index 6f4a6c641..4cc331f17 100644 --- a/src/tab/test/__snapshots__/index.spec.js.snap +++ b/src/tab/test/__snapshots__/index.spec.js.snap @@ -229,7 +229,7 @@ exports[`render nav-left & nav-right slot 1`] = ` exports[`rendered event 1`] = `
Text
`; -exports[`scrollspy 1`] = ` +exports[`scrollspy prop 1`] = `
@@ -251,7 +251,7 @@ exports[`scrollspy 1`] = `
`; -exports[`scrollspy 2`] = ` +exports[`scrollspy prop 2`] = `
diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index 9c9d326c4..cf1b6ec39 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -258,7 +258,7 @@ test('info prop', () => { expect(wrapper).toMatchSnapshot(); }); -test('scrollspy', async () => { +test('scrollspy prop', async () => { const onChange = jest.fn(); window.scrollTo = jest.fn(); @@ -288,6 +288,30 @@ test('scrollspy', async () => { expect(onChange).toHaveBeenCalledWith('c', 'title3'); }); +test('scrollTo method', async () => { + const onChange = jest.fn(); + window.scrollTo = jest.fn(); + + mount({ + template: ` + + Text + Text + Text + + `, + methods: { + onChange, + }, + mounted() { + this.$refs.root.scrollTo('b'); + }, + }); + + await later(); + expect(onChange).toHaveBeenCalledWith('b', 'title2'); +}); + test('rendered event', async () => { const onRendered = jest.fn(); diff --git a/src/tabs/index.js b/src/tabs/index.js index 9765c0e2f..d52d35eea 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -299,7 +299,15 @@ export default createComponent({ this.$emit('scroll', params); }, - scrollToCurrentContent() { + // @exposed-api + scrollTo(name) { + this.$nextTick(() => { + this.setCurrentIndexByName(name); + this.scrollToCurrentContent(true); + }); + }, + + scrollToCurrentContent(immediate = false) { if (this.scrollspy) { const target = this.children[this.currentIndex]; const el = target?.$el; @@ -308,7 +316,7 @@ export default createComponent({ const to = getElementTop(el, this.scroller) - this.scrollOffset; this.lockScroll = true; - scrollTopTo(this.scroller, to, +this.duration, () => { + scrollTopTo(this.scroller, to, immediate ? 0 : +this.duration, () => { this.lockScroll = false; }); } diff --git a/types/tabs.d.ts b/types/tabs.d.ts index 57b8cad0a..1b9d9becd 100644 --- a/types/tabs.d.ts +++ b/types/tabs.d.ts @@ -2,4 +2,6 @@ import { VanComponent } from './component'; export class Tabs extends VanComponent { resize(): void; + + scrollTo(name: string | number): void; } From 6a3179d4344f99a3d62d72a97c77c77f43bd1950 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2020 22:52:20 +0800 Subject: [PATCH 02/51] build(deps): bump lodash in /packages/vant-waterfall (#6803) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vant-waterfall/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vant-waterfall/yarn.lock b/packages/vant-waterfall/yarn.lock index dea18f849..5ffaa03d1 100644 --- a/packages/vant-waterfall/yarn.lock +++ b/packages/vant-waterfall/yarn.lock @@ -1609,9 +1609,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.13: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== loose-envify@^1.0.0: version "1.4.0" From 942ffd37d1ebaa1e1832aaf29339e44dbf4f7154 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2020 22:52:30 +0800 Subject: [PATCH 03/51] build(deps): bump lodash in /packages/vant-eslint-config (#6802) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vant-eslint-config/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vant-eslint-config/yarn.lock b/packages/vant-eslint-config/yarn.lock index 9e72d478c..475e583d1 100644 --- a/packages/vant-eslint-config/yarn.lock +++ b/packages/vant-eslint-config/yarn.lock @@ -813,9 +813,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.14, lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== mimic-fn@^2.1.0: version "2.1.0" From 5e0c7c8d47b752dee03b4dcba5550a32efb490da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2020 22:52:43 +0800 Subject: [PATCH 04/51] build(deps): bump lodash in /packages/vant-stylelint-config (#6801) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vant-stylelint-config/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vant-stylelint-config/yarn.lock b/packages/vant-stylelint-config/yarn.lock index 037f17894..88d8f4c77 100644 --- a/packages/vant-stylelint-config/yarn.lock +++ b/packages/vant-stylelint-config/yarn.lock @@ -1270,9 +1270,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== log-symbols@^2.0.0, log-symbols@^2.2.0: version "2.2.0" From aed8cd1ff213f493f6e561ec737b46f424010788 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 16 Jul 2020 22:56:20 +0800 Subject: [PATCH 05/51] fix(NumberKeyboard): flex not work on legacy safari (#6804) --- src/number-keyboard/Key.js | 7 +- src/number-keyboard/index.less | 3 - .../test/__snapshots__/demo.spec.js.snap | 316 +++++++++---- .../test/__snapshots__/index.spec.js.snap | 414 +++++++++++++----- .../test/__snapshots__/demo.spec.js.snap | 52 ++- 5 files changed, 578 insertions(+), 214 deletions(-) diff --git a/src/number-keyboard/Key.js b/src/number-keyboard/Key.js index 158aa0a57..858af2257 100644 --- a/src/number-keyboard/Key.js +++ b/src/number-keyboard/Key.js @@ -78,8 +78,9 @@ export default createComponent({ render() { return (
- +
); }, diff --git a/src/number-keyboard/index.less b/src/number-keyboard/index.less index da0cb56aa..a6dcb5805 100644 --- a/src/number-keyboard/index.less +++ b/src/number-keyboard/index.less @@ -79,13 +79,10 @@ display: flex; align-items: center; justify-content: center; - width: 100%; height: @number-keyboard-key-height; - padding: 0; font-size: @number-keyboard-key-font-size; line-height: 1.5; background-color: @white; - border: none; border-radius: @border-radius-lg; cursor: pointer; diff --git a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap index a420dbc39..8de8b1efe 100644 --- a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap +++ b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap @@ -41,45 +41,95 @@ exports[`renders demo correctly 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
0
+
+
+
-
+
+
@@ -87,20 +137,44 @@ exports[`renders demo correctly 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -110,66 +184,142 @@ exports[`renders demo correctly 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/number-keyboard/test/__snapshots__/index.spec.js.snap b/src/number-keyboard/test/__snapshots__/index.spec.js.snap index 912ecac3d..928a45c13 100644 --- a/src/number-keyboard/test/__snapshots__/index.spec.js.snap +++ b/src/number-keyboard/test/__snapshots__/index.spec.js.snap @@ -4,20 +4,44 @@ exports[`extra-key slot 1`] = ` @@ -27,22 +51,46 @@ exports[`focus on key 1`] = ` @@ -52,22 +100,46 @@ exports[`focus on key 2`] = ` @@ -77,22 +149,46 @@ exports[`move and blur key 1`] = ` @@ -102,22 +198,46 @@ exports[`move and blur key 2`] = ` @@ -127,22 +247,46 @@ exports[`move and blur key 3`] = ` @@ -155,22 +299,46 @@ exports[`render title 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
0
+
+
+
-
+
+
@@ -181,22 +349,46 @@ exports[`title-left slot 1`] = `
Custom Title Left
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
0
+
+
+
-
+
+
diff --git a/src/password-input/test/__snapshots__/demo.spec.js.snap b/src/password-input/test/__snapshots__/demo.spec.js.snap index 52ca0fd65..ca92591da 100644 --- a/src/password-input/test/__snapshots__/demo.spec.js.snap +++ b/src/password-input/test/__snapshots__/demo.spec.js.snap @@ -19,22 +19,46 @@ exports[`renders demo correctly 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
0
+
+
+
-
+
+
From 19e0d0df0e52cb9b683aef1f7f09d9c4ae425b97 Mon Sep 17 00:00:00 2001 From: liuhaihong Date: Fri, 17 Jul 2020 15:37:00 +0800 Subject: [PATCH 06/51] feat(Sku): add tel mobile message value formatter --- src/sku/components/SkuMessages.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sku/components/SkuMessages.js b/src/sku/components/SkuMessages.js index 7c50eda87..9abffcdd4 100644 --- a/src/sku/components/SkuMessages.js +++ b/src/sku/components/SkuMessages.js @@ -112,6 +112,16 @@ export default createComponent({ } }, + getFormatter(message) { + return function formatter(value) { + if (message.type === 'mobile' || message.type === 'tel') { + return value.replace(/\s/g, '').replace(/[\u202c|\u202d]/g, ''); + } + + return value; + }; + }, + genMessage(message, index) { if (message.type === 'image') { return ( @@ -157,6 +167,7 @@ export default createComponent({ required={String(message.required) === '1'} placeholder={this.getPlaceholder(message)} type={this.getType(message)} + formatter={this.getFormatter(message)} /> ); }, From 5cce17ab4ba8c894c2004d7f7d83d5b920348b30 Mon Sep 17 00:00:00 2001 From: liuhaihong Date: Fri, 17 Jul 2020 16:34:45 +0800 Subject: [PATCH 07/51] feat(Sku): complete the notes --- src/sku/components/SkuMessages.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sku/components/SkuMessages.js b/src/sku/components/SkuMessages.js index 9abffcdd4..fea96e6f4 100644 --- a/src/sku/components/SkuMessages.js +++ b/src/sku/components/SkuMessages.js @@ -111,7 +111,11 @@ export default createComponent({ } } }, - + /** + * The phone number copied from IOS mobile phone address book + * will add spaces and invisible Unicode characters + * which cannot pass the /^\d+$/ verification + */ getFormatter(message) { return function formatter(value) { if (message.type === 'mobile' || message.type === 'tel') { From b1460ce42ebd269580c2cce31f40eeb36e7e8999 Mon Sep 17 00:00:00 2001 From: liuhaihong Date: Fri, 17 Jul 2020 18:27:27 +0800 Subject: [PATCH 08/51] feat(Sku): add sku message formatter test --- src/sku/components/SkuMessages.js | 3 ++- src/sku/test/index.spec.js | 43 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/sku/components/SkuMessages.js b/src/sku/components/SkuMessages.js index fea96e6f4..de63f77fd 100644 --- a/src/sku/components/SkuMessages.js +++ b/src/sku/components/SkuMessages.js @@ -115,11 +115,12 @@ export default createComponent({ * The phone number copied from IOS mobile phone address book * will add spaces and invisible Unicode characters * which cannot pass the /^\d+$/ verification + * so keep numbers and dots */ getFormatter(message) { return function formatter(value) { if (message.type === 'mobile' || message.type === 'tel') { - return value.replace(/\s/g, '').replace(/[\u202c|\u202d]/g, ''); + return value.replace(/[^\d.]/g, ''); } return value; diff --git a/src/sku/test/index.spec.js b/src/sku/test/index.spec.js index 01efb6f04..9822dde0b 100644 --- a/src/sku/test/index.spec.js +++ b/src/sku/test/index.spec.js @@ -32,6 +32,49 @@ test('resetSelectedSku method', () => { expect(wrapper.emitted('buy-clicked').length).toEqual(1); }); +test('message formatter', () => { + const skuData = getSkuData(); + + skuData.sku.messages = skuData.sku.messages.filter( + message => message.type === 'tel' + ); + + const wrapper = mount(Sku, { + propsData: { + value: true, + initialSku, + sku: skuData.sku, + quota: skuData.quota, + goods: skuData.goods_info, + goodsId: skuData.goods_id, + quotaUsed: skuData.quota_used, + hideStock: skuData.sku.hide_stock, + startSaleNum: skuData.start_sale_num, + }, + }); + + const input = wrapper.find('input'); + const correctValue = '15000000000'; + + // \u202c + input.element.value = '15000000000‬'; + input.trigger('input'); + + expect(input.element.value).toEqual(correctValue); + + // \u0020 + input.element.value = '150 0000 0000'; + input.trigger('input'); + + expect(input.element.value).toEqual(correctValue); + + // /[a-zA-z]/ + input.element.value = 'a-zA-z'; + input.trigger('input'); + + expect(input.element.value).toEqual(''); +}); + test('stringToDate', () => { expect(dateToString(stringToDate(''))).toEqual(''); expect(dateToString(stringToDate('2020-07-01'))).toEqual('2020-07-01'); From 6c744d75311b0050ce1d79fc1d062e4d6eebdcdf Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 18 Jul 2020 17:36:37 +0800 Subject: [PATCH 09/51] feat(Uploader): add preview-options prop (#6810) --- src/uploader/README.md | 1 + src/uploader/README.zh-CN.md | 1 + src/uploader/index.js | 4 +++- src/uploader/test/index.spec.js | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/uploader/README.md b/src/uploader/README.md index 62271d6d2..6681badd0 100644 --- a/src/uploader/README.md +++ b/src/uploader/README.md @@ -203,6 +203,7 @@ Use `disabled` prop to disable uploader. | preview-size | Size of preview image | _number \| string_ | `80px` | | preview-image `v2.1.5` | Whether to show image preview | _boolean_ | `true` | | preview-full-image | Whethe to show full screen image preview when click image | _boolean_ | `true` | +| preview-options `v2.9.3` | Options of full screen image preview,see [ImagePreview](#/en-US/image-preview) | _object_ | - | | multiple | Whether to enable multiple selection pictures | _boolean_ | `false` | | disabled | Whether to disabled the upload | _boolean_ | `false` | | deletable `v2.2.12` | Whether to show delete icon | _boolean_ | `true` | diff --git a/src/uploader/README.zh-CN.md b/src/uploader/README.zh-CN.md index fa14d0286..45d33af9e 100644 --- a/src/uploader/README.zh-CN.md +++ b/src/uploader/README.zh-CN.md @@ -227,6 +227,7 @@ export default { | preview-size | 预览图和上传区域的尺寸,默认单位为`px` | _number \| string_ | `80px` | | preview-image | 是否在上传完成后展示预览图 | _boolean_ | `true` | | preview-full-image `v2.1.5` | 是否在点击预览图后展示全屏图片预览 | _boolean_ | `true` | +| preview-options `v2.9.3` | 全屏图片预览的配置项,可选值见 [ImagePreview](#/zh-CN/image-preview) | _object_ | - | | multiple | 是否开启图片多选,部分安卓机型不支持 | _boolean_ | `false` | | disabled | 是否禁用文件上传 | _boolean_ | `false` | | deletable `v2.2.12` | 是否展示删除按钮 | _boolean_ | `true` | diff --git a/src/uploader/index.js b/src/uploader/index.js index 1ede615a5..da26fbb6b 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -30,6 +30,7 @@ export default createComponent({ beforeRead: Function, beforeDelete: Function, previewSize: [Number, String], + previewOptions: Object, name: { type: [Number, String], default: '', @@ -256,11 +257,12 @@ export default createComponent({ this.imagePreview = ImagePreview({ images: imageContents, - closeOnPopstate: true, startPosition: imageFiles.indexOf(item), + closeOnPopstate: true, onClose: () => { this.$emit('close-preview'); }, + ...this.previewOptions, }); }, diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 5aa5c894d..76ab58f30 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -406,6 +406,23 @@ test('click to preview image', async () => { expect(images.length).toEqual(1); }); +test('preview-options prop', async () => { + const wrapper = mount(Uploader, { + propsData: { + fileList: [{ url: IMAGE }], + previewOptions: { + closeable: true, + }, + }, + }); + + wrapper.find('.van-image').trigger('click'); + await later(); + + const closeIcon = document.querySelectorAll('.van-image-preview__close-icon'); + expect(closeIcon.length).toEqual(1); +}); + test('closeImagePreview method', () => { const close = jest.fn(); const wrapper = mount(Uploader, { From 3c223ba7f7c8965a9df223e989aea0850d0d8847 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 18 Jul 2020 17:49:17 +0800 Subject: [PATCH 10/51] fix(ImagePreview): image overflow in some cases (#6811) --- src/image-preview/index.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/image-preview/index.less b/src/image-preview/index.less index 0de2d1fd8..adf1433d2 100644 --- a/src/image-preview/index.less +++ b/src/image-preview/index.less @@ -14,6 +14,7 @@ display: flex; align-items: center; justify-content: center; + overflow: hidden; } } From e541260ef3ff3b98eec8bd7f1c609470cae552b6 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 18 Jul 2020 18:53:40 +0800 Subject: [PATCH 11/51] fix(Calendar): rendering fails in some cases (#6812) --- src/calendar/index.js | 7 +++---- src/utils/dom/scroll.ts | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/calendar/index.js b/src/calendar/index.js index 591e64a2c..7b70a65c1 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -244,14 +244,13 @@ export default createComponent({ onScroll() { const { body, months } = this.$refs; const top = getScrollTop(body); - const bottom = top + this.bodyHeight; const heights = months.map((item) => item.getHeight()); const heightSum = heights.reduce((a, b) => a + b, 0); // iOS scroll bounce may exceed the range - /* istanbul ignore next */ - if (top < 0 || (bottom > heightSum && top > 0)) { - return; + let bottom = top + this.bodyHeight; + if (bottom > heightSum && top > 0) { + bottom = heightSum; } let height = 0; diff --git a/src/utils/dom/scroll.ts b/src/utils/dom/scroll.ts index aa3f7f571..6d7457f74 100644 --- a/src/utils/dom/scroll.ts +++ b/src/utils/dom/scroll.ts @@ -40,7 +40,10 @@ export function getScroller(el: HTMLElement, root: ScrollElement = window) { } export function getScrollTop(el: ScrollElement): number { - return 'scrollTop' in el ? el.scrollTop : el.pageYOffset; + const top = 'scrollTop' in el ? el.scrollTop : el.pageYOffset; + + // iOS scroll bounce cause minus scrollTop + return Math.max(top, 0); } export function setScrollTop(el: ScrollElement, value: number) { From f28b624d9e9b32b97249f8dd3de80858af0d184b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2020 12:14:14 +0800 Subject: [PATCH 12/51] build(deps): bump lodash from 4.17.15 to 4.17.19 in /packages/vant-cli (#6813) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vant-cli/yarn.lock | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vant-cli/yarn.lock b/packages/vant-cli/yarn.lock index 893bcf088..90a993161 100644 --- a/packages/vant-cli/yarn.lock +++ b/packages/vant-cli/yarn.lock @@ -7696,11 +7696,16 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" -lodash@4.17.15, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: +lodash@4.17.15: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== + log-symbols@^2.0.0, log-symbols@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" From cda36102333d739bb578e30cfc106b89b572e485 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2020 12:14:58 +0800 Subject: [PATCH 13/51] docs: add vant-react link (#6814) --- README.md | 1 + README.zh-CN.md | 1 + docs/markdown/home.en-US.md | 1 + docs/markdown/home.zh-CN.md | 1 + 4 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 766f5857c..bb73583e3 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Modern browsers and Android 4.0+, iOS 8.0+. | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection | | [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | diff --git a/README.zh-CN.md b/README.zh-CN.md index e3804faf1..f39e36e19 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -90,6 +90,7 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手 | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 | | [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React 版(由社区维护) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | diff --git a/docs/markdown/home.en-US.md b/docs/markdown/home.en-US.md index 765d18823..3ee90ba6c 100644 --- a/docs/markdown/home.en-US.md +++ b/docs/markdown/home.en-US.md @@ -35,6 +35,7 @@ Modern browsers and Android 4.0+, iOS 8.0+. | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection | | [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | diff --git a/docs/markdown/home.zh-CN.md b/docs/markdown/home.zh-CN.md index 2e25343f6..ad310a9d0 100644 --- a/docs/markdown/home.zh-CN.md +++ b/docs/markdown/home.zh-CN.md @@ -51,6 +51,7 @@ | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 | | [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React 版(由社区维护) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | From 839f65e533d0318806afc8d453bdd56fc15ed093 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2020 15:40:39 +0800 Subject: [PATCH 14/51] feat: Sticky/Picker support vw unit (#6816) --- src/area/README.md | 2 +- src/area/README.zh-CN.md | 2 +- src/datetime-picker/README.md | 2 +- src/datetime-picker/README.zh-CN.md | 2 +- src/picker/README.md | 2 +- src/picker/README.zh-CN.md | 2 +- src/sticky/README.md | 2 +- src/sticky/README.zh-CN.md | 2 +- .../test/__snapshots__/index.spec.js.snap | 8 ++++++++ src/sticky/test/index.spec.js | 16 ++++++++++++++++ src/tab/README.md | 2 +- src/tab/README.zh-CN.md | 2 +- src/utils/format/unit.ts | 17 ++++++++++++++--- 13 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/area/README.md b/src/area/README.md index 9c10fdb57..4a60b074b 100644 --- a/src/area/README.md +++ b/src/area/README.md @@ -64,7 +64,7 @@ To have a selected value,simply pass the `code` of target area to `value` prop | area-list | Area list data | _object_ | - | | columns-placeholder `v2.2.5` | Placeholder of columns | _string[]_ | `[]` | | loading | Whether to show loading prompt | _boolean_ | `false` | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | columns-num | Level of picker | _number \| string_ | `3` | | visible-item-count | Count of visible columns | _number \| string_ | `5` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | diff --git a/src/area/README.zh-CN.md b/src/area/README.zh-CN.md index 71f8367e5..0de44a86a 100644 --- a/src/area/README.zh-CN.md +++ b/src/area/README.zh-CN.md @@ -64,7 +64,7 @@ Vue.use(Area); | area-list | 省市区数据,格式见下方 | _object_ | - | | columns-placeholder `v2.2.5` | 列占位提示文字 | _string[]_ | `[]` | | loading | 是否显示加载状态 | _boolean_ | `false` | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | columns-num | 显示列数,3-省市区,2-省市,1-省 | _number \| string_ | `3` | | visible-item-count | 可见的选项个数 | _number \| string_ | `5` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | diff --git a/src/datetime-picker/README.md b/src/datetime-picker/README.md index bd27f1e51..3293d5e20 100644 --- a/src/datetime-picker/README.md +++ b/src/datetime-picker/README.md @@ -259,7 +259,7 @@ export default { | filter | Option filter | _(type, vals) => vals_ | - | | formatter | Option text formatter | _(type, val) => val_ | - | | columns-order `v2.9.2` | Array for ordering columns, where item can be set to
`year`, `month`, `day`, `hour` and `minute` | _string[]_ | - | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | visible-item-count | Count of visible columns | _number \| string_ | `5` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | diff --git a/src/datetime-picker/README.zh-CN.md b/src/datetime-picker/README.zh-CN.md index 22f7d54f8..f7a39741a 100644 --- a/src/datetime-picker/README.zh-CN.md +++ b/src/datetime-picker/README.zh-CN.md @@ -268,7 +268,7 @@ export default { | filter | 选项过滤函数 | _(type, vals) => vals_ | - | | formatter | 选项格式化函数 | _(type, val) => val_ | - | | columns-order `v2.9.2` | 自定义列排序数组, 子项可选值为
`year`、`month`、`day`、`hour`、`minute` | _string[]_ | - | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | visible-item-count | 可见的选项个数 | _number \| string_ | `5` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | diff --git a/src/picker/README.md b/src/picker/README.md index a2654b023..d6da938eb 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -252,7 +252,7 @@ export default { | show-toolbar | Whether to show toolbar | _boolean_ | `false` | | allow-html `v2.1.8` | Whether to allow HTML in option text | _boolean_ | `true` | | default-index | Default value index of single column picker | _number \| string_ | `0` | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | visible-item-count | Count of visible columns | _number \| string_ | `5` | | swipe-duration `v2.2.10` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 9d0fdad33..8ba6d01a5 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -275,7 +275,7 @@ export default { | show-toolbar | 是否显示顶部栏 | _boolean_ | `false` | | allow-html `v2.1.8` | 是否允许选项内容中渲染 HTML | _boolean_ | `true` | | default-index | 单列选择时,默认选中项的索引 | _number \| string_ | `0` | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | visible-item-count | 可见的选项个数 | _number \| string_ | `5` | | swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位 `ms` | _number \| string_ | `1000` | diff --git a/src/sticky/README.md b/src/sticky/README.md index fcb804a05..17ce81ccd 100644 --- a/src/sticky/README.md +++ b/src/sticky/README.md @@ -56,7 +56,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| offset-top `v2.8.7` | Offset top, supports `px` ans `rem` unit, default `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | Offset top, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `0` | | z-index | z-index when sticky | _number \| string_ | `99` | | container | Container DOM | _Element_ | - | diff --git a/src/sticky/README.zh-CN.md b/src/sticky/README.zh-CN.md index e26650d6f..696d07055 100644 --- a/src/sticky/README.zh-CN.md +++ b/src/sticky/README.zh-CN.md @@ -66,7 +66,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `0` | | z-index | 吸顶时的 z-index | _number \| string_ | `99` | | container | 容器对应的 HTML 节点 | _Element_ | - | diff --git a/src/sticky/test/__snapshots__/index.spec.js.snap b/src/sticky/test/__snapshots__/index.spec.js.snap index be6374a1d..fbfac5d00 100644 --- a/src/sticky/test/__snapshots__/index.spec.js.snap +++ b/src/sticky/test/__snapshots__/index.spec.js.snap @@ -36,6 +36,14 @@ exports[`offset-top with rem unit 1`] = ` `; +exports[`offset-top with vw unit 1`] = ` +
+
+ Content +
+
+`; + exports[`sticky to top 1`] = `
diff --git a/src/sticky/test/index.spec.js b/src/sticky/test/index.spec.js index 7fb2de770..16c6b2c2f 100644 --- a/src/sticky/test/index.spec.js +++ b/src/sticky/test/index.spec.js @@ -63,6 +63,22 @@ test('offset-top with rem unit', () => { window.getComputedStyle = originGetComputedStyle; }); +test('offset-top with vw unit', () => { + window.innerWidth = 300; + + const wrapper = mount({ + template: ` + + Content + + `, + }); + + mockScrollTop(100); + expect(wrapper).toMatchSnapshot(); + mockScrollTop(0); +}); + test('should not trigger scroll event when hidden', () => { const scroll = jest.fn(); mount({ diff --git a/src/tab/README.md b/src/tab/README.md index 009dc2637..567c562ab 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -205,7 +205,7 @@ In scrollspy mode, the list of content will be tiled | swipeable | Whether to switch tabs with swipe gestrue in the content | _boolean_ | `false` | | lazy-render | Whether to enable tab content lazy render | _boolean_ | `true` | | scrollspy `v2.3.0` | Whether to use scrollspy mode | _boolean_ | `false` | -| offset-top `v2.8.7` | Sticky offset top , supports `px` ans `rem` unit, default `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | Sticky offset top , supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `0` | | swipe-threshold | Set swipe tabs threshold | _number \| string_ | `4` | - | | title-active-color | Title active color | _string_ | - | | title-inactive-color | Title inactive color | _string_ | - | diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index 757ea4aeb..1c62490e3 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -209,7 +209,7 @@ export default { | swipeable | 是否开启手势滑动切换 | _boolean_ | `false` | | lazy-render | 是否开启延迟渲染(首次切换到标签时才触发内容渲染) | _boolean_ | `true` | | scrollspy `v2.3.0` | 是否开启滚动导航 | _boolean_ | `false` | -| offset-top `v2.8.7` | 粘性定位布局下与顶部的最小距离,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | 粘性定位布局下与顶部的最小距离,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `0` | | swipe-threshold | 滚动阈值,标签数量超过阈值时开始横向滚动 | _number \| string_ | `4` | | title-active-color | 标题选中态颜色 | _string_ | - | | title-inactive-color | 标题默认态颜色 | _string_ | - | diff --git a/src/utils/format/unit.ts b/src/utils/format/unit.ts index b50167e7c..9b2de011d 100644 --- a/src/utils/format/unit.ts +++ b/src/utils/format/unit.ts @@ -1,4 +1,4 @@ -import { isDef } from '..'; +import { isDef, inBrowser } from '..'; import { isNumeric } from '../validate/number'; export function addUnit(value?: string | number): string | undefined { @@ -30,13 +30,24 @@ function convertRem(value: string) { return +value * getRootFontSize(); } +function convertVw(value: string) { + value = value.replace(/vw/g, ''); + return (+value * window.innerWidth) / 100; +} + export function unitToPx(value: string | number): number { if (typeof value === 'number') { return value; } - if (value.indexOf('rem') !== -1) { - return convertRem(value); + if (inBrowser) { + if (value.indexOf('rem') !== -1) { + return convertRem(value); + } + + if (value.indexOf('vw') !== -1) { + return convertVw(value); + } } return parseFloat(value); From 9903230cb6d3e99279521d8641a84739e9234707 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2020 16:57:27 +0800 Subject: [PATCH 15/51] feat(Tabs): add before-change prop (#6817) --- src/tab/README.md | 39 ++++++++++++-- src/tab/README.zh-CN.md | 54 ++++++++++++++++---- src/tab/demo/index.vue | 20 ++++++++ src/tab/test/__snapshots__/demo.spec.js.snap | 27 ++++++++++ src/tab/test/index.spec.js | 48 +++++++++++++++++ src/tabs/index.js | 27 ++++++++-- 6 files changed, 196 insertions(+), 19 deletions(-) diff --git a/src/tab/README.md b/src/tab/README.md index 567c562ab..714912b34 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -126,7 +126,7 @@ export default { ### Sticky -In sticky mode, the tab will be fixed to top when scroll to top +In sticky mode, the tab will be fixed to top when scroll to top. ```html @@ -138,7 +138,7 @@ In sticky mode, the tab will be fixed to top when scroll to top ### Custom title -Use title slot to custom tab title +Use title slot to custom tab title. ```html @@ -151,7 +151,7 @@ Use title slot to custom tab title ### Switch Animation -Use `animated` props to change tabs with animation +Use `animated` props to change tabs with animation. ```html @@ -163,7 +163,7 @@ Use `animated` props to change tabs with animation ### Swipeable -In swipeable mode, you can switch tabs with swipe gestrue in the content +In swipeable mode, you can switch tabs with swipe gestrue in the content. ```html @@ -175,7 +175,7 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content ### Scrollspy -In scrollspy mode, the list of content will be tiled +In scrollspy mode, the list of content will be tiled. ```html @@ -185,6 +185,34 @@ In scrollspy mode, the list of content will be tiled ``` +### Before Change + +```html + + + content {{ index }} + + +``` + +```js +export default { + methods: { + beforeChange(index) { + // prevent change + if (index === 1) { + return false; + } + + // async + return new Promise((resolve) => { + resolve(index !== 3); + }); + }, + }, +}; +``` + ## API ### Tabs Props @@ -209,6 +237,7 @@ In scrollspy mode, the list of content will be tiled | swipe-threshold | Set swipe tabs threshold | _number \| string_ | `4` | - | | title-active-color | Title active color | _string_ | - | | title-inactive-color | Title inactive color | _string_ | - | +| before-change `v2.9.3` | Callback function before changing tabs,return `false` to prevent change,support return Promise | _(name) => boolean \| Promise_ | - | ### Tab Props diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index 1c62490e3..a2ba20c5b 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -14,7 +14,7 @@ Vue.use(Tabs); ### 基础用法 -通过`v-model`绑定当前激活标签对应的索引值,默认情况下启用第一个标签 +通过 `v-model` 绑定当前激活标签对应的索引值,默认情况下启用第一个标签。 ```html @@ -37,7 +37,7 @@ export default { ### 通过名称匹配 -在标签指定`name`属性的情况下,`v-model`的值为当前标签的`name`(此时无法通过索引值来匹配标签) +在标签指定 `name` 属性的情况下,`v-model` 的值为当前标签的 `name`(此时无法通过索引值来匹配标签)。 ```html @@ -59,7 +59,7 @@ export default { ### 标签栏滚动 -标签数量超过 4 个时,标签栏可以在水平方向上滚动,切换时会自动将当前标签居中 +标签数量超过 4 个时,标签栏可以在水平方向上滚动,切换时会自动将当前标签居中。 ```html @@ -71,7 +71,7 @@ export default { ### 禁用标签 -设置`disabled`属性即可禁用标签。如果需要监听禁用标签的点击事件,可以在`van-tabs`上监听`disabled`事件 +设置 `disabled` 属性即可禁用标签,如果需要监听禁用标签的点击事件,可以在 `van-tabs` 上监听`disabled` 事件。 ```html @@ -95,7 +95,7 @@ export default { ### 样式风格 -`Tab`支持两种样式风格:`line`和`card`,默认为`line`样式,可以通过`type`属性修改样式风格 +`Tab` 支持两种样式风格:`line` 和`card`,默认为 `line` 样式,可以通过 `type` 属性切换样式风格。 ```html @@ -107,7 +107,7 @@ export default { ### 点击事件 -可以在`van-tabs`上绑定`click`事件,事件传参为标签对应的索引和标题 +可以在 `van-tabs` 上绑定 `click` 事件,事件传参为标签对应的标识符和标题。 ```html @@ -130,7 +130,7 @@ export default { ### 粘性布局 -通过`sticky`属性可以开启粘性布局,粘性布局下,当 Tab 滚动到顶部时会自动吸顶 +通过 `sticky` 属性可以开启粘性布局,粘性布局下,标签页滚动到顶部时会自动吸顶。 ```html @@ -142,7 +142,7 @@ export default { ### 自定义标签 -通过 title 插槽可以自定义标签内容 +通过 `title` 插槽可以自定义标签内容。 ```html @@ -155,7 +155,7 @@ export default { ### 切换动画 -通过`animated`属性可以开启切换标签内容时的转场动画 +通过 `animated` 属性可以开启切换标签内容时的转场动画。 ```html @@ -167,7 +167,7 @@ export default { ### 滑动切换 -通过`swipeable`属性可以开启滑动切换标签页 +通过 `swipeable` 属性可以开启滑动切换标签页。 ```html @@ -179,7 +179,7 @@ export default { ### 滚动导航 -通过`scrollspy`属性可以开启滚动导航模式,该模式下,内容将会平铺展示 +通过 `scrollspy` 属性可以开启滚动导航模式,该模式下,内容将会平铺展示。 ```html @@ -189,6 +189,37 @@ export default { ``` +### 异步切换 + +通过 `before-change` 属性可以在切换标签前执行特定的逻辑。 + +```html + + + 内容 {{ index }} + + +``` + +```js +export default { + methods: { + beforeChange(index) { + // 返回 false 表示阻止此次切换 + if (index === 1) { + return false; + } + + // 返回 Promise 来执行异步逻辑 + return new Promise((resolve) => { + // 在 resolve 函数中返回 true 或 false + resolve(index !== 3); + }); + }, + }, +}; +``` + ## API ### Tabs Props @@ -213,6 +244,7 @@ export default { | swipe-threshold | 滚动阈值,标签数量超过阈值时开始横向滚动 | _number \| string_ | `4` | | title-active-color | 标题选中态颜色 | _string_ | - | | title-inactive-color | 标题默认态颜色 | _string_ | - | +| before-change `v2.9.3` | 切换标签前的回调函数,返回 `false` 可阻止切换,支持返回 Promise | _(name) => boolean \| Promise_ | - | ### Tab Props diff --git a/src/tab/demo/index.vue b/src/tab/demo/index.vue index 6a72eea9e..9d24cac71 100644 --- a/src/tab/demo/index.vue +++ b/src/tab/demo/index.vue @@ -93,6 +93,14 @@ + + + + + {{ t('content') }} {{ index }} + + + @@ -112,6 +120,7 @@ export default { title10: '滚动导航', disabled: ' 已被禁用', matchByName: '通过名称匹配', + beforeChange: '异步切换', }, 'en-US': { tab: 'Tab ', @@ -127,6 +136,7 @@ export default { title10: 'Scrollspy', disabled: ' is disabled', matchByName: 'Match By Name', + beforeChange: 'Before Change', }, }, @@ -146,6 +156,16 @@ export default { onClick(index, title) { this.$toast(title); }, + + beforeChange(name) { + if (name === 1) { + return false; + } + + return new Promise((resolve) => { + resolve(name !== 3); + }); + }, }, }; diff --git a/src/tab/test/__snapshots__/demo.spec.js.snap b/src/tab/test/__snapshots__/demo.spec.js.snap index e8b7e703a..7349ac11c 100644 --- a/src/tab/test/__snapshots__/demo.spec.js.snap +++ b/src/tab/test/__snapshots__/demo.spec.js.snap @@ -318,5 +318,32 @@ exports[`renders demo correctly 1`] = `
+
+
+
+
+ + + + +
+
+
+
+
+ 内容 1 +
+ + + +
+
+
`; diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index cf1b6ec39..9eb51fba5 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -362,3 +362,51 @@ test('should not trigger rendered event when disable lazy-render', async () => { await later(); expect(onRendered).toHaveBeenCalledTimes(0); }); + +test('before-change prop', async () => { + const onChange = jest.fn(); + const wrapper = mount({ + template: ` + + Text + Text + Text + Text + Text + + `, + methods: { + onChange, + beforeChange(name) { + switch (name) { + case 1: + return false; + case 2: + return true; + case 3: + return Promise.resolve(false); + case 4: + return Promise.resolve(true); + } + }, + }, + }); + + await later(); + + const tabs = wrapper.findAll('.van-tab'); + tabs.at(1).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(0); + + tabs.at(2).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(1); + expect(onChange).toHaveBeenLastCalledWith(2, 'title3'); + + tabs.at(3).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(1); + + tabs.at(4).trigger('click'); + await later(); + expect(onChange).toHaveBeenCalledTimes(2); + expect(onChange).toHaveBeenLastCalledWith(4, 'title5'); +}); diff --git a/src/tabs/index.js b/src/tabs/index.js index d52d35eea..476024b43 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -1,5 +1,5 @@ // Utils -import { createNamespace, isDef, addUnit } from '../utils'; +import { createNamespace, isDef, addUnit, isPromise } from '../utils'; import { scrollLeftTo, scrollTopTo } from './utils'; import { route } from '../utils/router'; import { isHidden } from '../utils/dom/style'; @@ -53,6 +53,7 @@ export default createComponent({ background: String, lineWidth: [Number, String], lineHeight: [Number, String], + beforeChange: Function, titleActiveColor: String, titleInactiveColor: String, type: { @@ -266,14 +267,34 @@ export default createComponent({ } }, + callBeforeChange(name, done) { + if (this.beforeChange) { + const returnVal = this.beforeChange(name); + + if (isPromise(returnVal)) { + returnVal.then((value) => { + if (value) { + done(); + } + }); + } else if (returnVal) { + done(); + } + } else { + done(); + } + }, + // emit event when clicked onClick(item, index) { const { title, disabled, computedName } = this.children[index]; if (disabled) { this.$emit('disabled', computedName, title); } else { - this.setCurrentIndex(index); - this.scrollToCurrentContent(); + this.callBeforeChange(computedName, () => { + this.setCurrentIndex(index); + this.scrollToCurrentContent(); + }); this.$emit('click', computedName, title); route(item.$router, item); } From 08d5b3da6ac85250da544c05429a84f33a070db0 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 19 Jul 2020 17:03:19 +0800 Subject: [PATCH 16/51] chore: release 2.9.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 408c69b2b..2c2b58f41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vant", - "version": "2.9.2", + "version": "2.9.3", "description": "Mobile UI Components built on Vue", "main": "lib/index.js", "module": "es/index.js", From 96f3e90ff3fa93d2f47795584ec2f2165e593eab Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 19 Jul 2020 17:15:28 +0800 Subject: [PATCH 17/51] docs(changelog): 2.9.3 --- docs/markdown/changelog.en-US.md | 20 ++++++++++++++++++++ docs/markdown/changelog.zh-CN.md | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 24771359a..e7d663eff 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -10,6 +10,26 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/). - Minor version:released every one to two months, including backwards compatible features. - Major version:including breaking changes and new features. +### [v2.9.3](https://github.com/youzan/vant/compare/v2.9.2...v2.9.3) + +`2020-07-19` + +**Feature** + +- Tabs: add before-change prop [#6817](https://github.com/youzan/vant/issues/6817) +- Sticky: offset-top support vw unit [#6816](https://github.com/youzan/vant/issues/6816) +- Picker: item-height support vw unit [#6816](https://github.com/youzan/vant/issues/6816) +- Sku: add mobile message value formatter [19e0d0](https://github.com/youzan/vant/commit/19e0d0df0e52cb9b683aef1f7f09d9c4ae425b97) +- Tab: add scrollTo method [#6800](https://github.com/youzan/vant/issues/6800) +- Uploader: add preview-options prop [#6810](https://github.com/youzan/vant/issues/6810) + +**Bug Fixes** + +- Calendar: rendering fails in some cases [#6812](https://github.com/youzan/vant/issues/6812) +- ImagePreview: image overflow in some cases [#6811](https://github.com/youzan/vant/issues/6811) +- NumberKeyboard: flex not work on legacy safari [#6804](https://github.com/youzan/vant/issues/6804) +- Slider: missing transition in vertical mode [#6786](https://github.com/youzan/vant/issues/6786) + ### [v2.9.2](https://github.com/youzan/vant/compare/v2.9.1...v2.9.2) `2020-07-14` diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 419bc9209..aafe9275b 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -10,6 +10,26 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 - 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。 - 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。 +### [v2.9.3](https://github.com/youzan/vant/compare/v2.9.2...v2.9.3) + +`2020-07-19` + +**Feature** + +- Tabs: 新增 before-change 属性,用于在切换标签前执行校验逻辑 [#6817](https://github.com/youzan/vant/issues/6817) +- Sticky: offset-top 属性支持传入 vw 单位 [#6816](https://github.com/youzan/vant/issues/6816) +- Picker: item-height 属性支持传入 vw 单位 [#6816](https://github.com/youzan/vant/issues/6816) +- Sku: 新增对手机号留言的格式化处理 [19e0d0](https://github.com/youzan/vant/commit/19e0d0df0e52cb9b683aef1f7f09d9c4ae425b97) +- Tab: 新增 scrollTo 方法,用于在滚动导航模式下滚动到特定位置 [#6800](https://github.com/youzan/vant/issues/6800) +- Uploader: 新增 preview-options 属性,用于自定义全屏图片预览的配置项 [#6810](https://github.com/youzan/vant/issues/6810) + +**Bug Fixes** + +- Calendar: 修复在个别情况下内容渲染失败的问题 [#6812](https://github.com/youzan/vant/issues/6812) +- ImagePreview: 修复在个别情况下图片错位的问题 [#6811](https://github.com/youzan/vant/issues/6811) +- NumberKeyboard: 修复在旧版本 iOS 上按键内容不居中的问题 [#6804](https://github.com/youzan/vant/issues/6804) +- Slider: 修复垂直模式下滑动动画失效的问题 [#6786](https://github.com/youzan/vant/issues/6786) + ### [v2.9.2](https://github.com/youzan/vant/compare/v2.9.1...v2.9.2) `2020-07-14` From ebb964aed8baa151dc1e4aaadc36cb3aa020e24f Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 20 Jul 2020 22:41:26 +0800 Subject: [PATCH 18/51] fix(ImagePreview): fit orientationchange (#6825) * fix(ImagePreview): fit orientationchange * chore: remove log --- src/image-preview/ImagePreview.js | 1 + src/swipe/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/image-preview/ImagePreview.js b/src/image-preview/ImagePreview.js index 9c03d4e7c..0748d9727 100644 --- a/src/image-preview/ImagePreview.js +++ b/src/image-preview/ImagePreview.js @@ -20,6 +20,7 @@ export default createComponent({ }), BindEventMixin(function (bind) { bind(window, 'resize', this.resize, true); + bind(window, 'orientationchange', this.resize, true); }), ], diff --git a/src/swipe/index.js b/src/swipe/index.js index 95816beea..608289690 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -18,6 +18,7 @@ export default createComponent({ ParentMixin('vanSwipe'), BindEventMixin(function (bind, isBind) { bind(window, 'resize', this.resize, true); + bind(window, 'orientationchange', this.resize, true); bind(window, 'visibilitychange', this.onVisibilityChange); if (isBind) { From 2d9f5d858a68af054d8da01a5b2cd8dd30075f6d Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 21 Jul 2020 14:12:59 +0800 Subject: [PATCH 19/51] style(Picker): adjust default value of visible-item-count to 6 (#6827) --- src/area/README.md | 2 +- src/area/README.zh-CN.md | 2 +- src/area/test/__snapshots__/demo.spec.js.snap | 38 +++--- .../test/__snapshots__/index.spec.js.snap | 108 +++++++++--------- src/datetime-picker/README.md | 2 +- src/datetime-picker/README.zh-CN.md | 2 +- .../__snapshots__/date-picker.spec.js.snap | 28 ++--- .../datetime-picker.spec.js.snap | 8 +- .../test/__snapshots__/demo.spec.js.snap | 78 ++++++------- .../__snapshots__/time-picker.spec.js.snap | 32 +++--- src/picker/README.md | 2 +- src/picker/README.zh-CN.md | 2 +- src/picker/shared.ts | 2 +- .../test/__snapshots__/demo.spec.js.snap | 52 ++++----- .../test/__snapshots__/index.spec.js.snap | 30 ++--- 15 files changed, 194 insertions(+), 194 deletions(-) diff --git a/src/area/README.md b/src/area/README.md index 4a60b074b..f8494fa0b 100644 --- a/src/area/README.md +++ b/src/area/README.md @@ -66,7 +66,7 @@ To have a selected value,simply pass the `code` of target area to `value` prop | loading | Whether to show loading prompt | _boolean_ | `false` | | item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | columns-num | Level of picker | _number \| string_ | `3` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | | is-oversea-code `v2.1.4` | The method to validate oversea code | _() => boolean_ | - | diff --git a/src/area/README.zh-CN.md b/src/area/README.zh-CN.md index 0de44a86a..5e2691ffe 100644 --- a/src/area/README.zh-CN.md +++ b/src/area/README.zh-CN.md @@ -66,7 +66,7 @@ Vue.use(Area); | loading | 是否显示加载状态 | _boolean_ | `false` | | item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | columns-num | 显示列数,3-省市区,2-省市,1-省 | _number \| string_ | `3` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | | is-oversea-code `v2.1.4` | 根据`code`校验海外地址,海外地址会划分至单独的分类 | _() => boolean_ | - | diff --git a/src/area/test/__snapshots__/demo.spec.js.snap b/src/area/test/__snapshots__/demo.spec.js.snap index 1853af53c..984178494 100644 --- a/src/area/test/__snapshots__/demo.spec.js.snap +++ b/src/area/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -119,14 +119,14 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 北京市
-
    +
    • 东城区
    • @@ -177,7 +177,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -189,9 +189,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -300,7 +300,7 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 杭州市
    • @@ -337,7 +337,7 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 鹿城区
    • @@ -373,7 +373,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -385,9 +385,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -496,13 +496,13 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 北京市
-
+
@@ -514,9 +514,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 请选择
    • @@ -628,12 +628,12 @@ exports[`renders demo correctly 1`] = `
-
    +
      -
        +
          -
          +
          diff --git a/src/area/test/__snapshots__/index.spec.js.snap b/src/area/test/__snapshots__/index.spec.js.snap index 2db538023..e29ea9587 100644 --- a/src/area/test/__snapshots__/index.spec.js.snap +++ b/src/area/test/__snapshots__/index.spec.js.snap @@ -4,9 +4,9 @@ exports[`change option 1`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -16,7 +16,7 @@ exports[`change option 1`] = `
          -
            +
            • 北京市
            • @@ -26,7 +26,7 @@ exports[`change option 1`] = `
          -
            +
            • 东城区
            • @@ -35,7 +35,7 @@ exports[`change option 1`] = `
          -
          +
          @@ -46,9 +46,9 @@ exports[`change option 2`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -58,7 +58,7 @@ exports[`change option 2`] = `
          -
            +
            • 天津市
            • @@ -68,7 +68,7 @@ exports[`change option 2`] = `
          -
            +
            • 和平区
            • @@ -77,7 +77,7 @@ exports[`change option 2`] = `
          -
          +
          @@ -88,9 +88,9 @@ exports[`change option 3`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -100,7 +100,7 @@ exports[`change option 3`] = `
          -
            +
            • 天津市
            • @@ -110,7 +110,7 @@ exports[`change option 3`] = `
          -
            +
            • 和平区
            • @@ -119,7 +119,7 @@ exports[`change option 3`] = `
          -
          +
          @@ -130,9 +130,9 @@ exports[`columns-num prop 1`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -142,7 +142,7 @@ exports[`columns-num prop 1`] = `
          -
            +
            • 北京市
            • @@ -151,7 +151,7 @@ exports[`columns-num prop 1`] = `
          -
          +
          @@ -161,17 +161,17 @@ exports[`columns-num prop 1`] = ` exports[`columns-top、columns-bottom slot 1`] = `
          - Top
          + Top
          -
            +
              -
                +
                  -
                    +
                      -
                      +
                      Bottom @@ -182,9 +182,9 @@ exports[`reset method 1`] = `
                      -
                      +
                      -
                        +
                        • 北京市
                        • @@ -194,7 +194,7 @@ exports[`reset method 1`] = `
                      -
                        +
                        • 天津市
                        • @@ -204,13 +204,13 @@ exports[`reset method 1`] = `
                      -
                        +
                        • 蓟县
                      -
                      +
                      @@ -221,9 +221,9 @@ exports[`reset method 2`] = `
                      -
                      +
                      -
                        +
                        • 北京市
                        • @@ -233,7 +233,7 @@ exports[`reset method 2`] = `
                      -
                        +
                        • 北京市
                        • @@ -243,7 +243,7 @@ exports[`reset method 2`] = `
                      -
                        +
                        • 东城区
                        • @@ -252,7 +252,7 @@ exports[`reset method 2`] = `
                      -
                      +
                      @@ -263,17 +263,17 @@ exports[`title slot 1`] = `
                      Custom Title
                      -
                      +
                      -
                        +
                          -
                            +
                              -
                                +
                                  -
                                  +
                                  @@ -284,9 +284,9 @@ exports[`watch areaList & code 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -296,7 +296,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -306,7 +306,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -315,7 +315,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                  +
                                  @@ -326,9 +326,9 @@ exports[`watch areaList & code 2`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -338,7 +338,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -348,7 +348,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -357,7 +357,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                  +
                                  @@ -368,9 +368,9 @@ exports[`watch areaList & code 3`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -380,7 +380,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -390,7 +390,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -399,7 +399,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/README.md b/src/datetime-picker/README.md index 3293d5e20..44b5d09f2 100644 --- a/src/datetime-picker/README.md +++ b/src/datetime-picker/README.md @@ -260,7 +260,7 @@ export default { | formatter | Option text formatter | _(type, val) => val_ | - | | columns-order `v2.9.2` | Array for ordering columns, where item can be set to
                                  `year`, `month`, `day`, `hour` and `minute` | _string[]_ | - | | item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | ### DatePicker Props diff --git a/src/datetime-picker/README.zh-CN.md b/src/datetime-picker/README.zh-CN.md index f7a39741a..17fb28660 100644 --- a/src/datetime-picker/README.zh-CN.md +++ b/src/datetime-picker/README.zh-CN.md @@ -269,7 +269,7 @@ export default { | formatter | 选项格式化函数 | _(type, val) => val_ | - | | columns-order `v2.9.2` | 自定义列排序数组, 子项可选值为
                                  `year`、`month`、`day`、`hour`、`minute` | _string[]_ | - | | item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | ### DatePicker Props diff --git a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap index 1489ea5bc..69d2e9083 100644 --- a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap @@ -4,16 +4,16 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                  -
                                    +
                                    • 05
                                    • @@ -23,7 +23,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 05
                                    • @@ -45,7 +45,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -64,7 +64,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -103,7 +103,7 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  @@ -114,9 +114,9 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 2010 year
                                    • @@ -126,7 +126,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 05 month
                                    • @@ -136,7 +136,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 05 day
                                    • @@ -158,7 +158,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 hour
                                    • @@ -177,7 +177,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 minute
                                    • @@ -216,7 +216,7 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap index 93186057a..fea04fd14 100644 --- a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap @@ -4,9 +4,9 @@ exports[`time type 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 22
                                    • @@ -16,7 +16,7 @@ exports[`time type 1`] = `
                                  -
                                    +
                                    • 58
                                    • @@ -25,7 +25,7 @@ exports[`time type 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap index 30a574b09..39071a4ab 100644 --- a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月日
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -32,7 +32,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -72,7 +72,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -168,7 +168,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -180,9 +180,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月
                                  -
                                  +
                                  -
                                    +
                                    • 2020年
                                    • @@ -204,7 +204,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01月
                                    • @@ -243,7 +243,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -255,9 +255,9 @@ exports[`renders demo correctly 1`] = `
                                  选择月日
                                  -
                                  +
                                  -
                                    +
                                    • 01月
                                    • @@ -297,7 +297,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01日
                                    • @@ -393,7 +393,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -405,9 +405,9 @@ exports[`renders demo correctly 1`] = `
                                  选择时间
                                  -
                                  +
                                  -
                                    +
                                    • 10
                                    • @@ -444,7 +444,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -627,7 +627,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -639,9 +639,9 @@ exports[`renders demo correctly 1`] = `
                                  选择完整时间
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -663,7 +663,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -703,7 +703,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -800,7 +800,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -876,7 +876,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1059,7 +1059,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1071,9 +1071,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月日小时
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -1095,7 +1095,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -1135,7 +1135,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -1232,7 +1232,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1307,7 +1307,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1319,9 +1319,9 @@ exports[`renders demo correctly 1`] = `
                                  选项过滤器
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -1397,7 +1397,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1436,7 +1436,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1448,9 +1448,9 @@ exports[`renders demo correctly 1`] = `
                                  自定义列排序
                                  -
                                  +
                                  -
                                    +
                                    • 01月
                                    • @@ -1490,7 +1490,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01日
                                    • @@ -1587,7 +1587,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 2020年
                                    • @@ -1608,7 +1608,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap index ec25eb174..ec66b33e1 100644 --- a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap @@ -4,9 +4,9 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -25,7 +25,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -46,7 +46,7 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  @@ -57,9 +57,9 @@ exports[`format initial value 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 22
                                    • @@ -69,7 +69,7 @@ exports[`format initial value 1`] = `
                                  -
                                    +
                                    • 58
                                    • @@ -78,7 +78,7 @@ exports[`format initial value 1`] = `
                                  -
                                  +
                                  @@ -89,9 +89,9 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00 hour
                                    • @@ -110,7 +110,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 minute
                                    • @@ -131,7 +131,7 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  @@ -142,9 +142,9 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -157,7 +157,7 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -169,7 +169,7 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                  +
                                  diff --git a/src/picker/README.md b/src/picker/README.md index d6da938eb..619598f14 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -253,7 +253,7 @@ export default { | allow-html `v2.1.8` | Whether to allow HTML in option text | _boolean_ | `true` | | default-index | Default value index of single column picker | _number \| string_ | `0` | | item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.10` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | ### Events diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 8ba6d01a5..f647f48c4 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -276,7 +276,7 @@ export default { | allow-html `v2.1.8` | 是否允许选项内容中渲染 HTML | _boolean_ | `true` | | default-index | 单列选择时,默认选中项的索引 | _number \| string_ | `0` | | item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位 `ms` | _number \| string_ | `1000` | ### Events diff --git a/src/picker/shared.ts b/src/picker/shared.ts index 9df9467d7..7736234a5 100644 --- a/src/picker/shared.ts +++ b/src/picker/shared.ts @@ -23,7 +23,7 @@ export const pickerProps = { }, visibleItemCount: { type: [Number, String], - default: 5, + default: 6, }, swipeDuration: { type: [Number, String], diff --git a/src/picker/test/__snapshots__/demo.spec.js.snap b/src/picker/test/__snapshots__/demo.spec.js.snap index ef31702d1..44490e4d6 100644 --- a/src/picker/test/__snapshots__/demo.spec.js.snap +++ b/src/picker/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -28,7 +28,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -40,9 +40,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -60,7 +60,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -72,9 +72,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 周一
                                    • @@ -93,7 +93,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 上午
                                    • @@ -105,7 +105,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -117,9 +117,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -129,7 +129,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -139,7 +139,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 西湖区
                                    • @@ -148,7 +148,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -160,9 +160,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -174,7 +174,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -186,9 +186,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -198,7 +198,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -216,7 +216,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -228,9 +228,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -240,7 +240,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -258,7 +258,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  diff --git a/src/picker/test/__snapshots__/index.spec.js.snap b/src/picker/test/__snapshots__/index.spec.js.snap index fe9515293..24c30aa69 100644 --- a/src/picker/test/__snapshots__/index.spec.js.snap +++ b/src/picker/test/__snapshots__/index.spec.js.snap @@ -59,11 +59,11 @@ exports[`column watch default index 2`] = ` exports[`columns-top、columns-bottom prop 1`] = `
                                  - Custom Columns Top
                                  + Custom Columns Top
                                  -
                                    +
                                      -
                                      +
                                      Custom Columns Bottom @@ -73,15 +73,15 @@ exports[`columns-top、columns-bottom prop 1`] = ` exports[`not allow html 1`] = `
                                      -
                                      +
                                      -
                                        +
                                        • <div>option</div>
                                      -
                                      +
                                      @@ -92,11 +92,11 @@ exports[`render title slot 1`] = `
                                      Custom title
                                      -
                                      +
                                      -
                                        +
                                          -
                                          +
                                          @@ -106,9 +106,9 @@ exports[`render title slot 1`] = ` exports[`set rem item-height 1`] = `
                                          -
                                          +
                                          -
                                            +
                                            • 1990
                                            • @@ -117,7 +117,7 @@ exports[`set rem item-height 1`] = `
                                          -
                                          +
                                          @@ -128,11 +128,11 @@ exports[`toolbar-position prop 1`] = `
                                          -
                                          +
                                          -
                                            +
                                              -
                                              +
                                              From c49c57d2caa1f4408709af30990b1797203bbd37 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 21 Jul 2020 22:58:26 +0800 Subject: [PATCH 20/51] style(Tag): adjust size and padding (#6828) --- src/card/test/__snapshots__/demo.spec.js.snap | 4 +- src/style/var.less | 13 +++-- src/tag/README.md | 5 -- src/tag/README.zh-CN.md | 15 ++---- src/tag/demo/index.vue | 5 -- src/tag/index.less | 50 +++++++++++-------- src/tag/index.tsx | 3 +- src/tag/test/__snapshots__/demo.spec.js.snap | 10 ++-- 8 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/card/test/__snapshots__/demo.spec.js.snap b/src/card/test/__snapshots__/demo.spec.js.snap index 016ba0f01..ce4cac4ec 100644 --- a/src/card/test/__snapshots__/demo.spec.js.snap +++ b/src/card/test/__snapshots__/demo.spec.js.snap @@ -62,9 +62,9 @@ exports[`renders demo correctly 1`] = `
                                              商品名称
                                              描述信息
                                              -
                                              +
                                              标签 - + 标签
                                              diff --git a/src/style/var.less b/src/style/var.less index a0957a179..7a4773358 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -766,12 +766,15 @@ @tabs-bottom-bar-color: @tabs-default-color; // Tag -@tag-padding: 0.2em 0.5em; -@tag-font-size: @font-size-xs; -@tag-medium-font-size: @font-size-sm; -@tag-large-font-size: @font-size-md; +@tag-padding: 0 @padding-base; @tag-text-color: @white; -@tag-border-radius: 0.2em; +@tag-font-size: @font-size-sm; +@tag-border-radius: 2px; +@tag-line-height: 16px; +@tag-medium-padding: 2px 6px; +@tag-large-padding: @padding-base @padding-xs; +@tag-large-border-radius: @border-radius-md; +@tag-large-font-size: @font-size-md; @tag-round-border-radius: @border-radius-max; @tag-danger-color: @red; @tag-primary-color: @blue; diff --git a/src/tag/README.md b/src/tag/README.md index eb36c57e8..4a8a32d45 100644 --- a/src/tag/README.md +++ b/src/tag/README.md @@ -14,7 +14,6 @@ Vue.use(Tag); ### Basic Usage ```html -Tag Tag Tag Tag @@ -24,7 +23,6 @@ Vue.use(Tag); ### Round style ```html -Tag Tag Tag Tag @@ -34,7 +32,6 @@ Vue.use(Tag); ### Mark style ```html -Tag Tag Tag Tag @@ -44,7 +41,6 @@ Vue.use(Tag); ### Plain style ```html -Tag Tag Tag Tag @@ -55,7 +51,6 @@ Vue.use(Tag); ```html Tag -Tag Tag Tag Tag diff --git a/src/tag/README.zh-CN.md b/src/tag/README.zh-CN.md index 34b682c6f..f9fc0e99b 100644 --- a/src/tag/README.zh-CN.md +++ b/src/tag/README.zh-CN.md @@ -13,10 +13,9 @@ Vue.use(Tag); ### 基础用法 -通过`type`属性控制标签颜色,默认为灰色 +通过 `type` 属性控制标签颜色。 ```html -标签 标签 标签 标签 @@ -25,10 +24,9 @@ Vue.use(Tag); ### 圆角样式 -通过`round`设置为圆角样式 +通过 `round` 设置为圆角样式。 ```html -标签 标签 标签 标签 @@ -37,10 +35,9 @@ Vue.use(Tag); ### 标记样式 -通过`mark`设置为标记样式(半圆角) +通过 `mark` 设置为标记样式(半圆角)。 ```html -标签 标签 标签 标签 @@ -49,10 +46,9 @@ Vue.use(Tag); ### 空心样式 -设置`plain`属性设置为空心样式 +设置 `plain` 属性设置为空心样式。 ```html -标签 标签 标签 标签 @@ -63,7 +59,6 @@ Vue.use(Tag); ```html 标签 -标签 标签 标签 标签 @@ -79,7 +74,7 @@ Vue.use(Tag); ### 可关闭标签 -添加`closeable`属性表示标签是可关闭的,关闭标签时会触发`close`事件,在`close`事件中可以执行隐藏标签的逻辑 +添加 `closeable` 属性表示标签是可关闭的,关闭标签时会触发 `close` 事件,在 `close` 事件中可以执行隐藏标签的逻辑。 ```html - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -9,7 +8,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -17,7 +15,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -25,7 +22,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -34,7 +30,6 @@ {{ t('tag') }} - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} diff --git a/src/tag/index.less b/src/tag/index.less index b7ebdb053..9f5d3b49c 100644 --- a/src/tag/index.less +++ b/src/tag/index.less @@ -1,19 +1,15 @@ @import '../style/var'; .van-tag { + position: relative; display: inline-flex; align-items: center; padding: @tag-padding; color: @tag-text-color; font-size: @tag-font-size; - line-height: normal; + line-height: @tag-line-height; border-radius: @tag-border-radius; - &::after { - border-color: currentColor; - border-radius: @tag-border-radius * 2; - } - &--default { background-color: @tag-default-color; @@ -56,30 +52,42 @@ &--plain { background-color: @tag-plain-background-color; - } - &--mark { - padding-right: 0.7em; - - &, - &::after { - border-radius: 0 @tag-round-border-radius @tag-round-border-radius 0; - } - } - - &--round { - &, - &::after { - border-radius: @tag-round-border-radius; + &::before { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border: 1px solid currentColor; + border-radius: inherit; + content: ''; + pointer-events: none; } } &--medium { - font-size: @tag-medium-font-size; + padding: @tag-medium-padding; } &--large { + padding: @tag-large-padding; font-size: @tag-large-font-size; + border-radius: @tag-large-border-radius; + } + + &--mark { + border-radius: 0 @tag-round-border-radius @tag-round-border-radius 0; + + &::after { + display: block; + width: 2px; + content: ''; + } + } + + &--round { + border-radius: @tag-round-border-radius; } &__close { diff --git a/src/tag/index.tsx b/src/tag/index.tsx index 7c0dcd604..f33604ca0 100644 --- a/src/tag/index.tsx +++ b/src/tag/index.tsx @@ -1,7 +1,6 @@ // Utils import { createNamespace } from '../utils'; import { inherit, emit } from '../utils/functional'; -import { BORDER_SURROUND } from '../utils/constant'; // Components import Icon from '../icon'; @@ -63,7 +62,7 @@ function Tag( {slots.default?.()} diff --git a/src/tag/test/__snapshots__/demo.spec.js.snap b/src/tag/test/__snapshots__/demo.spec.js.snap index 622597aba..b75a4f8c3 100644 --- a/src/tag/test/__snapshots__/demo.spec.js.snap +++ b/src/tag/test/__snapshots__/demo.spec.js.snap @@ -2,11 +2,11 @@ exports[`renders demo correctly 1`] = `
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              标签 标签 标签
                                              标签 From bed0c1a61dba3c7b199392934cda7048f27c1c4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2020 22:59:08 +0800 Subject: [PATCH 21/51] build(deps): bump codecov from 3.7.0 to 3.7.1 in /packages/vant-cli (#6831) Bumps [codecov](https://github.com/codecov/codecov-node) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/codecov/codecov-node/releases) - [Commits](https://github.com/codecov/codecov-node/compare/v3.7.0...v3.7.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vant-cli/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vant-cli/yarn.lock b/packages/vant-cli/yarn.lock index 90a993161..55f98c23f 100644 --- a/packages/vant-cli/yarn.lock +++ b/packages/vant-cli/yarn.lock @@ -3516,9 +3516,9 @@ co@^4.6.0: integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= codecov@^3.7.0: - version "3.7.0" - resolved "https://registry.npm.taobao.org/codecov/download/codecov-3.7.0.tgz#4a09939cde24447a43f36d068e8b4e0188dc3f27" - integrity sha1-SgmTnN4kRHpD820GjotOAYjcPyc= + version "3.7.1" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202" + integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw== dependencies: argv "0.0.2" ignore-walk "3.0.3" From ec41d278345d99fbb23f300be957606f4d9c4222 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2020 22:59:41 +0800 Subject: [PATCH 22/51] build(deps): bump codecov from 3.7.0 to 3.7.1 (#6830) Bumps [codecov](https://github.com/codecov/codecov-node) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/codecov/codecov-node/releases) - [Commits](https://github.com/codecov/codecov-node/compare/v3.7.0...v3.7.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index b7a529e7e..55931d7c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1565,9 +1565,9 @@ defer-to-connect "^2.0.0" "@tootallnate/once@1": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.0.0.tgz#9c13c2574c92d4503b005feca8f2e16cc1611506" - integrity sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA== + version "1.1.2" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== "@types/anymatch@*": version "1.3.1" @@ -2424,9 +2424,9 @@ agent-base@5: integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== agent-base@6: - version "6.0.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.0.tgz#5d0101f19bbfaed39980b22ae866de153b93f09a" - integrity sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw== + version "6.0.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.1.tgz#808007e4e5867decb0ab6ab2f928fbdb5a596db4" + integrity sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg== dependencies: debug "4" @@ -3636,9 +3636,9 @@ co@^4.6.0: integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= codecov@^3.7.0: - version "3.7.0" - resolved "https://registry.npmjs.org/codecov/-/codecov-3.7.0.tgz#4a09939cde24447a43f36d068e8b4e0188dc3f27" - integrity sha512-uIixKofG099NbUDyzRk1HdGtaG8O+PBUAg3wfmjwXw2+ek+PZp+puRvbTohqrVfuudaezivJHFgTtSC3M8MXww== + version "3.7.1" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202" + integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw== dependencies: argv "0.0.2" ignore-walk "3.0.3" From a1693b68aeb75afafabbf2122794cbbebfac8d06 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Wed, 22 Jul 2020 19:56:17 +0800 Subject: [PATCH 23/51] chore: release 2.9.4-beta.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c2b58f41..6de5bbf28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vant", - "version": "2.9.3", + "version": "2.9.4-beta.0", "description": "Mobile UI Components built on Vue", "main": "lib/index.js", "module": "es/index.js", From aa4f5ffdb1393cbe6f8801c9fa58d11c0d7aa6eb Mon Sep 17 00:00:00 2001 From: Will Wu <59545147+WillHHH@users.noreply.github.com> Date: Thu, 23 Jul 2020 06:53:52 -0400 Subject: [PATCH 24/51] docs(Picker): fix spelling-problems (#6840) --- src/picker/README.zh-CN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index f647f48c4..b2ace5118 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -174,7 +174,7 @@ export default { ``` ```js -const citys = { +const cities = { 浙江: ['杭州', '宁波', '温州', '嘉兴', '湖州'], 福建: ['福州', '厦门', '莆田', '三明', '泉州'], }; @@ -182,12 +182,12 @@ const citys = { export default { data() { return { - columns: [{ values: Object.keys(citys) }, { values: citys['浙江'] }], + columns: [{ values: Object.keys(cities) }, { values: cities['浙江'] }], }; }, methods: { onChange(picker, values) { - picker.setColumnValues(1, citys[values[0]]); + picker.setColumnValues(1, cities[values[0]]); }, }, }; From ab37ee6d67b22d4a379e6dca935e1a5d90bc72b0 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 19:37:15 +0800 Subject: [PATCH 25/51] style(Cell): adjust icon margin to 4px (#6844) --- src/cell/README.md | 14 +++++++- src/cell/README.zh-CN.md | 32 +++++++++++++------ src/cell/demo/index.vue | 12 ++++--- src/cell/index.less | 4 +-- src/cell/test/__snapshots__/demo.spec.js.snap | 2 +- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/cell/README.md b/src/cell/README.md index e475fc1f0..feca7df32 100644 --- a/src/cell/README.md +++ b/src/cell/README.md @@ -95,9 +95,21 @@ Vue.use(CellGroup); + + ``` ### Vertical Center diff --git a/src/cell/README.zh-CN.md b/src/cell/README.zh-CN.md index f13bd478b..86394eec0 100644 --- a/src/cell/README.zh-CN.md +++ b/src/cell/README.zh-CN.md @@ -14,7 +14,7 @@ Vue.use(CellGroup); ### 基础用法 -`Cell`可以单独使用,也可以与`CellGroup`搭配使用。`CellGroup`可以为`Cell`提供上下外边框 +`Cell` 可以单独使用,也可以与 `CellGroup` 搭配使用,`CellGroup` 可以为 `Cell` 提供上下外边框。 ```html @@ -25,7 +25,7 @@ Vue.use(CellGroup); ### 单元格大小 -通过`size`属性可以控制单元格的大小 +通过 `size` 属性可以控制单元格的大小。 ```html @@ -34,7 +34,7 @@ Vue.use(CellGroup); ### 展示图标 -通过`icon`属性在标题左侧展示图标 +通过 `icon` 属性在标题左侧展示图标。 ```html @@ -42,7 +42,7 @@ Vue.use(CellGroup); ### 只设置 value -只设置`value`时,内容会靠左对齐 +只设置 `value` 时,内容会靠左对齐。 ```html @@ -50,7 +50,7 @@ Vue.use(CellGroup); ### 展示箭头 -设置`is-link`属性后会在单元格右侧显示箭头,并且可以通过`arrow-direction`属性控制箭头方向 +设置 `is-link` 属性后会在单元格右侧显示箭头,并且可以通过 `arrow-direction` 属性控制箭头方向。 ```html @@ -60,7 +60,7 @@ Vue.use(CellGroup); ### 页面导航 -可以通过`url`属性进行 URL 跳转,或通过`to`属性进行路由跳转 +可以通过 `url` 属性进行 URL 跳转,或通过 `to` 属性进行路由跳转。 ```html @@ -69,7 +69,7 @@ Vue.use(CellGroup); ### 分组标题 -通过`CellGroup`的`title`属性可以指定分组标题 +通过 `CellGroup` 的 `title` 属性可以指定分组标题。 ```html @@ -82,7 +82,7 @@ Vue.use(CellGroup); ### 使用插槽 -如以上用法不能满足你的需求,可以使用插槽来自定义内容 +如以上用法不能满足你的需求,可以使用插槽来自定义内容。 ```html @@ -96,14 +96,26 @@ Vue.use(CellGroup); + + ``` ### 垂直居中 -通过`center`属性可以让`Cell`的左右内容都垂直居中 +通过 `center` 属性可以让 `Cell` 的左右内容都垂直居中。 ```html diff --git a/src/cell/demo/index.vue b/src/cell/demo/index.vue index 1769799fb..b1462a942 100644 --- a/src/cell/demo/index.vue +++ b/src/cell/demo/index.vue @@ -60,10 +60,7 @@ @@ -117,8 +114,13 @@ export default { diff --git a/src/cell/index.less b/src/cell/index.less index 8bcb4878a..b5cfdc768 100644 --- a/src/cell/index.less +++ b/src/cell/index.less @@ -57,11 +57,11 @@ } &__left-icon { - margin-right: 5px; + margin-right: @padding-base; } &__right-icon { - margin-left: 5px; + margin-left: @padding-base; color: @cell-right-icon-color; } diff --git a/src/cell/test/__snapshots__/demo.spec.js.snap b/src/cell/test/__snapshots__/demo.spec.js.snap index b66a4b780..aa03c8674 100644 --- a/src/cell/test/__snapshots__/demo.spec.js.snap +++ b/src/cell/test/__snapshots__/demo.spec.js.snap @@ -94,7 +94,7 @@ exports[`renders demo correctly 1`] = `
                                              -
                                              单元格
                                              +
                                              单元格
                                              From e6b30e4de9c6a020b7142802e3fbe1c188e9c5f3 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 19:58:43 +0800 Subject: [PATCH 26/51] style(NumberKeyboard): increase title size (#6845) --- src/style/var.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/style/var.less b/src/style/var.less index 7a4773358..df7919287 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -484,8 +484,8 @@ @number-keyboard-key-active-color: @gray-3; @number-keyboard-delete-font-size: @font-size-lg; @number-keyboard-title-color: @gray-7; -@number-keyboard-title-height: 30px; -@number-keyboard-title-font-size: @font-size-md; +@number-keyboard-title-height: 34px; +@number-keyboard-title-font-size: @font-size-lg; @number-keyboard-close-padding: 0 @padding-md; @number-keyboard-close-color: @text-link-color; @number-keyboard-close-font-size: @font-size-md; From 3557e8bc69988624a55428b851d6a22a4d657747 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 20:13:29 +0800 Subject: [PATCH 27/51] style(ActionSheet): adjust cancel text color to @gray-7 (#6846) --- src/action-sheet/index.less | 4 ++++ src/style/var.less | 1 + 2 files changed, 5 insertions(+) diff --git a/src/action-sheet/index.less b/src/action-sheet/index.less index 79ba786b9..8285a5ccc 100644 --- a/src/action-sheet/index.less +++ b/src/action-sheet/index.less @@ -41,6 +41,10 @@ } } + &__cancel { + color: @action-sheet-cancel-text-color; + } + &__subname { margin-top: @padding-xs; color: @action-sheet-subname-color; diff --git a/src/style/var.less b/src/style/var.less index df7919287..f4fd347ae 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -82,6 +82,7 @@ @action-sheet-close-icon-color: @gray-5; @action-sheet-close-icon-active-color: @gray-6; @action-sheet-close-icon-padding: 0 @padding-md; +@action-sheet-cancel-text-color: @gray-7; @action-sheet-cancel-padding-top: @padding-xs; @action-sheet-cancel-padding-color: @background-color; From 082b353ad8401bcb1332e2b7337cbd154fcef9b1 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 20:24:15 +0800 Subject: [PATCH 28/51] style(ActionSheet): add @action-sheet-loading-icon-size var (#6847) --- src/action-sheet/index.less | 5 +++++ src/action-sheet/index.tsx | 2 +- src/action-sheet/test/__snapshots__/index.spec.js.snap | 2 +- src/style/var.less | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/action-sheet/index.less b/src/action-sheet/index.less index 8285a5ccc..3a776e4f7 100644 --- a/src/action-sheet/index.less +++ b/src/action-sheet/index.less @@ -78,6 +78,11 @@ } } + &__loading-icon .van-loading__spinner { + width: @action-sheet-loading-icon-size; + height: @action-sheet-loading-icon-size; + } + &__close { position: absolute; top: 0; diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index 77808b419..2c5adcd53 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -97,7 +97,7 @@ function ActionSheet( function OptionContent() { if (loading) { - return ; + return ; } return [ diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index e71b51fbe..d1bb01fd6 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -2,7 +2,7 @@ exports[`callback events 1`] = `
                                              diff --git a/src/style/var.less b/src/style/var.less index f4fd347ae..230fa9fc6 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -85,6 +85,7 @@ @action-sheet-cancel-text-color: @gray-7; @action-sheet-cancel-padding-top: @padding-xs; @action-sheet-cancel-padding-color: @background-color; +@action-sheet-loading-icon-size: 22px; // AddressEdit @address-edit-padding: @padding-sm; From d656c2d94e5c2706d1e4cdac4ef3e07b21511c73 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 21:03:18 +0800 Subject: [PATCH 29/51] style(Toast): adjust background color (#6848) --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index 230fa9fc6..9c707d039 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -792,7 +792,7 @@ @toast-loading-icon-color: @white; @toast-line-height: 20px; @toast-border-radius: @border-radius-lg; -@toast-background-color: fade(@text-color, 88%); +@toast-background-color: fade(@black, 70%); @toast-icon-size: 40px; @toast-text-min-width: 96px; @toast-text-padding: @padding-xs @padding-sm; From fb540abe766321db761a18bc23c004d6e16df86f Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 23 Jul 2020 21:07:58 +0800 Subject: [PATCH 30/51] style(Field): adjust icon margin to 4px (#6849) --- src/field/index.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field/index.less b/src/field/index.less index 305c8fe23..88712250b 100644 --- a/src/field/index.less +++ b/src/field/index.less @@ -123,7 +123,7 @@ } &__left-icon { - margin-right: 5px; + margin-right: @padding-base; } &__right-icon { From 418fa02439f1211c3f488f9d35292dfad243796f Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 15:27:41 +0800 Subject: [PATCH 31/51] style(NumberKeyboard): improve safe area inset bottom (#6855) --- src/number-keyboard/index.less | 3 +-- src/style/var.less | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/number-keyboard/index.less b/src/number-keyboard/index.less index a6dcb5805..39a6c51b7 100644 --- a/src/number-keyboard/index.less +++ b/src/number-keyboard/index.less @@ -6,8 +6,7 @@ left: 0; z-index: @number-keyboard-z-index; width: 100%; - padding-bottom: constant(safe-area-inset-bottom); - padding-bottom: env(safe-area-inset-bottom); + padding-bottom: @number-keyboard-safe-area-inset-bottom; background-color: @number-keyboard-background-color; user-select: none; diff --git a/src/style/var.less b/src/style/var.less index 9c707d039..d239d5fcd 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -498,6 +498,7 @@ @number-keyboard-cursor-height: 40%; @number-keyboard-cursor-animation-duration: 1s; @number-keyboard-z-index: 100; +@number-keyboard-safe-area-inset-bottom: 32px; // Overlay @overlay-z-index: 1; From d5808be9b353681ba784d44f5ada1304ff036173 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Fri, 24 Jul 2020 15:37:41 +0800 Subject: [PATCH 32/51] Revert "style(NumberKeyboard): improve safe area inset bottom (#6855)" This reverts commit 418fa02439f1211c3f488f9d35292dfad243796f. --- src/number-keyboard/index.less | 3 ++- src/style/var.less | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/number-keyboard/index.less b/src/number-keyboard/index.less index 39a6c51b7..a6dcb5805 100644 --- a/src/number-keyboard/index.less +++ b/src/number-keyboard/index.less @@ -6,7 +6,8 @@ left: 0; z-index: @number-keyboard-z-index; width: 100%; - padding-bottom: @number-keyboard-safe-area-inset-bottom; + padding-bottom: constant(safe-area-inset-bottom); + padding-bottom: env(safe-area-inset-bottom); background-color: @number-keyboard-background-color; user-select: none; diff --git a/src/style/var.less b/src/style/var.less index d239d5fcd..9c707d039 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -498,7 +498,6 @@ @number-keyboard-cursor-height: 40%; @number-keyboard-cursor-animation-duration: 1s; @number-keyboard-z-index: 100; -@number-keyboard-safe-area-inset-bottom: 32px; // Overlay @overlay-z-index: 1; From 64087756260cad7288d1c93cab5d2982bacce6a4 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 15:42:18 +0800 Subject: [PATCH 33/51] style(ActionSheet): increase header height to 48px (#6856) --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index 9c707d039..e76733e2a 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -65,7 +65,7 @@ // ActionSheet @action-sheet-max-height: 80%; -@action-sheet-header-height: 44px; +@action-sheet-header-height: 48px; @action-sheet-header-font-size: @font-size-lg; @action-sheet-description-color: @gray-6; @action-sheet-description-font-size: @font-size-md; From be0eb547da4bd63d5a869cae0553edb969855770 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 15:54:05 +0800 Subject: [PATCH 34/51] style(Toast): adjust icon size to 36px (#6857) --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index e76733e2a..8a4bf190a 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -793,7 +793,7 @@ @toast-line-height: 20px; @toast-border-radius: @border-radius-lg; @toast-background-color: fade(@black, 70%); -@toast-icon-size: 40px; +@toast-icon-size: 36px; @toast-text-min-width: 96px; @toast-text-padding: @padding-xs @padding-sm; @toast-default-padding: @padding-md; From 7f466a3859a197bee255c3dca4e620f2ae5014fb Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 16:00:30 +0800 Subject: [PATCH 35/51] fix(Icon): incorrect image icon height when loading (#6858) --- src/icon/index.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/icon/index.less b/src/icon/index.less index f1b78f967..803156141 100644 --- a/src/icon/index.less +++ b/src/icon/index.less @@ -3,6 +3,7 @@ .van-icon { &__image { + display: block; width: 1em; height: 1em; object-fit: contain; From d7f30bb5fee6f726d9e29525c9d2a4a6f39ff08f Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 16:43:04 +0800 Subject: [PATCH 36/51] style(Sidebar): adjust selected text color to @red (#6860) --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index 8a4bf190a..76c193982 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -631,7 +631,7 @@ @sidebar-active-color: @active-color; @sidebar-background-color: @background-color; @sidebar-selected-font-weight: @font-weight-bold; -@sidebar-selected-text-color: @text-color; +@sidebar-selected-text-color: @red; @sidebar-selected-border-width: 4px; @sidebar-selected-border-height: 16px; @sidebar-selected-border-color: @red; From cdb63ad98d54dd0ca0f399672b20fe38974ff02f Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 16:50:02 +0800 Subject: [PATCH 37/51] style(Sidebar): adjust width to 80px (#6861) --- src/style/var.less | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/style/var.less b/src/style/var.less index 76c193982..00f43ac4c 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -620,9 +620,7 @@ @search-action-font-size: @font-size-md; // Sidebar -@sidebar-width: 85px; - -// SidebarItem +@sidebar-width: 80px; @sidebar-font-size: @font-size-md; @sidebar-line-height: 20px; @sidebar-text-color: @text-color; From 95d3389d15a420d769a4de2435c4a9dc8eb9f9a8 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 17:23:46 +0800 Subject: [PATCH 38/51] style: uniform line-height (#6862) * style: uniform line-height * style: line height --- src/address-list/index.less | 2 +- src/card/index.less | 2 +- src/contact-card/demo/index.vue | 6 ++-- src/coupon/index.less | 2 +- src/step/index.less | 2 +- src/style/var.less | 54 ++++++++++++++++++--------------- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/address-list/index.less b/src/address-list/index.less index 7a777636b..27d2b2e41 100644 --- a/src/address-list/index.less +++ b/src/address-list/index.less @@ -50,7 +50,7 @@ align-items: center; margin-bottom: @padding-xs; font-size: @font-size-lg; - line-height: 22px; + line-height: @line-height-lg; } &__tag { diff --git a/src/card/index.less b/src/card/index.less index 1a05e11a0..6f6541ec3 100644 --- a/src/card/index.less +++ b/src/card/index.less @@ -60,7 +60,7 @@ } &__bottom { - line-height: 20px; + line-height: @line-height-md; } &__price { diff --git a/src/contact-card/demo/index.vue b/src/contact-card/demo/index.vue index de3dbc438..c1968e315 100644 --- a/src/contact-card/demo/index.vue +++ b/src/contact-card/demo/index.vue @@ -115,7 +115,7 @@ export default { if (this.isEdit) { this.list = this.list.map((item) => - (item.id === info.id ? info : item) + item.id === info.id ? info : item ); } else { this.list.push(info); @@ -135,10 +135,12 @@ export default { diff --git a/src/coupon/index.less b/src/coupon/index.less index 1673c30e4..6caf77bb7 100644 --- a/src/coupon/index.less +++ b/src/coupon/index.less @@ -68,7 +68,7 @@ margin-bottom: 10px; font-weight: bold; font-size: @coupon-name-font-size; - line-height: 20px; + line-height: @line-height-md; } &__valid { diff --git a/src/step/index.less b/src/step/index.less index 8ecc8ca13..ed99f540c 100644 --- a/src/step/index.less +++ b/src/step/index.less @@ -88,7 +88,7 @@ display: block; float: none; padding: 10px 10px 10px 0; - line-height: 18px; + line-height: @line-height-sm; &:not(:last-child)::after { border-bottom-width: 1px; diff --git a/src/style/var.less b/src/style/var.less index 00f43ac4c..d50ed00f8 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -43,6 +43,10 @@ @font-size-md: 14px; @font-size-lg: 16px; @font-weight-bold: 500; +@line-height-xs: 14px; +@line-height-sm: 18px; +@line-height-md: 20px; +@line-height-lg: 22px; @base-font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; @@ -69,15 +73,15 @@ @action-sheet-header-font-size: @font-size-lg; @action-sheet-description-color: @gray-6; @action-sheet-description-font-size: @font-size-md; -@action-sheet-description-line-height: 20px; +@action-sheet-description-line-height: @line-height-md; @action-sheet-item-background: @white; @action-sheet-item-font-size: @font-size-lg; -@action-sheet-item-line-height: 22px; +@action-sheet-item-line-height: @line-height-lg; @action-sheet-item-text-color: @text-color; @action-sheet-item-disabled-text-color: @gray-5; @action-sheet-subname-color: @gray-6; @action-sheet-subname-font-size: @font-size-sm; -@action-sheet-subname-line-height: 20px; +@action-sheet-subname-line-height: @line-height-sm; @action-sheet-close-icon-size: 22px; @action-sheet-close-icon-color: @gray-5; @action-sheet-close-icon-active-color: @gray-6; @@ -99,13 +103,13 @@ @address-list-disabled-text-color: @gray-6; @address-list-disabled-text-padding: @padding-base * 5 0 @padding-md; @address-list-disabled-text-font-size: @font-size-md; -@address-list-disabled-text-line-height: 20px; +@address-list-disabled-text-line-height: @line-height-md; @address-list-add-button-z-index: 999; @address-list-item-padding: @padding-sm; @address-list-item-text-color: @text-color; @address-list-item-disabled-text-color: @gray-5; @address-list-item-font-size: 13px; -@address-list-item-line-height: 18px; +@address-list-item-line-height: @line-height-sm; @address-list-item-radio-icon-color: @red; @address-list-edit-icon-size: 20px; @@ -161,7 +165,7 @@ @calendar-selected-day-size: 54px; @calendar-selected-day-color: @white; @calendar-info-font-size: @font-size-xs; -@calendar-info-line-height: 14px; +@calendar-info-line-height: @line-height-xs; @calendar-selected-day-background-color: @red; @calendar-day-disabled-color: @gray-5; @calendar-confirm-button-height: 36px; @@ -176,7 +180,7 @@ @card-thumb-border-radius: @border-radius-lg; @card-title-line-height: 16px; @card-desc-color: @gray-7; -@card-desc-line-height: 20px; +@card-desc-line-height: @line-height-md; @card-price-color: @gray-8; @card-origin-price-color: @gray-6; @card-num-color: @gray-6; @@ -197,7 +201,7 @@ @cell-required-color: @red; @cell-label-color: @gray-6; @cell-label-font-size: @font-size-sm; -@cell-label-line-height: 18px; +@cell-label-line-height: @line-height-sm; @cell-label-margin-top: @padding-base; @cell-value-color: @gray-6; @cell-icon-size: 16px; @@ -228,12 +232,12 @@ @circle-text-color: @text-color; @circle-text-font-weight: @font-weight-bold; @circle-text-font-size: @font-size-md; -@circle-text-line-height: 18px; +@circle-text-line-height: @line-height-md; // Collapse @collapse-item-transition-duration: @animation-duration-base; @collapse-item-content-padding: @padding-sm @padding-md; -@collapse-item-content-font-size: 14px; +@collapse-item-content-font-size: @font-size-md; @collapse-item-content-line-height: 1.5; @collapse-item-content-text-color: @gray-6; @collapse-item-content-background-color: @white; @@ -243,7 +247,7 @@ @contact-card-padding: @padding-md; @contact-card-add-icon-size: 40px; @contact-card-add-icon-color: @blue; -@contact-card-value-line-height: 20px; +@contact-card-value-line-height: @line-height-md; // ContactEdit @contact-edit-padding: @padding-md; @@ -261,7 +265,7 @@ // CountDown @count-down-text-color: @text-color; @count-down-font-size: @font-size-md; -@count-down-line-height: 20px; +@count-down-line-height: @line-height-md; // Coupon @coupon-margin: 0 @padding-sm @padding-sm; @@ -291,7 +295,7 @@ @coupon-list-empty-image-size: 200px; @coupon-list-empty-tip-color: @gray-6; @coupon-list-empty-tip-font-size: @font-size-md; -@coupon-list-empty-tip-line-height: 20px; +@coupon-list-empty-tip-line-height: @line-height-md; // Dialog @dialog-width: 320px; @@ -306,7 +310,7 @@ @dialog-header-isolated-padding: @padding-lg 0; @dialog-message-padding: @padding-lg; @dialog-message-font-size: @font-size-md; -@dialog-message-line-height: 20px; +@dialog-message-line-height: @line-height-md; @dialog-message-max-height: 60vh; @dialog-has-title-message-text-color: @gray-7; @dialog-has-title-message-padding-top: @padding-sm; @@ -330,7 +334,7 @@ @dropdown-menu-title-active-text-color: @blue; @dropdown-menu-title-disabled-text-color: @gray-6; @dropdown-menu-title-padding: 0 @padding-xs; -@dropdown-menu-title-line-height: 22px; +@dropdown-menu-title-line-height: @line-height-lg; @dropdown-menu-option-active-color: @blue; @dropdown-menu-content-max-height: 80%; @dropdown-item-z-index: 10; @@ -341,8 +345,8 @@ @empty-description-margin-top: @padding-md; @empty-description-padding: 0 60px; @empty-description-color: @gray-6; -@empty-description-font-size: 14px; -@empty-description-line-height: 20px; +@empty-description-font-size: @font-size-md; +@empty-description-line-height: @line-height-md; @empty-bottom-margin-top: 24px; // Field @@ -401,7 +405,7 @@ // IndexBar @index-bar-sidebar-z-index: 2; @index-bar-index-font-size: @font-size-xs; -@index-bar-index-line-height: 14px; +@index-bar-index-line-height: @line-height-xs; @index-bar-index-active-color: @green; // Info @@ -426,7 +430,7 @@ // ImagePreview @image-preview-index-text-color: @white; @image-preview-index-font-size: @font-size-md; -@image-preview-index-line-height: 22px; +@image-preview-index-line-height: @line-height-md; @image-preview-index-text-shadow: 0 1px 1px @gray-8; @image-preview-overlay-background-color: rgba(0, 0, 0, 0.9); @image-preview-close-icon-size: 22px; @@ -473,7 +477,7 @@ @notify-text-color: @white; @notify-padding: @padding-xs @padding-md; @notify-font-size: @font-size-md; -@notify-line-height: 20px; +@notify-line-height: @line-height-md; @notify-primary-background-color: @blue; @notify-success-background-color: @green; @notify-danger-background-color: @red; @@ -535,7 +539,7 @@ @picker-background-color: @white; @picker-toolbar-height: 44px; @picker-title-font-size: @font-size-lg; -@picker-title-line-height: 20px; +@picker-title-line-height: @line-height-md; @picker-action-padding: 0 @padding-md; @picker-action-font-size: @font-size-md; @picker-confirm-action-color: @text-link-color; @@ -593,7 +597,7 @@ @share-sheet-header-padding: @padding-sm @padding-md @padding-base; @share-sheet-title-color: @text-color; @share-sheet-title-font-size: @font-size-md; -@share-sheet-title-line-height: 20px; +@share-sheet-title-line-height: @line-height-md; @share-sheet-description-color: @gray-6; @share-sheet-description-font-size: @font-size-sm; @share-sheet-description-line-height: 16px; @@ -622,7 +626,7 @@ // Sidebar @sidebar-width: 80px; @sidebar-font-size: @font-size-md; -@sidebar-line-height: 20px; +@sidebar-line-height: @line-height-md; @sidebar-text-color: @text-color; @sidebar-disabled-text-color: @gray-5; @sidebar-padding: 20px @padding-sm; @@ -788,7 +792,7 @@ @toast-font-size: @font-size-md; @toast-text-color: @white; @toast-loading-icon-color: @white; -@toast-line-height: 20px; +@toast-line-height: @line-height-md; @toast-border-radius: @border-radius-lg; @toast-background-color: fade(@black, 70%); @toast-icon-size: 36px; @@ -831,7 +835,7 @@ @uploader-mask-background-color: fade(@gray-8, 88%); @uploader-mask-icon-size: 22px; @uploader-mask-message-font-size: @font-size-sm; -@uploader-mask-message-line-height: 14px; +@uploader-mask-message-line-height: @line-height-xs; @uploader-loading-icon-size: 22px; @uploader-loading-icon-color: @white; @uploader-disabled-opacity: @disabled-opacity; From b43b8fc94376c5485b50fec895e875f4a219fa0c Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Fri, 24 Jul 2020 17:24:16 +0800 Subject: [PATCH 39/51] Revert "style(Sidebar): adjust selected text color to @red (#6860)" This reverts commit d7f30bb5fee6f726d9e29525c9d2a4a6f39ff08f. --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index d50ed00f8..9919d8597 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -633,7 +633,7 @@ @sidebar-active-color: @active-color; @sidebar-background-color: @background-color; @sidebar-selected-font-weight: @font-weight-bold; -@sidebar-selected-text-color: @red; +@sidebar-selected-text-color: @text-color; @sidebar-selected-border-width: 4px; @sidebar-selected-border-height: 16px; @sidebar-selected-border-color: @red; From e12b468843db28536455810b127f861e7fd60522 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 24 Jul 2020 17:45:20 +0800 Subject: [PATCH 40/51] style(DropdownMenu): adjust default active color to @red (#6863) --- src/dropdown-menu/README.md | 8 ++++++-- src/dropdown-menu/README.zh-CN.md | 8 ++++++-- src/dropdown-menu/demo/index.vue | 14 +++++++++++--- src/style/var.less | 4 ++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/dropdown-menu/README.md b/src/dropdown-menu/README.md index d3b5526be..0805893f3 100644 --- a/src/dropdown-menu/README.md +++ b/src/dropdown-menu/README.md @@ -50,7 +50,11 @@ export default { - Confirm +
                                              + + Confirm + +
                                              ``` @@ -112,7 +116,7 @@ Use `active-color` prop to custom active color of the title and options | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| active-color | Active color of title and option | _string_ | `#1989fa` | +| active-color | Active color of title and option | _string_ | `#ee0a24` | | direction `v2.0.1` | Expand direction, can be set to `up` | _string_ | `down` | | z-index | z-index of menu item | _number \| string_ | `10` | | duration | Transition duration, unit second | _number \| string_ | `0.2` | diff --git a/src/dropdown-menu/README.zh-CN.md b/src/dropdown-menu/README.zh-CN.md index 2336c71d6..ac1547b93 100644 --- a/src/dropdown-menu/README.zh-CN.md +++ b/src/dropdown-menu/README.zh-CN.md @@ -52,7 +52,11 @@ export default { - 确认 +
                                              + + 确认 + +
                                              ``` @@ -116,7 +120,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| active-color | 菜单标题和选项的选中态颜色 | _string_ | `#1989fa` | +| active-color | 菜单标题和选项的选中态颜色 | _string_ | `#ee0a24` | | direction `v2.0.1` | 菜单展开方向,可选值为`up` | _string_ | `down` | | z-index | 菜单栏 z-index 层级 | _number \| string_ | `10` | | duration | 动画时长,单位秒 | _number \| string_ | `0.2` | diff --git a/src/dropdown-menu/demo/index.vue b/src/dropdown-menu/demo/index.vue index 18e8ef119..4eeb25073 100644 --- a/src/dropdown-menu/demo/index.vue +++ b/src/dropdown-menu/demo/index.vue @@ -13,9 +13,17 @@ - - {{ t('confirm') }} - +
                                              + + {{ t('confirm') }} + +
                                              diff --git a/src/style/var.less b/src/style/var.less index 9919d8597..5989aea32 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -331,11 +331,11 @@ @dropdown-menu-background-color: @white; @dropdown-menu-title-font-size: 15px; @dropdown-menu-title-text-color: @text-color; -@dropdown-menu-title-active-text-color: @blue; +@dropdown-menu-title-active-text-color: @red; @dropdown-menu-title-disabled-text-color: @gray-6; @dropdown-menu-title-padding: 0 @padding-xs; @dropdown-menu-title-line-height: @line-height-lg; -@dropdown-menu-option-active-color: @blue; +@dropdown-menu-option-active-color: @red; @dropdown-menu-content-max-height: 80%; @dropdown-item-z-index: 10; From aca86a8c212dfbae897bf3535475cfb40f95dc7d Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 25 Jul 2020 09:57:48 +0800 Subject: [PATCH 41/51] fix(Field): failed to reset validation when message is empty (#6867) * fix(Field): failed to reset validation when message is empty * fix: test case --- src/field/index.js | 2 +- .../test/__snapshots__/methods.spec.js.snap | 19 ----------- src/form/test/methods.spec.js | 34 +++++++++++++++---- 3 files changed, 28 insertions(+), 27 deletions(-) delete mode 100644 src/form/test/__snapshots__/methods.spec.js.snap diff --git a/src/field/index.js b/src/field/index.js index abf59cb12..8150656f3 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -282,7 +282,7 @@ export default createComponent({ }, resetValidation() { - if (this.validateMessage) { + if (this.validateFailed) { this.validateFailed = false; this.validateMessage = ''; } diff --git a/src/form/test/__snapshots__/methods.spec.js.snap b/src/form/test/__snapshots__/methods.spec.js.snap deleted file mode 100644 index 6c019b6b1..000000000 --- a/src/form/test/__snapshots__/methods.spec.js.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`resetValidation method - reset one field 1`] = ` -
                                              -
                                              -
                                              -
                                              -
                                              -
                                              -
                                              -
                                              -
                                              -
                                              B failed
                                              -
                                              -
                                              -
                                              -`; diff --git a/src/form/test/methods.spec.js b/src/form/test/methods.spec.js index d00cd0679..5acb4549b 100644 --- a/src/form/test/methods.spec.js +++ b/src/form/test/methods.spec.js @@ -50,12 +50,12 @@ test('validate method - validate one field and passed', (done) => { test('validate method - validate one field and failed', (done) => { mountForm({ - template: ` - - - - - + template: ` + + + + + `, data: getSimpleRules, mounted() { @@ -90,7 +90,27 @@ test('resetValidation method - reset one field', (done) => { mounted() { this.$refs.form.validate().catch(() => { this.$refs.form.resetValidation('A'); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.findAll('.van-field--error').length).toEqual(1); + this.$refs.form.resetValidation('B'); + expect(wrapper.findAll('.van-field--error').length).toEqual(0); + done(); + }); + }, + }); +}); + +test('resetValidation method - reset when rule message is empty', (done) => { + const wrapper = mountSimpleRulesForm({ + data() { + return { + rulesA: [{ required: true, message: '' }], + rulesB: [{ required: true, message: '' }], + }; + }, + mounted() { + this.$refs.form.validate().catch(() => { + this.$refs.form.resetValidation('A'); + expect(wrapper.findAll('.van-field--error').length).toEqual(1); done(); }); }, From b7a7e48eea4da53c9e2971c45959f564a9e5ca8d Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 25 Jul 2020 10:18:00 +0800 Subject: [PATCH 42/51] docs(Stepper): add value type faq (#6868) * docs(Stepper): add value type faq * docs: remove space --- src/stepper/README.zh-CN.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stepper/README.zh-CN.md b/src/stepper/README.zh-CN.md index f8c03d49b..9043c3394 100644 --- a/src/stepper/README.zh-CN.md +++ b/src/stepper/README.zh-CN.md @@ -167,3 +167,15 @@ export default { | minus | 点击减少按钮时触发 | - | | focus | 输入框聚焦时触发 | _event: Event_ | | blur | 输入框失焦时触发 | _event: Event_ | + +## 常见问题 + +### 为什么 value 有时候会变成 string 类型? + +这是因为用户输入过程中可能出现小数点或空值,比如 `1.`,这种情况下组件会抛出字符串类型。 + +如果希望 value 保持 number 类型,可以在 v-model 上添加 `number` 修饰符: + +```html + +``` From 08a554c5a218666b82293ee28b9794741a712700 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 25 Jul 2020 10:36:45 +0800 Subject: [PATCH 43/51] feat(AddressEdit): add tel-maxlength prop (#6869) --- src/address-edit/README.md | 1 + src/address-edit/README.zh-CN.md | 1 + src/address-edit/index.js | 6 ++++-- src/address-edit/test/index.spec.js | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/address-edit/README.md b/src/address-edit/README.md index b2419a84d..f92f8122a 100644 --- a/src/address-edit/README.md +++ b/src/address-edit/README.md @@ -86,6 +86,7 @@ export default { | is-saving | Whether to show save button loading status | _boolean_ | `false` | | is-deleting | Whether to show delete button loading status | _boolean_ | `false` | | tel-validator | The method to validate tel | _(tel: string) => boolean_ | - | +| tel-maxlength `v2.10.0` | Tel maxlength | _number \| string_ | - | | postal-validator `v2.1.2` | The method to validate postal | _(tel: string) => boolean_ | - | | validator | Custom validator | _(key, val) => string_ | - | diff --git a/src/address-edit/README.zh-CN.md b/src/address-edit/README.zh-CN.md index e9eb5d4b9..a0d7fe29b 100644 --- a/src/address-edit/README.zh-CN.md +++ b/src/address-edit/README.zh-CN.md @@ -86,6 +86,7 @@ export default { | is-saving | 是否显示保存按钮加载动画 | _boolean_ | `false` | | is-deleting | 是否显示删除按钮加载动画 | _boolean_ | `false` | | tel-validator | 手机号格式校验函数 | _string => boolean_ | - | +| tel-maxlength `v2.10.0` | 手机号最大长度 | _number \| string_ | - | | postal-validator `v2.1.2` | 邮政编码格式校验函数 | _string => boolean_ | - | | validator | 自定义校验函数 | _(key, val) => string_ | - | diff --git a/src/address-edit/index.js b/src/address-edit/index.js index ba7267c89..f810496f7 100644 --- a/src/address-edit/index.js +++ b/src/address-edit/index.js @@ -40,11 +40,12 @@ export default createComponent({ showDelete: Boolean, showPostal: Boolean, searchResult: Array, + telMaxlength: [Number, String], showSetDefault: Boolean, - showSearchResult: Boolean, saveButtonText: String, - deleteButtonText: String, areaPlaceholder: String, + deleteButtonText: String, + showSearchResult: Boolean, showArea: { type: Boolean, default: true, @@ -283,6 +284,7 @@ export default createComponent({ clearable type="tel" label={t('tel')} + maxlength={this.telMaxlength} placeholder={t('telPlaceholder')} errorMessage={errorInfo.tel} onFocus={onFocus('tel')} diff --git a/src/address-edit/test/index.spec.js b/src/address-edit/test/index.spec.js index 2af606077..376133a9d 100644 --- a/src/address-edit/test/index.spec.js +++ b/src/address-edit/test/index.spec.js @@ -1,6 +1,6 @@ import AddressEdit from '..'; import areaList from '../../area/demo/area-simple'; -import { mount, later } from '../../../test'; +import { mount, later, trigger } from '../../../test'; const addressInfo = { name: '测试', @@ -306,3 +306,17 @@ test('click-area event', () => { field.trigger('click'); expect(wrapper.emitted('click-area')[0]).toBeTruthy(); }); + +test('tel-maxlength prop', () => { + const wrapper = mount(AddressEdit, { + propsData: { + telMaxlength: 4, + }, + }); + + const telInput = wrapper.find('input[type="tel"]'); + telInput.element.value = '123456'; + trigger(telInput, 'input'); + + expect(telInput.element.value).toEqual('1234'); +}); From 2328983afa8dac675f8c43ce1c9368c248bc5a08 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 25 Jul 2020 10:47:47 +0800 Subject: [PATCH 44/51] feat(NumberKeyboard): add get-container prop (#6870) --- src/mixins/portal.js | 2 +- src/number-keyboard/README.md | 1 + src/number-keyboard/README.zh-CN.md | 1 + src/number-keyboard/index.js | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mixins/portal.js b/src/mixins/portal.js index 3ed88ef2d..ec3e65f26 100644 --- a/src/mixins/portal.js +++ b/src/mixins/portal.js @@ -6,7 +6,7 @@ function getElement(selector) { return selector(); } -export function PortalMixin({ ref, afterPortal }) { +export function PortalMixin({ ref, afterPortal } = {}) { return { props: { getContainer: [String, Function], diff --git a/src/number-keyboard/README.md b/src/number-keyboard/README.md index 67faf36b7..ba612b0e8 100644 --- a/src/number-keyboard/README.md +++ b/src/number-keyboard/README.md @@ -160,6 +160,7 @@ export default { | close-button-loading `v2.7.0` | Whether to show loading close button in custom theme | _boolean_ | `false` | | show-delete-key `v2.5.9` | Whether to show delete button | _boolean_ | `true` | | hide-on-click-outside | Whether to hide keyboard when click outside | _boolean_ | `true` | +| get-container `v2.10.0` | Return the mount node for NumberKeyboard | _string \| () => Element_ | - | | safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` | ### Events diff --git a/src/number-keyboard/README.zh-CN.md b/src/number-keyboard/README.zh-CN.md index 24bea797a..4228b1b9a 100644 --- a/src/number-keyboard/README.zh-CN.md +++ b/src/number-keyboard/README.zh-CN.md @@ -173,6 +173,7 @@ export default { | close-button-loading `v2.7.0` | 是否将关闭按钮设置为加载中状态,仅在 `theme="custom"` 时有效 | _boolean_ | `false` | | show-delete-key `v2.5.9` | 是否展示删除图标 | _boolean_ | `true` | | hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` | +| get-container `v2.10.0` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - | | safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` | ### Events diff --git a/src/number-keyboard/index.js b/src/number-keyboard/index.js index ebd1c85f8..3ea42df30 100644 --- a/src/number-keyboard/index.js +++ b/src/number-keyboard/index.js @@ -1,5 +1,6 @@ import { createNamespace } from '../utils'; import { stopPropagation } from '../utils/dom/event'; +import { PortalMixin } from '../mixins/portal'; import { BindEventMixin } from '../mixins/bind-event'; import Key from './Key'; @@ -7,6 +8,7 @@ const [createComponent, bem] = createNamespace('number-keyboard'); export default createComponent({ mixins: [ + PortalMixin(), BindEventMixin(function (bind) { if (this.hideOnClickOutside) { bind(document.body, 'touchstart', this.onBlur); From cdf3bebfab194f3cc3a39ac8229b4e07c7b1f8d2 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 25 Jul 2020 14:28:29 +0800 Subject: [PATCH 45/51] docs(Button): update demo (#6871) --- src/button/README.md | 18 ++++----- src/button/README.zh-CN.md | 40 +++++++++---------- src/button/demo/index.vue | 12 +++--- .../test/__snapshots__/demo.spec.js.snap | 14 +++---- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/button/README.md b/src/button/README.md index 3414b3b30..922c2de2b 100644 --- a/src/button/README.md +++ b/src/button/README.md @@ -14,9 +14,9 @@ Vue.use(Button); ### Type ```html -Default Primary Info +Default Danger Warning ``` @@ -60,11 +60,11 @@ Vue.use(Button); ### Icon ```html - -Button -Button + +Button + + Button + ``` ### Size @@ -94,9 +94,9 @@ Vue.use(Button); ```html Pure Pure -Gradient + + Gradient + ``` ## API diff --git a/src/button/README.zh-CN.md b/src/button/README.zh-CN.md index 092bd1211..8c01ac951 100644 --- a/src/button/README.zh-CN.md +++ b/src/button/README.zh-CN.md @@ -13,19 +13,19 @@ Vue.use(Button); ### 按钮类型 -支持`default`、`primary`、`info`、`warning`、`danger`五种类型,默认为`default` +按钮支持 `default`、`primary`、`info`、`warning`、`danger` 五种类型,默认为 `default`。 ```html -默认按钮 主要按钮 信息按钮 +默认按钮 警告按钮 危险按钮 ``` ### 朴素按钮 -通过`plain`属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。 +通过 `plain` 属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。 ```html 朴素按钮 @@ -34,7 +34,7 @@ Vue.use(Button); ### 细边框 -设置`hairline`属性可以开启 0.5px 边框,基于伪类实现 +设置 `hairline` 属性可以展示 0.5px 的细边框。 ```html 细边框按钮 @@ -43,7 +43,7 @@ Vue.use(Button); ### 禁用状态 -通过`disabled`属性来禁用按钮,禁用状态下按钮不可点击 +通过 `disabled` 属性来禁用按钮,禁用状态下按钮不可点击。 ```html 禁用状态 @@ -52,7 +52,7 @@ Vue.use(Button); ### 加载状态 -通过`loading`属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过`loading-text`设置加载状态下的文字 +通过 `loading` 属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过 `loading-text` 设置加载状态下的文字。 ```html @@ -62,7 +62,7 @@ Vue.use(Button); ### 按钮形状 -通过`square`设置方形按钮,通过`round`设置圆形按钮 +通过 `square` 设置方形按钮,通过 `round` 设置圆形按钮。 ```html 方形按钮 @@ -71,19 +71,19 @@ Vue.use(Button); ### 图标按钮 -通过`icon`属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL +通过 `icon` 属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL。 ```html - -按钮 -按钮 + +按钮 + + 按钮 + ``` ### 按钮尺寸 -支持`large`、`normal`、`small`、`mini`四种尺寸,默认为`normal` +支持 `large`、`normal`、`small`、`mini` 四种尺寸,默认为 `normal`。 ```html 大号按钮 @@ -94,7 +94,7 @@ Vue.use(Button); ### 块级元素 -按钮在默认情况下为行内块级元素,通过`block`属性可以将按钮的元素类型设置为块级元素 +按钮在默认情况下为行内块级元素,通过 `block` 属性可以将按钮的元素类型设置为块级元素。 ```html 块级元素 @@ -102,7 +102,7 @@ Vue.use(Button); ### 页面导航 -可以通过`url`属性进行 URL 跳转,或通过`to`属性进行路由跳转 +可以通过 `url` 属性进行 URL 跳转,或通过 `to` 属性进行路由跳转。 ```html URL 跳转 @@ -111,14 +111,14 @@ Vue.use(Button); ### 自定义颜色 -通过`color`属性可以自定义按钮的颜色 +通过 `color` 属性可以自定义按钮的颜色。 ```html 单色按钮 单色按钮 -渐变色按钮 + + 渐变色按钮 + ``` ## API diff --git a/src/button/demo/index.vue b/src/button/demo/index.vue index 2eb52e3bd..befe6c9b4 100644 --- a/src/button/demo/index.vue +++ b/src/button/demo/index.vue @@ -2,9 +2,9 @@
                                              - {{ t('default') }} {{ t('primary') }} {{ t('info') }} + {{ t('default') }}
                                              {{ t('danger') }} {{ t('warning') }} @@ -37,12 +37,12 @@
                                              - - + + @@ -71,7 +71,7 @@ diff --git a/src/button/test/__snapshots__/demo.spec.js.snap b/src/button/test/__snapshots__/demo.spec.js.snap index 9d218df71..466a4c918 100644 --- a/src/button/test/__snapshots__/demo.spec.js.snap +++ b/src/button/test/__snapshots__/demo.spec.js.snap @@ -3,12 +3,12 @@ exports[`renders demo correctly 1`] = `
                                              -