Files
element-plus/packages/components/button/src/button.ts
三咲智子 ea812ae622 refactor(components): refactor button (#5933)
* refactor(components): refactor button

* refactor: rename

* test: apply jsx

* feat: expose

* test: fix
2022-02-12 18:37:16 +08:00

66 lines
1.4 KiB
TypeScript

import { useSizeProp } from '@element-plus/hooks'
import { buildProps, iconPropType } from '@element-plus/utils'
import { Loading } from '@element-plus/icons-vue'
import type { ExtractPropTypes } from 'vue'
import type button from './button.vue'
export const buttonTypes = [
'default',
'primary',
'success',
'warning',
'info',
'danger',
'text',
'',
] as const
export const buttonNativeTypes = ['button', 'submit', 'reset'] as const
export const buttonProps = buildProps({
size: useSizeProp,
disabled: Boolean,
type: {
type: String,
values: buttonTypes,
default: '',
},
icon: {
type: iconPropType,
default: '',
},
nativeType: {
type: String,
values: buttonNativeTypes,
default: 'button',
},
loading: Boolean,
loadingIcon: {
type: iconPropType,
default: () => Loading,
},
plain: Boolean,
autofocus: Boolean,
round: Boolean,
circle: Boolean,
color: String,
autoInsertSpace: {
type: Boolean,
default: undefined,
},
} 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']
export type ButtonInstance = InstanceType<typeof button>
export interface ButtonConfigContext {
autoInsertSpace?: boolean
}