mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(DatetimePicker): inherit correct props
This commit is contained in:
parent
18050f945a
commit
ed332daf31
@ -1,11 +1,14 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { createNamespace } from '../utils';
|
import { pick, createNamespace } from '../utils';
|
||||||
import { useExpose } from '../composition/use-expose';
|
import { useExpose } from '../composition/use-expose';
|
||||||
import TimePicker from './TimePicker';
|
import TimePicker from './TimePicker';
|
||||||
import DatePicker from './DatePicker';
|
import DatePicker from './DatePicker';
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('datetime-picker');
|
const [createComponent, bem] = createNamespace('datetime-picker');
|
||||||
|
|
||||||
|
const timePickerProps = Object.keys(TimePicker.props);
|
||||||
|
const datePickerProps = Object.keys(DatePicker.props);
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
...TimePicker.props,
|
...TimePicker.props,
|
||||||
@ -20,8 +23,20 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const Component = props.type === 'time' ? TimePicker : DatePicker;
|
const isTimePicker = props.type === 'time';
|
||||||
return <Component ref={root} class={bem()} {...{ ...props, ...attrs }} />;
|
const Component = isTimePicker ? TimePicker : DatePicker;
|
||||||
|
const inheritProps = pick(
|
||||||
|
props,
|
||||||
|
isTimePicker ? timePickerProps : datePickerProps
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Component
|
||||||
|
ref={root}
|
||||||
|
class={bem()}
|
||||||
|
{...{ ...inheritProps, ...attrs }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
exports[`should render demo and match snapshot 1`] = `
|
exports[`should render demo and match snapshot 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择年月日</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择年月日</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -176,7 +176,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择年月</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择年月</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -253,7 +253,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择月日</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择月日</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -405,7 +405,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" type="time" mindate="Fri Jan 01 2010 00:00:00 GMT+0800 (GMT+08:00)" maxdate="Tue Dec 31 2030 00:00:00 GMT+0800 (GMT+08:00)">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择时间</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择时间</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -641,7 +641,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择完整时间</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择完整时间</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1075,7 +1075,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选择年月日小时</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选择年月日小时</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1325,7 +1325,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" type="time" mindate="Fri Jan 01 2010 00:00:00 GMT+0800 (GMT+08:00)" maxdate="Tue Dec 31 2030 00:00:00 GMT+0800 (GMT+08:00)">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">选项过滤器</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">选项过滤器</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1456,7 +1456,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-picker van-datetime-picker" minhour="0" maxhour="23" minminute="0" maxminute="59">
|
<div class="van-picker van-datetime-picker">
|
||||||
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
<div class="van-picker__toolbar"><button type="button" class="van-picker__cancel">取消</button>
|
||||||
<div class="van-picker__title van-ellipsis">自定义列排序</div><button type="button" class="van-picker__confirm">确认</button>
|
<div class="van-picker__title van-ellipsis">自定义列排序</div><button type="button" class="van-picker__confirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user