mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
[improvement] SwitchCell: tsx (#2785)
This commit is contained in:
48
packages/switch-cell/index.tsx
Normal file
48
packages/switch-cell/index.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { use } from '../utils';
|
||||
import { inherit } from '../utils/functional';
|
||||
import Cell from '../cell';
|
||||
import Switch, { SwitchEvents } from '../switch';
|
||||
import { switchProps, SharedSwitchProps } from '../switch/shared';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/use/sfc';
|
||||
|
||||
export type SwitchCellProps = SharedSwitchProps & {
|
||||
size?: string;
|
||||
title?: string;
|
||||
border?: boolean;
|
||||
};
|
||||
|
||||
const [sfc, bem] = use('switch-cell');
|
||||
|
||||
function SwitchCell(
|
||||
h: CreateElement,
|
||||
props: SwitchCellProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<SwitchCellProps>
|
||||
) {
|
||||
return (
|
||||
<Cell
|
||||
center
|
||||
title={props.title}
|
||||
border={props.border}
|
||||
class={bem()}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
<Switch {...{ props, on: ctx.listeners }} />
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
|
||||
SwitchCell.props = {
|
||||
...switchProps,
|
||||
title: String,
|
||||
border: Boolean,
|
||||
size: {
|
||||
type: String,
|
||||
default: '24px'
|
||||
}
|
||||
};
|
||||
|
||||
export default sfc<SwitchCellProps, SwitchEvents>(SwitchCell);
|
Reference in New Issue
Block a user