Merge branch 'dev' into next

This commit is contained in:
chenjiahan 2020-09-22 19:42:24 +08:00
commit 8ef46764c9
20 changed files with 245 additions and 29 deletions

View File

@ -10,6 +10,23 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
- Minor versionreleased every one to two months, including backwards compatible features. - Minor versionreleased every one to two months, including backwards compatible features.
- Major versionincluding breaking changes and new features. - Major versionincluding 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) ### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7)
`2020-09-17` `2020-09-17`

View File

@ -10,6 +10,23 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
- 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。 - 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。
- 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。 - 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 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) ### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7)
`2020-09-17` `2020-09-17`

View File

@ -1,5 +1,11 @@
# 更新日志 # 更新日志
### v2.5.4
`2020-09-22`
- 支持在 webpack.config.js 中修改内部 Webpack 配置
### v2.5.3 ### v2.5.3
`2020-09-16` `2020-09-16`

View File

@ -6,12 +6,14 @@ import {
readFileSync, readFileSync,
outputFileSync, outputFileSync,
} from 'fs-extra'; } from 'fs-extra';
import merge from 'webpack-merge';
import { import {
SRC_DIR, SRC_DIR,
getVantConfig, getVantConfig,
ROOT_WEBPACK_CONFIG_FILE, ROOT_WEBPACK_CONFIG_FILE,
ROOT_POSTCSS_CONFIG_FILE, ROOT_POSTCSS_CONFIG_FILE,
} from './constant'; } from './constant';
import { WebpackConfig } from './types';
export const EXT_REGEXP = /\.\w+$/; export const EXT_REGEXP = /\.\w+$/;
export const SFC_REGEXP = /\.(vue)$/; export const SFC_REGEXP = /\.(vue)$/;
@ -100,21 +102,23 @@ export function normalizePath(path: string): string {
return path.replace(/\\/g, '/'); return path.replace(/\\/g, '/');
} }
export function getWebpackConfig(): object { export function getWebpackConfig(defaultConfig: WebpackConfig): WebpackConfig {
if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) { if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) {
const config = require(ROOT_WEBPACK_CONFIG_FILE); const config = require(ROOT_WEBPACK_CONFIG_FILE);
// 如果是函数形式,可能并不仅仅是添加额外的处理流程,而是在原有流程上进行修改
// 比如修改markdown-loader,添加options.enableMetaData
if (typeof config === 'function') { if (typeof config === 'function') {
return config(); return config(defaultConfig);
} }
return config; return merge(defaultConfig, config);
} }
return {}; return defaultConfig;
} }
export function getPostcssConfig(): object { export function getPostcssConfig() {
if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) { if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) {
return require(ROOT_POSTCSS_CONFIG_FILE); return require(ROOT_POSTCSS_CONFIG_FILE);
} }

View File

