Files
element-plus/packages/components/button/src/button.ts
Xc ad3d998752 feat(components): [button] add link api (#7652)
* feat: button add link type

* fix: code lint

* feat: button add link api

* docs: edit word

Co-authored-by: xiaochenchen <xiaochen.chen@igg.com>
2022-05-14 12:20:02 +08:00

69 lines
1.5 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',
'',
] 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,
text: Boolean,
link: Boolean,
bg: Boolean,
autofocus: Boolean,
round: Boolean,
circle: Boolean,
color: String,
dark: Boolean,
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
}