index.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { use } from '../utils';
  2. import { inherit } from '../utils/functional';
  3. import Cell from '../cell';
  4. import Switch, { SwitchEvents } from '../switch';
  5. import { switchProps, SharedSwitchProps } from '../switch/shared';
  6. // Types
  7. import { CreateElement, RenderContext } from 'vue/types';
  8. import { DefaultSlots } from '../utils/use/sfc';
  9. export type SwitchCellProps = SharedSwitchProps & {
  10. size: string;
  11. title?: string;
  12. border?: boolean;
  13. };
  14. const [sfc, bem] = use('switch-cell');
  15. function SwitchCell(
  16. h: CreateElement,
  17. props: SwitchCellProps,
  18. slots: DefaultSlots,
  19. ctx: RenderContext<SwitchCellProps>
  20. ) {
  21. return (
  22. <Cell
  23. center
  24. title={props.title}
  25. border={props.border}
  26. class={bem()}
  27. {...inherit(ctx)}
  28. >
  29. <Switch {...{ props, on: ctx.listeners }} />
  30. </Cell>
  31. );
  32. }
  33. SwitchCell.props = {
  34. ...switchProps,
  35. title: String,
  36. border: Boolean,
  37. size: {
  38. type: String,
  39. default: '24px'
  40. }
  41. };
  42. export default sfc<SwitchCellProps, SwitchEvents>(SwitchCell);