From 17bd32491f0015ec24327f6fc1720c1023009731 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 20 Sep 2020 10:12:55 +0800 Subject: [PATCH 1/9] chore(FIeld): remove unused code (#7212) --- src/field/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/field/index.js b/src/field/index.js index eff30d6ba..4bc2cb8e5 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -317,8 +317,6 @@ export default createComponent({ if (value !== this.value) { this.$emit('input', value); } - - this.currentValue = value; }, onInput(event) { From f609c224b19e316834edb6c46ed3e09cea53af44 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 20 Sep 2020 10:13:05 +0800 Subject: [PATCH 2/9] docs(Tab): title slot can be dynamic (#7213) --- src/tab/README.zh-CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index ba61dbe7b..77a10cb63 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -289,7 +289,7 @@ export default { ### Tab Slots -| 名称 | 说明 | -| ------- | -------------------------- | -| default | 标签页内容 | -| title | 自定义标题,不支持动态渲染 | +| 名称 | 说明 | +| ------- | ---------- | +| default | 标签页内容 | +| title | 自定义标题 | From e201bc55ee5670630b20e7d611da18f347b8b8ef Mon Sep 17 00:00:00 2001 From: JSparow Date: Mon, 21 Sep 2020 21:29:09 +0800 Subject: [PATCH 3/9] feat(SidebarItem): add title slot (#7220) --- src/sidebar-item/index.js | 2 +- src/sidebar/README.md | 6 ++++++ src/sidebar/README.zh-CN.md | 6 ++++++ .../test/__snapshots__/index.spec.js.snap | 9 +++++++++ src/sidebar/test/index.spec.js | 19 +++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/sidebar/test/__snapshots__/index.spec.js.snap diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js index 54d587f1d..058eb77d5 100644 --- a/src/sidebar-item/index.js +++ b/src/sidebar-item/index.js @@ -43,7 +43,7 @@ export default createComponent({ onClick={this.onClick} >
- {this.title} + {this.slots('title') ?? this.title} +
Title Slot + +
+
+`; diff --git a/src/sidebar/test/index.spec.js b/src/sidebar/test/index.spec.js index a3e533410..966eb72d0 100644 --- a/src/sidebar/test/index.spec.js +++ b/src/sidebar/test/index.spec.js @@ -76,3 +76,22 @@ test('without parent', () => { expect(err).toBeTruthy(); } }); + +test('title slot', () => { + const wrapper = mount({ + template: ` + + + + + + `, + data() { + return { + active: 0, + }; + }, + }); + + expect(wrapper).toMatchSnapshot(); +}); From e59fa850e3707c35d322827241470229539aed8d Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 21 Sep 2020 21:31:58 +0800 Subject: [PATCH 4/9] chore: release 2.10.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57e2bf82d..76ffa36be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vant", - "version": "2.10.7", + "version": "2.10.8", "description": "Mobile UI Components built on Vue", "main": "lib/index.js", "module": "es/index.js", From 43da00b724974070152a5de84b132fb0c09679a9 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 21 Sep 2020 21:36:15 +0800 Subject: [PATCH 5/9] docs(changelog): 2.10.8 --- docs/markdown/changelog.en-US.md | 17 +++++++++++++++++ docs/markdown/changelog.zh-CN.md | 17 +++++++++++++++++ src/sidebar/README.md | 6 +++--- src/sidebar/README.zh-CN.md | 14 +++++++------- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 7a78d30a6..f5c1f83e9 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -10,6 +10,23 @@ 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.10.8](https://github.com/youzan/vant/compare/v2.10.7...v2.10.8) + +`2020-09-21` + +**Feature** + +- SidebarItem: add title slot [#7220](https://github.com/youzan/vant/issues/7220) + +**Bug Fixes** + +- Calendar: incorrect month title [#7205](https://github.com/youzan/vant/issues/7205) +- CouponCell: discounted value [#7196](https://github.com/youzan/vant/issues/7196) +- Field: incorrect disabled color in iOS 14 [#7206](https://github.com/youzan/vant/issues/7206) +- List: scoped style not applied to first child [#7202](https://github.com/youzan/vant/issues/7202) +- Swipe: can't disable loop in some cases [#7208](https://github.com/youzan/vant/issues/7208) +- Swipe: incorrect indicator color trantision [#7207](https://github.com/youzan/vant/issues/7207) + ### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7) `2020-09-17` diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 32a7ea67a..d95cf46f7 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -10,6 +10,23 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 - 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。 - 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。 +### [v2.10.8](https://github.com/youzan/vant/compare/v2.10.7...v2.10.8) + +`2020-09-21` + +**Feature** + +- SidebarItem: 新增 title 插槽 [#7220](https://github.com/youzan/vant/issues/7220) + +**Bug Fixes** + +- Calendar: 修复月份标题展示错误的问题 [#7205](https://github.com/youzan/vant/issues/7205) +- CouponCell: 修复金额为 0 时取值逻辑错误的问题 [#7196](https://github.com/youzan/vant/issues/7196) +- Field: 修复在 iOS 14 上禁用时文字颜色过浅的问题 [#7206](https://github.com/youzan/vant/issues/7206) +- List: 修复个别情况下第一个子元素的 scoped 样式不生效的问题 [#7202](https://github.com/youzan/vant/issues/7202) +- Swipe: 修复宽度为小数时无法禁用循环滚动的问题 [#7208](https://github.com/youzan/vant/issues/7208) +- Swipe: 修复指示器切换时渐变动画闪烁的问题 [#7207](https://github.com/youzan/vant/issues/7207) + ### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7) `2020-09-17` diff --git a/src/sidebar/README.md b/src/sidebar/README.md index 1af8d17d1..72427ed27 100644 --- a/src/sidebar/README.md +++ b/src/sidebar/README.md @@ -113,6 +113,6 @@ export default { ### SidebarItem Slots -| Name | Description | -| ----- | ---------------- | -| title | Custom item title | +| Name | Description | +| --------------- | ----------------- | +| title `v2.10.8` | Custom item title | diff --git a/src/sidebar/README.zh-CN.md b/src/sidebar/README.zh-CN.md index ed21ca2f0..d79e01c25 100644 --- a/src/sidebar/README.zh-CN.md +++ b/src/sidebar/README.zh-CN.md @@ -14,7 +14,7 @@ Vue.use(SidebarItem); ### 基础用法 -通过`v-model`绑定当前选中项的索引 +通过 `v-model` 绑定当前选中项的索引。 ```html @@ -36,7 +36,7 @@ export default { ### 徽标提示 -设置`dot`属性后,会在右上角展示一个小红点。设置`badge`属性后,会在右上角展示相应的徽标 +设置 `dot` 属性后,会在右上角展示一个小红点;设置 `badge` 属性后,会在右上角展示相应的徽标。 ```html @@ -48,7 +48,7 @@ export default { ### 禁用选项 -通过`disabled`属性禁用选项 +通过 `disabled` 属性禁用选项。 ```html @@ -60,7 +60,7 @@ export default { ### 监听切换事件 -设置`change`方法来监听切换导航项时的事件 +设置 `change` 方法来监听切换导航项时的事件。 ```html @@ -122,6 +122,6 @@ export default { ### SidebarItem Slots -| Name | Description | -| ----- | ----------- | -| title | 自定义标题 | +| Name | Description | +| --------------- | ----------- | +| title `v2.10.8` | 自定义标题 | From 0642a73628810e05fe8c069d1008ea19820a21fa Mon Sep 17 00:00:00 2001 From: ChangeHow Date: Tue, 22 Sep 2020 18:51:33 +0800 Subject: [PATCH 6/9] feat(@vant/cli): suport modify internal webpack config (#7227) --- packages/vant-cli/src/common/index.ts | 18 +++++++++++------- .../vant-cli/src/config/webpack.package.ts | 8 +++----- .../vant-cli/src/config/webpack.site.dev.ts | 2 +- .../vant-cli/src/config/webpack.site.prd.ts | 8 +++----- packages/vant-cli/yarn.lock | 10 +++++----- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/vant-cli/src/common/index.ts b/packages/vant-cli/src/common/index.ts index a10b3bb4c..573801302 100644 --- a/packages/vant-cli/src/common/index.ts +++ b/packages/vant-cli/src/common/index.ts @@ -6,12 +6,14 @@ import { readFileSync, outputFileSync, } from 'fs-extra'; +import merge from 'webpack-merge'; import { SRC_DIR, getVantConfig, ROOT_WEBPACK_CONFIG_FILE, ROOT_POSTCSS_CONFIG_FILE, } from './constant'; +import { WebpackConfig } from './types'; export const EXT_REGEXP = /\.\w+$/; export const SFC_REGEXP = /\.(vue)$/; @@ -37,9 +39,9 @@ export function getComponents() { const EXCLUDES = ['.DS_Store']; const dirs = readdirSync(SRC_DIR); return dirs - .filter(dir => !EXCLUDES.includes(dir)) - .filter(dir => - ENTRY_EXTS.some(ext => { + .filter((dir) => !EXCLUDES.includes(dir)) + .filter((dir) => + ENTRY_EXTS.some((ext) => { const path = join(SRC_DIR, dir, `index.${ext}`); if (existsSync(path)) { return hasDefaultExport(readFileSync(path, 'utf-8')); @@ -99,18 +101,20 @@ export function normalizePath(path: string): string { return path.replace(/\\/g, '/'); } -export function getWebpackConfig(): object { +export function getWebpackConfig(defaultConfig: WebpackConfig): object { if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) { const config = require(ROOT_WEBPACK_CONFIG_FILE); + // 如果是函数形式,可能并不仅仅是添加额外的处理流程,而是在原有流程上进行修改 + // 比如修改markdown-loader,添加options.enableMetaData if (typeof config === 'function') { - return config(); + return config(defaultConfig); } - return config; + return merge(defaultConfig, config); } - return {}; + return defaultConfig; } export function getPostcssConfig(): object { diff --git a/packages/vant-cli/src/config/webpack.package.ts b/packages/vant-cli/src/config/webpack.package.ts index 752c034bd..58be3545b 100644 --- a/packages/vant-cli/src/config/webpack.package.ts +++ b/packages/vant-cli/src/config/webpack.package.ts @@ -10,9 +10,8 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig { setBuildTarget('package'); - return merge( - baseConfig as any, - { + return getWebpackConfig( + merge(baseConfig as any, { mode: 'production', entry: { [name]: join(ES_DIR, 'index.js'), @@ -39,7 +38,6 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig { optimization: { minimize: isMinify, }, - }, - getWebpackConfig() + }) ); } diff --git a/packages/vant-cli/src/config/webpack.site.dev.ts b/packages/vant-cli/src/config/webpack.site.dev.ts index 805b5c79c..0346e1428 100644 --- a/packages/vant-cli/src/config/webpack.site.dev.ts +++ b/packages/vant-cli/src/config/webpack.site.dev.ts @@ -103,5 +103,5 @@ export function getSiteDevBaseConfig(): WebpackConfig { } export function getSiteDevConfig(): WebpackConfig { - return merge(getSiteDevBaseConfig(), getWebpackConfig()); + return getWebpackConfig(getSiteDevBaseConfig()); } diff --git a/packages/vant-cli/src/config/webpack.site.prd.ts b/packages/vant-cli/src/config/webpack.site.prd.ts index 56ddd21a2..cf368e7be 100644 --- a/packages/vant-cli/src/config/webpack.site.prd.ts +++ b/packages/vant-cli/src/config/webpack.site.prd.ts @@ -10,9 +10,8 @@ const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR); const publicPath = get(vantConfig, 'build.site.publicPath', '/'); export function getSitePrdConfig(): WebpackConfig { - return merge( - getSiteDevBaseConfig(), - { + return getWebpackConfig( + merge(getSiteDevBaseConfig(), { mode: 'production', stats: 'none', performance: { @@ -25,7 +24,6 @@ export function getSitePrdConfig(): WebpackConfig { filename: '[name].[hash:8].js', chunkFilename: 'async_[name].[chunkhash:8].js', }, - }, - getWebpackConfig() + }) ); } diff --git a/packages/vant-cli/yarn.lock b/packages/vant-cli/yarn.lock index 171ff2e85..b6d7e56fd 100644 --- a/packages/vant-cli/yarn.lock +++ b/packages/vant-cli/yarn.lock @@ -1988,8 +1988,8 @@ "@vant/markdown-loader@^2.3.0": version "2.3.0" - resolved "https://registry.yarnpkg.com/@vant/markdown-loader/-/markdown-loader-2.3.0.tgz#ea8ab4d8d41609839b40b817bc3a598cf13f9920" - integrity sha512-efNAnJMQbX3yP0+/zvnlYda+xIATLl+T9BXOB179M8KkS3hKk0b8tYHYVeLmdCLbJFeVd8bVXICILIplOYQJ5A== + resolved "https://registry.npm.taobao.org/@vant/markdown-loader/download/@vant/markdown-loader-2.3.0.tgz#ea8ab4d8d41609839b40b817bc3a598cf13f9920" + integrity sha1-6oq02NQWCYObQLgXvDpZjPE/mSA= dependencies: front-matter "^3.0.2" highlight.js "^9.16.2" @@ -5901,9 +5901,9 @@ he@^1.2.0: integrity sha1-hK5l+n6vsWX922FWauFLrwVmTw8= highlight.js@^9.16.2: - version "9.18.1" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c" - integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg== + version "9.18.3" + resolved "https://registry.npm.taobao.org/highlight.js/download/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634" + integrity sha1-oaCiAo1eMUniOA+Khl7oUWcD1jQ= hmac-drbg@^1.0.0: version "1.0.1" From f2e2ea7c74649cca0fed307c4c01a704256469a2 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 22 Sep 2020 18:54:38 +0800 Subject: [PATCH 7/9] chore: release @vant/cli@2.5.4 --- packages/vant-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index 967bb252c..765e51ef2 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -1,6 +1,6 @@ { "name": "@vant/cli", - "version": "2.5.3", + "version": "2.5.4", "description": "", "main": "lib/index.js", "typings": "lib/index.d.ts", From 1eca65d05be4d3cd59a788dc14f722fcb54aa3ec Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 22 Sep 2020 18:56:42 +0800 Subject: [PATCH 8/9] docs(cli): changelog 2.5.4 --- packages/vant-cli/changelog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md index 59af26ecc..8d6ea215f 100644 --- a/packages/vant-cli/changelog.md +++ b/packages/vant-cli/changelog.md @@ -1,5 +1,11 @@ # 更新日志 +### v2.5.4 + +`2020-09-22` + +- 支持在 webpack.config.js 中修改内部 Webpack 配置 + ### v2.5.3 `2020-09-16` From 106114333b197cbfadbbdeb299326b59819f28dc Mon Sep 17 00:00:00 2001 From: JSparow Date: Tue, 22 Sep 2020 19:10:43 +0800 Subject: [PATCH 9/9] feat(Pagination): pagination item custom render (#7222) * feat(Pagination): pagination item custom render * fix(Pagination): fix test result * fix(Pagination): expose page object directly --- src/pagination/README.md | 22 +++++++++++++ src/pagination/README.zh-CN.md | 22 +++++++++++++ src/pagination/demo/index.vue | 19 ++++++++++++ src/pagination/index.js | 6 ++-- .../test/__snapshots__/demo.spec.js.snap | 13 ++++++++ .../test/__snapshots__/index.spec.js.snap | 25 +++++++++++++++ src/pagination/test/index.spec.js | 31 +++++++++++++++++++ 7 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 src/pagination/test/__snapshots__/index.spec.js.snap create mode 100644 src/pagination/test/index.spec.js diff --git a/src/pagination/README.md b/src/pagination/README.md index 42ca945df..ecdcb77d9 100644 --- a/src/pagination/README.md +++ b/src/pagination/README.md @@ -44,6 +44,20 @@ export default { /> ``` +### Custom Render + +```html + + + + + +``` + ## API ### Props @@ -65,3 +79,11 @@ export default { | Event | Description | Arguments | | ------ | ------------------------ | --------- | | change | Triggered on page change | - | + +### Slots + +| Name | Description | Default | +| --- | --- | --- | +| prev-text | custom prev slot | `-` | +| next-text | custom next slot | `-` | +| page | pagination item slot | `{ number: number, text: string, active: boolean }` | diff --git a/src/pagination/README.zh-CN.md b/src/pagination/README.zh-CN.md index 89a5dcb44..9363fd0c2 100644 --- a/src/pagination/README.zh-CN.md +++ b/src/pagination/README.zh-CN.md @@ -44,6 +44,20 @@ export default { /> ``` +### 自定义渲染 + +```html + + + + + +``` + ## API ### Props @@ -65,3 +79,11 @@ export default { | 事件名 | 说明 | 回调参数 | | ------ | -------------- | -------- | | change | 页码改变时触发 | - | + +### Slots + +| 名称 | 描述 | 默认值 | +| --- | --- | --- | +| prev-text | 自定义上一页插槽 | `-` | +| next-text | 自定义下一页插槽 | `-` | +| page | 自定义页码插槽 | `{ number: number, text: string, active: boolean }` | diff --git a/src/pagination/demo/index.vue b/src/pagination/demo/index.vue index ddeecf243..95b56d3c6 100644 --- a/src/pagination/demo/index.vue +++ b/src/pagination/demo/index.vue @@ -31,6 +31,22 @@ :next-text="t('nextText')" /> + + + + + + + + @@ -40,12 +56,14 @@ export default { 'zh-CN': { title2: '简单模式', title3: '显示省略号', + title4: '自定义渲染', prevText: '上一页', nextText: '下一页', }, 'en-US': { title2: 'Simple Mode', title3: 'Show ellipses', + title4: 'Custom Render', prevText: 'Prev', nextText: 'Next', }, @@ -56,6 +74,7 @@ export default { currentPage1: 1, currentPage2: 1, currentPage3: 1, + currentPage4: 1, }; }, }; diff --git a/src/pagination/index.js b/src/pagination/index.js index a0e07c29c..33cdc9f9f 100644 --- a/src/pagination/index.js +++ b/src/pagination/index.js @@ -131,14 +131,14 @@ export default createComponent({ class={[bem('item', { disabled: value === 1 }), bem('prev'), BORDER]} onClick={onSelect(value - 1)} > - {this.prevText || t('prev')} + {(this.slots('prev-text') ?? this.prevText) || t('prev')} {this.pages.map((page) => (
  • - {page.text} + {this.slots('page', page) ?? page.text}
  • ))} {simple && ( @@ -154,7 +154,7 @@ export default createComponent({ ]} onClick={onSelect(value + 1)} > - {this.nextText || t('next')} + {(this.slots('next-text') ?? this.nextText) || t('next')} ); diff --git a/src/pagination/test/__snapshots__/demo.spec.js.snap b/src/pagination/test/__snapshots__/demo.spec.js.snap index c4e54ef49..4b4c78a6a 100644 --- a/src/pagination/test/__snapshots__/demo.spec.js.snap +++ b/src/pagination/test/__snapshots__/demo.spec.js.snap @@ -30,5 +30,18 @@ exports[`renders demo correctly 1`] = `
  • 下一页
  • +
    +
      +
    • +
    • +
    • 1
    • +
    • 2
    • +
    • 3
    • +
    • 4
    • +
    • 5
    • +
    • +
    • +
    +
    `; diff --git a/src/pagination/test/__snapshots__/index.spec.js.snap b/src/pagination/test/__snapshots__/index.spec.js.snap new file mode 100644 index 000000000..440c7e3d6 --- /dev/null +++ b/src/pagination/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`render page slot 1`] = ` +
      +
    • 上一页
    • +
    • 1
    • +
    • 2
    • +
    • 3
    • +
    • 4
    • +
    • 5
    • +
    • 下一页
    • +
    +`; + +exports[`render prev-text & next-text slot 1`] = ` +
      +
    • Custom PrevText
    • +
    • 1
    • +
    • 2
    • +
    • 3
    • +
    • 4
    • +
    • 5
    • +
    • Custom NextText
    • +
    +`; diff --git a/src/pagination/test/index.spec.js b/src/pagination/test/index.spec.js new file mode 100644 index 000000000..3996c8532 --- /dev/null +++ b/src/pagination/test/index.spec.js @@ -0,0 +1,31 @@ +import { mount } from '../../../test'; +import Paginaion from '..' + +test('render prev-text & next-text slot', () => { + const wrapper = mount(Paginaion, { + propsData: { + totalItems: 50, + showPageSize: 5 + }, + scopedSlots: { + 'prev-text': () => 'Custom PrevText', + 'next-text': () => 'Custom NextText', + } + }); + + expect(wrapper).toMatchSnapshot(); +}); + +test('render page slot', () => { + const wrapper = mount(Paginaion, { + propsData: { + totalItems: 50, + showPageSize: 5 + }, + scopedSlots: { + 'page': ({ text }) => `${text}`, + } + }); + + expect(wrapper).toMatchSnapshot(); +});