mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-07-15 01:51:06 +08:00
Compare commits
2 Commits
ac85f82f09
...
be0de2023c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be0de2023c | ||
|
|
e36081d68a |
@ -165,14 +165,6 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -331,14 +323,6 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -410,14 +394,6 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -495,14 +471,6 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -36,14 +36,6 @@ exports[`should render columns-top、columns-bottom slot correctly 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
Bottom
|
Bottom
|
||||||
</div>
|
</div>
|
||||||
@ -130,14 +122,6 @@ exports[`should render two columns when columns-num prop is two 1`] = `
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -352,14 +352,29 @@ export default defineComponent({
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const renderMask = (wrapHeight: number) => {
|
||||||
|
const hasOptions = formattedColumns.value.some(
|
||||||
|
(item) => item[valuesKey] && item[valuesKey].length !== 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasOptions) {
|
||||||
|
const frameStyle = { height: `${itemHeight.value}px` };
|
||||||
|
const maskStyle = {
|
||||||
|
backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`,
|
||||||
|
};
|
||||||
|
return [
|
||||||
|
<div class={bem('mask')} style={maskStyle} />,
|
||||||
|
<div
|
||||||
|
class={[BORDER_UNSET_TOP_BOTTOM, bem('frame')]}
|
||||||
|
style={frameStyle}
|
||||||
|
/>,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderColumns = () => {
|
const renderColumns = () => {
|
||||||
const wrapHeight = itemHeight.value * +props.visibleItemCount;
|
const wrapHeight = itemHeight.value * +props.visibleItemCount;
|
||||||
const frameStyle = { height: `${itemHeight.value}px` };
|
|
||||||
const columnsStyle = { height: `${wrapHeight}px` };
|
const columnsStyle = { height: `${wrapHeight}px` };
|
||||||
const maskStyle = {
|
|
||||||
backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={bem('columns')}
|
class={bem('columns')}
|
||||||
@ -367,11 +382,7 @@ export default defineComponent({
|
|||||||
onTouchmove={preventDefault}
|
onTouchmove={preventDefault}
|
||||||
>
|
>
|
||||||
{renderColumnItems()}
|
{renderColumnItems()}
|
||||||
<div class={bem('mask')} style={maskStyle} />
|
{renderMask(wrapHeight)}
|
||||||
<div
|
|
||||||
class={[BORDER_UNSET_TOP_BOTTOM, bem('frame')]}
|
|
||||||
style={frameStyle}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -168,14 +168,6 @@ exports[`columns-top、columns-bottom prop 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
Custom Columns Bottom
|
Custom Columns Bottom
|
||||||
</div>
|
</div>
|
||||||
@ -403,14 +395,6 @@ exports[`should render confirm/cancel slot correctly 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -439,14 +423,6 @@ exports[`should render title slot correctly 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -465,14 +441,6 @@ exports[`should render toolbar slot correctly 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -488,14 +456,6 @@ exports[`toolbar-position prop 1`] = `
|
|||||||
>
|
>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__mask"
|
|
||||||
style="background-size: 100% 110px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="van-hairline-unset--top-bottom van-picker__frame"
|
|
||||||
style="height: 44px;"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="van-picker__toolbar">
|
<div class="van-picker__toolbar">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
|
|||||||
@ -345,3 +345,17 @@ test('readonly prop', () => {
|
|||||||
|
|
||||||
expect(wrapper.emitted('change')).toBeFalsy();
|
expect(wrapper.emitted('change')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not render mask and frame when options is empty', async () => {
|
||||||
|
const wrapper = mount(Picker, {
|
||||||
|
props: {
|
||||||
|
columns: [{ values: [] }],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(wrapper.find('.van-picker__mask').exists()).toBeFalsy();
|
||||||
|
expect(wrapper.find('.van-picker__frame').exists()).toBeFalsy();
|
||||||
|
|
||||||
|
await wrapper.setProps({ columns: [{ values: ['foo'] }] });
|
||||||
|
expect(wrapper.find('.van-picker__mask').exists()).toBeTruthy();
|
||||||
|
expect(wrapper.find('.van-picker__frame').exists()).toBeTruthy();
|
||||||
|
});
|
||||||
|
|||||||
@ -40,7 +40,15 @@ export default defineComponent({
|
|||||||
|
|
||||||
props: searchProps,
|
props: searchProps,
|
||||||
|
|
||||||
emits: ['search', 'cancel', 'update:modelValue'],
|
emits: [
|
||||||
|
'blur',
|
||||||
|
'focus',
|
||||||
|
'clear',
|
||||||
|
'search',
|
||||||
|
'cancel',
|
||||||
|
'click-input',
|
||||||
|
'update:modelValue',
|
||||||
|
],
|
||||||
|
|
||||||
setup(props, { emit, slots, attrs }) {
|
setup(props, { emit, slots, attrs }) {
|
||||||
const id = useId();
|
const id = useId();
|
||||||
@ -91,6 +99,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
const blur = () => filedRef.value?.blur();
|
const blur = () => filedRef.value?.blur();
|
||||||
const focus = () => filedRef.value?.focus();
|
const focus = () => filedRef.value?.focus();
|
||||||
|
const onBlur = (event: Event) => emit('blur', event);
|
||||||
|
const onFocus = (event: Event) => emit('focus', event);
|
||||||
|
const onClear = (event: MouseEvent) => emit('clear', event);
|
||||||
|
const onClickInput = (event: MouseEvent) => emit('click-input', event);
|
||||||
|
|
||||||
const fieldPropNames = Object.keys(fieldSharedProps) as Array<
|
const fieldPropNames = Object.keys(fieldSharedProps) as Array<
|
||||||
keyof typeof fieldSharedProps
|
keyof typeof fieldSharedProps
|
||||||
@ -110,7 +122,11 @@ export default defineComponent({
|
|||||||
type="search"
|
type="search"
|
||||||
class={bem('field')}
|
class={bem('field')}
|
||||||
border={false}
|
border={false}
|
||||||
|
onBlur={onBlur}
|
||||||
|
onFocus={onFocus}
|
||||||
|
onClear={onClear}
|
||||||
onKeypress={onKeypress}
|
onKeypress={onKeypress}
|
||||||
|
onClick-input={onClickInput}
|
||||||
onUpdate:modelValue={onInput}
|
onUpdate:modelValue={onInput}
|
||||||
{...fieldAttrs}
|
{...fieldAttrs}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user