mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-06-05 18:08:10 +08:00
Compare commits
2 Commits
5c99ded59d
...
62a30bbf02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62a30bbf02 | ||
|
|
e87905c5bf |
12
README.md
12
README.md
@ -71,19 +71,25 @@ Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
|
|||||||
|
|
||||||
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||||
|
|
||||||
## Ecosystem
|
## Official Ecosystem
|
||||||
|
|
||||||
| Project | Description |
|
| Project | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
||||||
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI (maintained by the community) |
|
|
||||||
| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) |
|
|
||||||
| [vant-use](https://youzan.github.io/vant/vant-use/) | Collection of Vant Composition APIs |
|
| [vant-use](https://youzan.github.io/vant/vant-use/) | Collection of Vant Composition APIs |
|
||||||
| [vant-demo](https://github.com/youzan/vant-demo) | Collection of Vant demos |
|
| [vant-demo](https://github.com/youzan/vant-demo) | Collection of Vant demos |
|
||||||
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
| [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-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 |
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||||
|
|
||||||
|
## Community Ecosystem
|
||||||
|
|
||||||
|
| Project | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React |
|
||||||
|
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
|
||||||
|
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
- [Documentation](https://youzan.github.io/vant)
|
- [Documentation](https://youzan.github.io/vant)
|
||||||
|
|||||||
@ -33,19 +33,25 @@ Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
|
|||||||
|
|
||||||
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||||
|
|
||||||
### Ecosystem
|
### Official Ecosystem
|
||||||
|
|
||||||
| Project | Description |
|
| Project | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
||||||
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI (maintained by the community) |
|
|
||||||
| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) |
|
|
||||||
| [vant-use](https://youzan.github.io/vant/vant-use/) | Collection of Vant Composition APIs |
|
| [vant-use](https://youzan.github.io/vant/vant-use/) | Collection of Vant Composition APIs |
|
||||||
| [vant-demo](https://github.com/youzan/vant-demo) | Collection of Vant demos |
|
| [vant-demo](https://github.com/youzan/vant-demo) | Collection of Vant demos |
|
||||||
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
| [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-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 |
|
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||||
|
|
||||||
|
### Community Ecosystem
|
||||||
|
|
||||||
|
| Project | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React |
|
||||||
|
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
|
||||||
|
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
|
||||||
|
|
||||||
### Links
|
### Links
|
||||||
|
|
||||||
- [Feedback](https://github.com/youzan/vant/issues)
|
- [Feedback](https://github.com/youzan/vant/issues)
|
||||||
|
|||||||
@ -104,9 +104,20 @@ export default defineComponent({
|
|||||||
default: 0,
|
default: 0,
|
||||||
validator: (val: number) => val >= 0 && val <= 6,
|
validator: (val: number) => val >= 0 && val <= 6,
|
||||||
},
|
},
|
||||||
|
showRangePrompt: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['select', 'confirm', 'unselect', 'month-show', 'update:show'],
|
emits: [
|
||||||
|
'select',
|
||||||
|
'confirm',
|
||||||
|
'unselect',
|
||||||
|
'month-show',
|
||||||
|
'update:show',
|
||||||
|
'over-range',
|
||||||
|
],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const limitDateRange = (
|
const limitDateRange = (
|
||||||
@ -308,10 +319,13 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const checkRange = (date: [Date, Date]) => {
|
const checkRange = (date: [Date, Date]) => {
|
||||||
const { maxRange, rangePrompt } = props;
|
const { maxRange, rangePrompt, showRangePrompt } = props;
|
||||||
|
|
||||||
if (maxRange && calcDateNum(date) > maxRange) {
|
if (maxRange && calcDateNum(date) > maxRange) {
|
||||||
Toast(rangePrompt || t('rangePrompt', maxRange));
|
if (showRangePrompt) {
|
||||||
|
Toast(rangePrompt || t('rangePrompt', maxRange));
|
||||||
|
}
|
||||||
|
emit('over-range');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -290,6 +290,7 @@ Following props are supported when the type is range
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| max-range | Number of selectable days | _number \| string_ | Unlimited |
|
| max-range | Number of selectable days | _number \| string_ | Unlimited |
|
||||||
| range-prompt | Error message when exceeded max range | _string_ | `Choose no more than xx days` |
|
| range-prompt | Error message when exceeded max range | _string_ | `Choose no more than xx days` |
|
||||||
|
| show-range-prompt | Whether prompt error message when exceeded max range | _boolean_ | `true` |
|
||||||
| allow-same-day | Whether the start and end time of the range is allowed on the same day | _boolean_ | `false` |
|
| allow-same-day | Whether the start and end time of the range is allowed on the same day | _boolean_ | `false` |
|
||||||
|
|
||||||
### Calendar Multiple Props
|
### Calendar Multiple Props
|
||||||
@ -324,6 +325,7 @@ Following props are supported when the type is multiple
|
|||||||
| closed | Emitted when Popup is closed | - |
|
| closed | Emitted when Popup is closed | - |
|
||||||
| unselect | Emitted when unselect date when type is multiple | _value: Date_ |
|
| unselect | Emitted when unselect date when type is multiple | _value: Date_ |
|
||||||
| month-show | Emitted when a month enters the visible area | _{ date: Date, title: string }_ |
|
| month-show | Emitted when a month enters the visible area | _{ date: Date, title: string }_ |
|
||||||
|
| over-range | Emitted when exceeded max range | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|||||||
@ -294,6 +294,7 @@ export default {
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| max-range | 日期区间最多可选天数 | _number \| string_ | 无限制 |
|
| max-range | 日期区间最多可选天数 | _number \| string_ | 无限制 |
|
||||||
| range-prompt | 范围选择超过最多可选天数时的提示文案 | _string_ | `选择天数不能超过 xx 天` |
|
| range-prompt | 范围选择超过最多可选天数时的提示文案 | _string_ | `选择天数不能超过 xx 天` |
|
||||||
|
| show-range-prompt | 范围选择超过最多可选天数时,是否展示提示文案 | _boolean_ | `true` |
|
||||||
| allow-same-day | 是否允许日期范围的起止时间为同一天 | _boolean_ | `false` |
|
| allow-same-day | 是否允许日期范围的起止时间为同一天 | _boolean_ | `false` |
|
||||||
|
|
||||||
### Calendar Multiple Props
|
### Calendar Multiple Props
|
||||||
@ -330,6 +331,7 @@ export default {
|
|||||||
| closed | 关闭弹出层且动画结束后触发 | - |
|
| closed | 关闭弹出层且动画结束后触发 | - |
|
||||||
| unselect | 当日历组件的 `type` 为 `multiple` 时,取消选中日期时触发 | _value: Date_ |
|
| unselect | 当日历组件的 `type` 为 `multiple` 时,取消选中日期时触发 | _value: Date_ |
|
||||||
| month-show | 当某个月份进入可视区域时触发 | _{ date: Date, title: string }_ |
|
| month-show | 当某个月份进入可视区域时触发 | _{ date: Date, title: string }_ |
|
||||||
|
| over-range | 范围选择超过最多可选天数时触发 | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|||||||
@ -252,3 +252,50 @@ test('readonly prop', async () => {
|
|||||||
days[13].trigger('click');
|
days[13].trigger('click');
|
||||||
expect(wrapper.emitted('select')).toBeTruthy();
|
expect(wrapper.emitted('select')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should disabled prompt when using show-range-prompt prop', async () => {
|
||||||
|
document.getElementsByTagName('html')[0].innerHTML = '';
|
||||||
|
const wrapper = mount(Calendar, {
|
||||||
|
props: {
|
||||||
|
type: 'range',
|
||||||
|
minDate,
|
||||||
|
maxDate,
|
||||||
|
maxRange: 3,
|
||||||
|
poppable: false,
|
||||||
|
lazyRender: false,
|
||||||
|
showRangePrompt: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await later();
|
||||||
|
|
||||||
|
const days = wrapper.findAll('.van-calendar__day');
|
||||||
|
days[12].trigger('click');
|
||||||
|
days[18].trigger('click');
|
||||||
|
|
||||||
|
await later();
|
||||||
|
expect(document.querySelector('.van-toast')).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should emit over-range when exceeded max range', async () => {
|
||||||
|
const onOverRange = jest.fn();
|
||||||
|
const wrapper = mount(Calendar, {
|
||||||
|
props: {
|
||||||
|
type: 'range',
|
||||||
|
minDate,
|
||||||
|
maxDate,
|
||||||
|
maxRange: 3,
|
||||||
|
onOverRange,
|
||||||
|
poppable: false,
|
||||||
|
lazyRender: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await later();
|
||||||
|
|
||||||
|
const days = wrapper.findAll('.van-calendar__day');
|
||||||
|
days[12].trigger('click');
|
||||||
|
days[18].trigger('click');
|
||||||
|
|
||||||
|
expect(onOverRange).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user