@ -10,9 +10,8 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig {
setBuildTarget('package'); setBuildTarget('package');
return merge( return getWebpackConfig(
baseConfig as any, merge(baseConfig as any, {
{
mode: 'production', mode: 'production',
entry: { entry: {
[name]: join(ES_DIR, 'index.js'), [name]: join(ES_DIR, 'index.js'),
@ -39,7 +38,6 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig {
optimization: { optimization: {
minimize: isMinify, minimize: isMinify,
}, },
}, })
getWebpackConfig()
); );
} }

View File

@ -103,5 +103,5 @@ export function getSiteDevBaseConfig(): WebpackConfig {
} }
export function getSiteDevConfig(): WebpackConfig { export function getSiteDevConfig(): WebpackConfig {
return merge(getSiteDevBaseConfig(), getWebpackConfig()); return getWebpackConfig(getSiteDevBaseConfig());
} }

View File

@ -10,9 +10,8 @@ const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
const publicPath = get(vantConfig, 'build.site.publicPath', '/'); const publicPath = get(vantConfig, 'build.site.publicPath', '/');
export function getSitePrdConfig(): WebpackConfig { export function getSitePrdConfig(): WebpackConfig {
return merge( return getWebpackConfig(
getSiteDevBaseConfig(), merge(getSiteDevBaseConfig(), {
{
mode: 'production', mode: 'production',
stats: 'none', stats: 'none',
performance: { performance: {
@ -25,7 +24,6 @@ export function getSitePrdConfig(): WebpackConfig {
filename: '[name].[hash:8].js', filename: '[name].[hash:8].js',
chunkFilename: 'async_[name].[chunkhash:8].js', chunkFilename: 'async_[name].[chunkhash:8].js',
}, },
}, })
getWebpackConfig()
); );
} }

View File

@ -45,6 +45,20 @@ export default {
/> />
``` ```
### Custom Render
```html
<van-pagination v-model="currentPage" :total-items="50" :show-page-size="5">
<template #prev-text>
<van-icon name="arrow-left" />
</template>
<template #next-text>
<van-icon name="arrow" />
</template>
<template #page="{ text }">{{ text }}</template>
</van-pagination>
```
## API ## API
### Props ### Props
@ -66,3 +80,11 @@ export default {
| Event | Description | Arguments | | Event | Description | Arguments |
| ------ | ------------------------ | --------- | | ------ | ------------------------ | --------- |
| change | Triggered on page change | - | | 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 }` |

View File

@ -45,6 +45,20 @@ export default {
/> />
``` ```
### 自定义渲染
```html
<van-pagination v-model="currentPage" :total-items="50" :show-page-size="5">
<template #prev-text>
<van-icon name="arrow-left" />
</template>
<template #next-text>
<van-icon name="arrow" />
</template>
<template #page="{ text }">{{ text }}</template>
</van-pagination>
```
## API ## API
### Props ### Props
@ -66,3 +80,11 @@ export default {
| 事件名 | 说明 | 回调参数 | | 事件名 | 说明 | 回调参数 |
| ------ | -------------- | -------- | | ------ | -------------- | -------- |
| change | 页码改变时触发 | - | | change | 页码改变时触发 | - |
### Slots
| 名称 | 描述 | 默认值 |
| --- | --- | --- |
| prev-text | 自定义上一页插槽 | `-` |
| next-text | 自定义下一页插槽 | `-` |
| page | 自定义页码插槽 | `{ number: number, text: string, active: boolean }` |

View File

@ -31,6 +31,22 @@
:next-text="t('nextText')" :next-text="t('nextText')"
/> />
</demo-block> </demo-block>
<demo-block :title="t('title4')">
<van-pagination
v-model="currentPage4"
:total-items="125"
:show-page-size="5"
>
<template #prev-text>
<van-icon name="arrow-left" />
</template>
<template #next-text>
<van-icon name="arrow" />
</template>
<template #page="{ text }">{{ text }}</template>
</van-pagination>
</demo-block>
</demo-section> </demo-section>
</template> </template>
@ -40,12 +56,14 @@ export default {
'zh-CN': { 'zh-CN': {
title2: '简单模式', title2: '简单模式',
title3: '显示省略号', title3: '显示省略号',
title4: '自定义渲染',
prevText: '上一页', prevText: '上一页',
nextText: '下一页', nextText: '下一页',
}, },
'en-US': { 'en-US': {
title2: 'Simple Mode', title2: 'Simple Mode',
title3: 'Show ellipses', title3: 'Show ellipses',
title4: 'Custom Render',
prevText: 'Prev', prevText: 'Prev',
nextText: 'Next', nextText: 'Next',
}, },
@ -56,6 +74,7 @@ export default {
currentPage1: 1, currentPage1: 1,
currentPage2: 1, currentPage2: 1,
currentPage3: 1, currentPage3: 1,
currentPage4: 1,
}; };
}, },
}; };

View File

@ -142,7 +142,9 @@ export default createComponent({
]} ]}
onClick={onSelect(value - 1)} onClick={onSelect(value - 1)}
> >
{props.prevText || t('prev')} {slots['prev-text']
? slots['prev-text']()
: props.prevText || t('prev')}
</li> </li>
{pages.value.map((page) => ( {pages.value.map((page) => (
<li <li
@ -153,7 +155,7 @@ export default createComponent({
]} ]}
onClick={onSelect(page.number)} onClick={onSelect(page.number)}
> >
{page.text} {slots.page ? slots.page(page) : page.text}
</li> </li>
))} ))}
{renderDesc()} {renderDesc()}
@ -165,7 +167,9 @@ export default createComponent({
]} ]}
onClick={onSelect(value + 1)} onClick={onSelect(value + 1)}
> >
{props.nextText || t('next')} {slots['next-text']
? slots['next-text']()
: props.nextText || t('next')}
</li> </li>
</ul> </ul>
); );

View File

@ -30,5 +30,18 @@ exports[`renders demo correctly 1`] = `
<li class="van-pagination__item van-pagination__next van-hairline">下一页</li> <li class="van-pagination__item van-pagination__next van-hairline">下一页</li>
</ul> </ul>
</div> </div>
<div>
<ul class="van-pagination">
<li class="van-pagination__item van-pagination__item--disabled van-pagination__prev van-hairline"><i class="van-icon van-icon-arrow-left">
<!----></i></li>
<li class="van-pagination__item van-pagination__item--active van-pagination__page van-hairline">1</li>
<li class="van-pagination__item van-pagination__page van-hairline">2</li>
<li class="van-pagination__item van-pagination__page van-hairline">3</li>
<li class="van-pagination__item van-pagination__page van-hairline">4</li>
<li class="van-pagination__item van-pagination__page van-hairline">5</li>
<li class="van-pagination__item van-pagination__next van-hairline"><i class="van-icon van-icon-arrow">
<!----></i></li>
</ul>
</div>
</div> </div>
`; `;

View File

@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`render page slot 1`] = `
<ul class="van-pagination">
<li class="van-pagination__item van-pagination__prev van-hairline">上一页</li>
<li class="van-pagination__item van-pagination__page van-hairline">1</li>
<li class="van-pagination__item van-pagination__page van-hairline">2</li>
<li class="van-pagination__item van-pagination__page van-hairline">3</li>
<li class="van-pagination__item van-pagination__page van-hairline">4</li>
<li class="van-pagination__item van-pagination__page van-hairline">5</li>
<li class="van-pagination__item van-pagination__next van-hairline">下一页</li>
</ul>
`;
exports[`render prev-text & next-text slot 1`] = `
<ul class="van-pagination">
<li class="van-pagination__item van-pagination__prev van-hairline">Custom PrevText</li>
<li class="van-pagination__item van-pagination__page van-hairline">1</li>
<li class="van-pagination__item van-pagination__page van-hairline">2</li>
<li class="van-pagination__item van-pagination__page van-hairline">3</li>
<li class="van-pagination__item van-pagination__page van-hairline">4</li>
<li class="van-pagination__item van-pagination__page van-hairline">5</li>
<li class="van-pagination__item van-pagination__next van-hairline">Custom NextText</li>
</ul>
`;

View File

@ -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();
});

