mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(ActionSheet): rename unreleased slot (#10082)
This commit is contained in:
parent
45e7e15c2d
commit
b6b831ce72
@ -94,13 +94,13 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderOptionContent = (action: ActionSheetAction, index: number) => {
|
const renderActionContent = (action: ActionSheetAction, index: number) => {
|
||||||
if (action.loading) {
|
if (action.loading) {
|
||||||
return <Loading class={bem('loading-icon')} />;
|
return <Loading class={bem('loading-icon')} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slots.option) {
|
if (slots.action) {
|
||||||
return slots.option({ action, index });
|
return slots.action({ action, index });
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -109,7 +109,7 @@ export default defineComponent({
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderOption = (action: ActionSheetAction, index: number) => {
|
const renderAction = (action: ActionSheetAction, index: number) => {
|
||||||
const { color, loading, callback, disabled, className } = action;
|
const { color, loading, callback, disabled, className } = action;
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
@ -135,7 +135,7 @@ export default defineComponent({
|
|||||||
class={[bem('item', { loading, disabled }), className]}
|
class={[bem('item', { loading, disabled }), className]}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
{renderOptionContent(action, index)}
|
{renderActionContent(action, index)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -159,7 +159,7 @@ export default defineComponent({
|
|||||||
{renderHeader()}
|
{renderHeader()}
|
||||||
{renderDescription()}
|
{renderDescription()}
|
||||||
<div class={bem('content')}>
|
<div class={bem('content')}>
|
||||||
{props.actions.map(renderOption)}
|
{props.actions.map(renderAction)}
|
||||||
{slots.default?.()}
|
{slots.default?.()}
|
||||||
</div>
|
</div>
|
||||||
{renderCancel()}
|
{renderCancel()}
|
||||||
|
@ -223,7 +223,7 @@ export default {
|
|||||||
| default | Custom content |
|
| default | Custom content |
|
||||||
| description | Custom description above the options |
|
| description | Custom description above the options |
|
||||||
| cancel `v3.0.10` | Custom the content of cancel button |
|
| cancel `v3.0.10` | Custom the content of cancel button |
|
||||||
| option `v3.3.8` | Custom the content of option | _{ action: Action, index: number }_ |
|
| action `v3.3.8` | Custom the content of option | _{ action: Action, index: number }_ |
|
||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ export default {
|
|||||||
| default | 自定义面板的展示内容 | - |
|
| default | 自定义面板的展示内容 | - |
|
||||||
| description | 自定义描述文案 | - |
|
| description | 自定义描述文案 | - |
|
||||||
| cancel `v3.0.10` | 自定义取消按钮内容 | - |
|
| cancel `v3.0.10` | 自定义取消按钮内容 | - |
|
||||||
| option `v3.3.8` | 自定义选项内容 | _{ action: Action, index: number }_ |
|
| action `v3.3.8` | 自定义选项内容 | _{ action: Action, index: number }_ |
|
||||||
|
|
||||||
### 类型定义
|
### 类型定义
|
||||||
|
|
||||||
|
@ -5,6 +5,14 @@ exports[`should allow to custom close icon with closeIcon prop 1`] = `
|
|||||||
</i>
|
</i>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`should render action slot correctly 1`] = `
|
||||||
|
<button type="button"
|
||||||
|
class="van-action-sheet__item"
|
||||||
|
>
|
||||||
|
name: Option, index: 0
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`should render cancel slot correctly 1`] = `
|
exports[`should render cancel slot correctly 1`] = `
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="van-action-sheet__cancel"
|
class="van-action-sheet__cancel"
|
||||||
@ -44,14 +52,6 @@ exports[`should render description slot when match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should render option slot correctly 1`] = `
|
|
||||||
<button type="button"
|
|
||||||
class="van-action-sheet__item"
|
|
||||||
>
|
|
||||||
name: Option, index: 0
|
|
||||||
</button>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`should render subname correctly 1`] = `
|
exports[`should render subname correctly 1`] = `
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="van-action-sheet__item"
|
class="van-action-sheet__item"
|
||||||
|
@ -262,14 +262,14 @@ test('should allow to control safe-area with safe-area-inset-bottom prop', async
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render option slot correctly', () => {
|
test('should render action slot correctly', () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
props: {
|
props: {
|
||||||
show: true,
|
show: true,
|
||||||
actions: [{ name: 'Option' }],
|
actions: [{ name: 'Option' }],
|
||||||
},
|
},
|
||||||
slots: {
|
slots: {
|
||||||
option: ({ action, index }) => `name: ${action.name}, index: ${index}`,
|
action: ({ action, index }) => `name: ${action.name}, index: ${index}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
&-item {
|
&-item {
|
||||||
user-select: none;
|
|
||||||
padding: var(--van-tree-select-nav-item-padding);
|
padding: var(--van-tree-select-nav-item-padding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user