Compare commits

...

3 Commits

Author SHA1 Message Date
neverland
22f832342a
docs(changelog): vant@4.0.0-rc.6 (#11169) 2022-10-23 23:07:31 +08:00
chenjiahan
59433115d9 release: 4.0.0-rc.6 2022-10-23 23:04:22 +08:00
neverland
6848550243
feat(Calendar): add params for subtitle slot (#11168)
* feat(Calendar): add params for subtitle slot

* chore: fix
2022-10-23 22:47:33 +08:00
9 changed files with 95 additions and 21 deletions

View File

@ -19,6 +19,23 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
## Details
### [v4.0.0-rc.6](https://github.com/vant-ui/vant/compare/v4.0.0-rc.5...v4.0.0-rc.6)
`2022-10-23`
**Feature**
- Calendar: add params for subtitle slot [#11168](https://github.com/vant-ui/vant/issues/11168)
- Cell: add tag prop [#11139](https://github.com/vant-ui/vant/issues/11139)
- ImagePreview: add image slot [#11133](https://github.com/vant-ui/vant/issues/11133)
- Toast: add wordBreak prop [#11147](https://github.com/vant-ui/vant/issues/11147)
**Bug Fixes**
- CouponList: fix the style of coupon checkbox [#11153](https://github.com/vant-ui/vant/issues/11153)
- CouponList: incorrect field style [#11155](https://github.com/vant-ui/vant/issues/11155)
- Swipe: failed to render when inside popup [#11162](https://github.com/vant-ui/vant/issues/11162)
### [v4.0.0-rc.5](https://github.com/vant-ui/vant/compare/v4.0.0-rc.4...v4.0.0-rc.5)
`2022-10-07`

View File

@ -19,6 +19,23 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
## 更新内容
### [v4.0.0-rc.6](https://github.com/vant-ui/vant/compare/v4.0.0-rc.5...v4.0.0-rc.6)
`2022-10-23`
**Feature**
- Calendar: subtitle 插槽新增 text 和 date 入参 [#11168](https://github.com/vant-ui/vant/issues/11168)
- Cell: 新增 tag 属性 [#11139](https://github.com/vant-ui/vant/issues/11139)
- ImagePreview: 新增 image 插槽 [#11133](https://github.com/vant-ui/vant/issues/11133)
- Toast: 新增 wordBreak 选项 [#11147](https://github.com/vant-ui/vant/issues/11147)
**Bug Fixes**
- CouponList: 修复 coupon 位置错误的问题 [#11153](https://github.com/vant-ui/vant/issues/11153)
- CouponList: 修复输入框样式错误的问题 [#11155](https://github.com/vant-ui/vant/issues/11155)
- Swipe: 修复在 Popup 内时个别情况下渲染错误的问题 [#11162](https://github.com/vant-ui/vant/issues/11162)
### [v4.0.0-rc.5](https://github.com/vant-ui/vant/compare/v4.0.0-rc.4...v4.0.0-rc.5)
`2022-10-07`

View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "4.0.0-rc.5",
"version": "4.0.0-rc.6",
"description": "Mobile UI Components built on Vue",
"main": "lib/vant.cjs.js",
"module": "es/index.mjs",

View File

@ -175,7 +175,10 @@ export default defineComponent({
const bodyRef = ref<HTMLElement>();
const subtitle = ref('');
const subtitle = ref<{ text: string; date?: Date }>({
text: '',
date: undefined,
});
const currentDate = ref(getInitialDate());
const [monthRefs, setMonthRefs] = useRefs<CalendarMonthInstance>();
@ -267,7 +270,10 @@ export default defineComponent({
/* istanbul ignore else */
if (currentMonth) {
subtitle.value = currentMonth.getTitle();
subtitle.value = {
text: currentMonth.getTitle(),
date: currentMonth.date,
};
}
};
@ -525,8 +531,9 @@ export default defineComponent({
<div class={bem()}>
<CalendarHeader
v-slots={pick(slots, ['title', 'subtitle'])}
date={subtitle.value.date}
title={props.title}
subtitle={subtitle.value}
subtitle={subtitle.value.text}
showTitle={props.showTitle}
showSubtitle={props.showSubtitle}
firstDayOfWeek={dayOffset.value}

View File

@ -8,6 +8,7 @@ export default defineComponent({
name,
props: {
date: Date,
title: String,
subtitle: String,
showTitle: Boolean,
@ -30,7 +31,12 @@ export default defineComponent({
const renderSubtitle = () => {
if (props.showSubtitle) {
const title = slots.subtitle ? slots.subtitle() : props.subtitle;
const title = slots.subtitle
? slots.subtitle({
date: props.date,
text: props.subtitle,
})
: props.subtitle;
return (
<div class={bem('header-subtitle')} onClick={onClickSubtitle}>
{title}

View File

@ -331,14 +331,14 @@ Following props are supported when the type is multiple
### Slots
| Name | Description | SlotProps |
| --------------------- | ------------------------- | ----------------------- |
| title | Custom title | - |
| subtitle `v3.1.3` | Custom subtitle | - |
| footer | Custom footer | - |
| confirm-text `v3.2.6` | Custom confirm text | _{ disabled: boolean }_ |
| top-info `v3.0.17` | Custom top info of day | _day: Day_ |
| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ |
| Name | Description | SlotProps |
| --- | --- | --- |
| title | Custom title | - |
| subtitle `v3.1.3` | Custom subtitle | _{ text: string, date?: Date }_ |
| footer | Custom footer | - |
| confirm-text `v3.2.6` | Custom confirm text | _{ disabled: boolean }_ |
| top-info `v3.0.17` | Custom top info of day | _day: Day_ |
| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ |
### Methods

View File

@ -337,14 +337,14 @@ export default {
### Slots
| 名称 | 说明 | 参数 |
| --------------------- | ------------------------ | ----------------------- |
| title | 自定义标题 | - |
| subtitle `v3.1.3` | 自定义日历副标题 | - |
| footer | 自定义底部区域内容 | - |
| confirm-text `v3.2.6` | 自定义确认按钮的内容 | _{ disabled: boolean }_ |
| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ |
| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ |
| 名称 | 说明 | 参数 |
| --- | --- | --- |
| title | 自定义标题 | - |
| subtitle `v3.1.3` | 自定义日历副标题 | _{ text: string, date?: Date }_ |
| footer | 自定义底部区域内容 | - |
| confirm-text `v3.2.6` | 自定义确认按钮的内容 | _{ disabled: boolean }_ |
| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ |
| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ |
### 方法

View File

@ -934,6 +934,12 @@ exports[`should render confirm-text slot correctly 1`] = `
</button>
`;
exports[`should render subtitle slot with params 1`] = `
<div class="van-calendar__header-subtitle">
Custom Subtitle
</div>
`;
exports[`should render title、footer、subtitle slot correctly 1`] = `
<div class="van-calendar">
<div class="van-calendar__header">

View File

@ -365,6 +365,27 @@ test('should render title、footer、subtitle slot correctly', async () => {
expect(wrapper.html()).toMatchSnapshot();
});
test('should render subtitle slot with params', async () => {
const wrapper = mount(Calendar, {
props: {
minDate,
maxDate,
poppable: false,
defaultDate: minDate,
lazyRender: false,
},
slots: {
subtitle: ({ text }) => `Custom Subtitle ${text}`,
},
});
await later();
expect(
wrapper.find('.van-calendar__header-subtitle').html()
).toMatchSnapshot();
});
test('should reset when type changed', async () => {
const wrapper = mount(Calendar, {
props: {