chore(Switch): use tsx

This commit is contained in:
chenjiahan 2020-09-21 17:25:35 +08:00
parent bf1f0f57eb
commit 7d0340a35b
2 changed files with 17 additions and 39 deletions

View File

@ -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}
>
<div class={bem('node')}>{renderLoading()}</div>

View File

@ -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,
},
};