mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* refactor(components): refactor button * refactor: rename * test: apply jsx * feat: expose * test: fix
66 lines
1.4 KiB
TypeScript
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
|
|
}
|