Files
element-plus/packages/components/button/src/button.ts
jeremywu 19bc41f965 feat(hooks): extracting size injection for form items (#3383)
* feat(hooks): extracting size injection for form items

- Extract common code for form items
- Apply extracted code for el-button

* - Address import order

* Update packages/hooks/use-form-item/index.ts

Co-authored-by: 三咲智子 <sxzz@sxzz.moe>

* - Fix type annotation for fallbacks

* - Use MaybeRef to mark type of local fallbacks

Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
2021-09-13 23:14:48 +08:00

50 lines
1.1 KiB
TypeScript

import { useFormItemProps } from '@element-plus/hooks'
import { buildProp } from '@element-plus/utils/props'
import type { ExtractPropTypes } from 'vue'
export const buttonType = [
'default',
'primary',
'success',
'warning',
'info',
'danger',
'text',
] as const
export const buttonSize = ['', 'large', 'medium', 'small', 'mini'] as const
export const buttonNativeType = ['button', 'submit', 'reset'] as const
export const buttonProps = {
...useFormItemProps,
type: buildProp({
type: String,
values: buttonType,
default: 'default',
} as const),
icon: {
type: String,
default: '',
},
nativeType: buildProp({
type: String,
values: buttonNativeType,
default: 'button',
} as const),
loading: Boolean,
plain: Boolean,
autofocus: Boolean,
round: Boolean,
circle: Boolean,
} as const
export const buttonEmits = {
click: (evt: MouseEvent) => evt instanceof MouseEvent,
}
export type ButtonProps = ExtractPropTypes<typeof buttonProps>
export type ButtonEmits = typeof buttonEmits
export type ButtonType = ButtonProps['type']
export type ButtonNativeType = ButtonProps['nativeType']