View File

@ -17,7 +17,7 @@ export default createComponent({
emits: ['click'], emits: ['click'],
setup(props, { emit }) { setup(props, { emit, slots }) {
const route = useRoute(); const route = useRoute();
const { parent, index } = useParent(SIDEBAR_KEY); const { parent, index } = useParent(SIDEBAR_KEY);
@ -39,7 +39,7 @@ export default createComponent({
return ( return (
<a class={bem({ select: selected, disabled })} onClick={onClick}> <a class={bem({ select: selected, disabled })} onClick={onClick}>
<div class={bem('text')}> <div class={bem('text')}>
{title} {slots.title ? slots.title() : title}
<Badge dot={dot} badge={badge} class={bem('badge')} /> <Badge dot={dot} badge={badge} class={bem('badge')} />
</div> </div>
</a> </a>

View File

@ -111,3 +111,9 @@ export default {
| Event | Description | Arguments | | Event | Description | Arguments |
| ----- | ------------------------- | ---------------------------- | | ----- | ------------------------- | ---------------------------- |
| click | Triggered when click item | index: index of current item | | click | Triggered when click item | index: index of current item |
### SidebarItem Slots
| Name | Description |
| --------------- | ----------------- |
| title `v2.10.8` | Custom item title |

View File

@ -15,7 +15,7 @@ app.use(SidebarItem);
### 基础用法 ### 基础用法
通过`v-model`绑定当前选中项的索引 通过 `v-model` 绑定当前选中项的索引
```html ```html
<van-sidebar v-model="activeKey"> <van-sidebar v-model="activeKey">
@ -37,7 +37,7 @@ export default {
### 徽标提示 ### 徽标提示
设置`dot`属性后,会在右上角展示一个小红点。设置`badge`属性后,会在右上角展示相应的徽标 设置 `dot` 属性后,会在右上角展示一个小红点;设置 `badge` 属性后,会在右上角展示相应的徽标。
```html ```html
<van-sidebar v-model="activeKey"> <van-sidebar v-model="activeKey">
@ -49,7 +49,7 @@ export default {
### 禁用选项 ### 禁用选项
通过`disabled`属性禁用选项 通过 `disabled` 属性禁用选项
```html ```html
<van-sidebar v-model="activeKey"> <van-sidebar v-model="activeKey">
@ -61,7 +61,7 @@ export default {
### 监听切换事件 ### 监听切换事件
设置`change`方法来监听切换导航项时的事件 设置 `change` 方法来监听切换导航项时的事件
```html ```html
<van-sidebar v-model="activeKey" @change="onChange"> <van-sidebar v-model="activeKey" @change="onChange">
@ -119,3 +119,9 @@ export default {
| 事件名 | 说明 | 回调参数 | | 事件名 | 说明 | 回调参数 |
| ------ | ---------- | ----------------------- | | ------ | ---------- | ----------------------- |
| click | 点击时触发 | index: 当前导航项的索引 | | click | 点击时触发 | index: 当前导航项的索引 |
### SidebarItem Slots
| Name | Description |
| --------------- | ----------- |
| title `v2.10.8` | 自定义标题 |

View File

@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`title slot 1`] = `
<div class="van-sidebar"><a class="van-sidebar-item van-sidebar-item--select">
<div class="van-sidebar-item__text">Title Slot
<!---->
</div>
</a></div>
`;

View File

@ -76,3 +76,22 @@ test('without parent', () => {
expect(err).toBeTruthy(); expect(err).toBeTruthy();
} }
}); });
test('title slot', () => {
const wrapper = mount({
template: `
<van-sidebar v-model="active">
<van-sidebar-item>
<template #title>Title Slot</template>
</van-sidebar-item>
</van-sidebar>
`,
data() {
return {
active: 0,
};
},
});
expect(wrapper).toMatchSnapshot();
});

View File

@ -289,7 +289,7 @@ export default {
### Tab Slots ### Tab Slots
| 名称 | 说明 | | 名称 | 说明 |
| ------- | -------------------------- | | ------- | ---------- |
| default | 标签页内容 | | default | 标签页内容 |
| title | 自定义标题,不支持动态渲染 | | title | 自定义标题 |