diff --git a/src/switch/index.js b/src/switch/index.tsx similarity index 80% rename from src/switch/index.js rename to src/switch/index.tsx index 98fd53322..498dfe512 100644 --- a/src/switch/index.js +++ b/src/switch/index.tsx @@ -1,17 +1,26 @@ -// Utils import { createNamespace, addUnit } from '../utils'; -import { switchProps } from './shared'; - -// Composition import { useParentField } from '../composition/use-parent-field'; - -// Components import Loading from '../loading'; const [createComponent, bem] = createNamespace('switch'); export default createComponent({ - props: switchProps, + props: { + size: [Number, String], + loading: Boolean, + disabled: Boolean, + modelValue: null as any, + activeColor: String, + inactiveColor: String, + activeValue: { + type: null as any, + default: true, + }, + inactiveValue: { + type: null as any, + default: false, + }, + }, emits: ['change', 'update:modelValue'], @@ -52,7 +61,7 @@ export default createComponent({ disabled, })} style={style} - aria-checked={String(checked)} + aria-checked={checked} onClick={onClick} >
{renderLoading()}
diff --git a/src/switch/shared.ts b/src/switch/shared.ts deleted file mode 100644 index fd77d663b..000000000 --- a/src/switch/shared.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Common Switch Props - */ - -export type SharedSwitchProps = { - size?: string | number; - loading?: boolean; - disabled?: boolean; - modelValue?: any; - activeValue: any; - inactiveValue: any; - activeColor?: string; - inactiveColor?: string; -}; - -export const switchProps = { - size: [Number, String], - loading: Boolean, - disabled: Boolean, - modelValue: null as any, - activeColor: String, - inactiveColor: String, - activeValue: { - type: null as any, - default: true, - }, - inactiveValue: { - type: null as any, - default: false, - }, -};