Files
element-plus/packages/components/checkbox/src/checkbox.ts
MonsterPi 49109158c8 refactor(components): [checkbox] refactor (#9594)
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
2022-09-16 20:53:11 +08:00

60 lines
1.4 KiB
TypeScript

import { UPDATE_MODEL_EVENT } from '@element-plus/constants'
import { useSizeProp } from '@element-plus/hooks'
import { isBoolean, isNumber, isString } from '@element-plus/utils'
import type { ExtractPropTypes } from 'vue'
import type Checkbox from './checkbox.vue'
export type CheckboxValueType = string | number | boolean
export const checkboxProps = {
modelValue: {
type: [Number, String, Boolean],
default: undefined,
},
label: {
type: [String, Boolean, Number, Object],
},
indeterminate: Boolean,
disabled: Boolean,
checked: Boolean,
name: {
type: String,
default: undefined,
},
trueLabel: {
type: [String, Number],
default: undefined,
},
falseLabel: {
type: [String, Number],
default: undefined,
},
id: {
type: String,
default: undefined,
},
controls: {
type: String,
default: undefined,
},
border: Boolean,
size: useSizeProp,
tabindex: [String, Number],
validateEvent: {
type: Boolean,
default: true,
},
}
export const checkboxEmits = {
[UPDATE_MODEL_EVENT]: (val: CheckboxValueType) =>
isString(val) || isNumber(val) || isBoolean(val),
change: (val: CheckboxValueType) =>
isString(val) || isNumber(val) || isBoolean(val),
}
export type CheckboxProps = ExtractPropTypes<typeof checkboxProps>
export type CheckboxEmits = typeof checkboxEmits
export type CheckboxInstance = InstanceType<typeof Checkbox>