mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
feat(ActionSheet): add closeable prop (#7099)
* feat(ActionSheet): add closeable prop * feat(ActionSheet): add closeable prop * Update index.tsx Co-authored-by: neverland <chenjiahan@youzan.com>
This commit is contained in:
parent
d0eb103cba
commit
b62c0e32cf
@ -155,6 +155,7 @@ export default {
|
|||||||
| title | Title | _string_ | - |
|
| title | Title | _string_ | - |
|
||||||
| cancel-text | Text of cancel button | _string_ | - |
|
| cancel-text | Text of cancel button | _string_ | - |
|
||||||
| description | Description above the options | _string_ | - |
|
| description | Description above the options | _string_ | - |
|
||||||
|
| closeable `v2.10.5` | Whether to show close icon | _boolean_ | `true` |
|
||||||
| close-icon | Close icon name | _string_ | `cross` |
|
| close-icon | Close icon name | _string_ | `cross` |
|
||||||
| duration | Transition duration, unit second | _number \| string_ | `0.3` |
|
| duration | Transition duration, unit second | _number \| string_ | `0.3` |
|
||||||
| round | Whether to show round corner | _boolean_ | `true` |
|
| round | Whether to show round corner | _boolean_ | `true` |
|
||||||
|
@ -161,6 +161,7 @@ export default {
|
|||||||
| title | 顶部标题 | _string_ | - |
|
| title | 顶部标题 | _string_ | - |
|
||||||
| cancel-text | 取消按钮文字 | _string_ | - |
|
| cancel-text | 取消按钮文字 | _string_ | - |
|
||||||
| description | 选项上方的描述信息 | _string_ | - |
|
| description | 选项上方的描述信息 | _string_ | - |
|
||||||
|
| closeable `v2.10.5` | 是否显示关闭图标 | _boolean_ | `true` |
|
||||||
| close-icon | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` |
|
| close-icon | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` |
|
||||||
| duration | 动画时长,单位秒 | _number \| string_ | `0.3` |
|
| duration | 动画时长,单位秒 | _number \| string_ | `0.3` |
|
||||||
| round | 是否显示圆角 | _boolean_ | `true` |
|
| round | 是否显示圆角 | _boolean_ | `true` |
|
||||||
|
@ -30,6 +30,7 @@ export type ActionSheetProps = PopupMixinProps & {
|
|||||||
title?: string;
|
title?: string;
|
||||||
actions?: ActionSheetItem[];
|
actions?: ActionSheetItem[];
|
||||||
duration: number | string;
|
duration: number | string;
|
||||||
|
closeable?: boolean;
|
||||||
closeIcon: string;
|
closeIcon: string;
|
||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
@ -50,7 +51,7 @@ function ActionSheet(
|
|||||||
slots: ActionSheetSlots,
|
slots: ActionSheetSlots,
|
||||||
ctx: RenderContext<ActionSheetProps>
|
ctx: RenderContext<ActionSheetProps>
|
||||||
) {
|
) {
|
||||||
const { title, cancelText } = props;
|
const { title, cancelText, closeable } = props;
|
||||||
|
|
||||||
function onCancel() {
|
function onCancel() {
|
||||||
emit(ctx, 'input', false);
|
emit(ctx, 'input', false);
|
||||||
@ -62,11 +63,13 @@ function ActionSheet(
|
|||||||
return (
|
return (
|
||||||
<div class={bem('header')}>
|
<div class={bem('header')}>
|
||||||
{title}
|
{title}
|
||||||
|
{closeable && (
|
||||||
<Icon
|
<Icon
|
||||||
name={props.closeIcon}
|
name={props.closeIcon}
|
||||||
class={bem('close')}
|
class={bem('close')}
|
||||||
onClick={onCancel}
|
onClick={onCancel}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -179,6 +182,10 @@ ActionSheet.props = {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
closeable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
closeIcon: {
|
closeIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'cross',
|
default: 'cross',
|
||||||
|
@ -198,3 +198,15 @@ test('close-icon prop', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('closeable prop', () => {
|
||||||
|
const wrapper = mount(ActionSheet, {
|
||||||
|
propsData: {
|
||||||
|
value: true,
|
||||||
|
title: 'Title',
|
||||||
|
closeable: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user