vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
import PropTypes from '../_util/vue-types'; |
|
|
|
import type { ExtractPropTypes, PropType } from 'vue'; |
|
import type { SizeType } from '../config-provider'; |
|
import { eventType } from '../_util/type'; |
|
import type { MouseEventHandler } from '../_util/EventInterface'; |
|
|
|
export type ButtonType = 'link' | 'default' | 'primary' | 'ghost' | 'dashed' | 'text'; |
|
export type ButtonShape = 'default' | 'circle' | 'round'; |
|
|
|
export type ButtonHTMLType = 'submit' | 'button' | 'reset'; |
|
|
|
export type LegacyButtonType = ButtonType | 'danger'; |
|
export function convertLegacyProps(type?: LegacyButtonType): ButtonProps { |
|
if (type === 'danger') { |
|
return { danger: true }; |
|
} |
|
return { type }; |
|
} |
|
|
|
export const buttonProps = () => ({ |
|
prefixCls: String, |
|
type: String as PropType<ButtonType>, |
|
htmlType: { type: String as PropType<ButtonHTMLType>, default: 'button' }, |
|
shape: { type: String as PropType<ButtonShape> }, |
|
size: { |
|
type: String as PropType<SizeType>, |
|
}, |
|
loading: { |
|
type: [Boolean, Object] as PropType<boolean | { delay?: number }>, |
|
default: (): boolean | { delay?: number } => false, |
|
}, |
|
disabled: { type: Boolean, default: undefined }, |
|
ghost: { type: Boolean, default: undefined }, |
|
block: { type: Boolean, default: undefined }, |
|
danger: { type: Boolean, default: undefined }, |
|
icon: PropTypes.any, |
|
href: String, |
|
target: String, |
|
title: String, |
|
onClick: eventType<MouseEventHandler>(), |
|
onMousedown: eventType<MouseEventHandler>(), |
|
}); |
|
|
|
export type ButtonProps = Partial<ExtractPropTypes<ReturnType<typeof buttonProps>>>; |
|
|
|
export default buttonProps;
|
|
|