2021-06-30 02:03:17 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
|
|
|
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
|
|
import type { SizeType } from '../config-provider';
|
2020-10-13 10:04:02 +00:00
|
|
|
|
2022-03-26 14:52:54 +00:00
|
|
|
export type ButtonType = 'link' | 'default' | 'primary' | 'ghost' | 'dashed' | 'text';
|
|
|
|
export type ButtonShape = 'default' | 'circle' | 'round';
|
2021-06-30 02:03:17 +00:00
|
|
|
|
2022-03-26 14:52:54 +00:00
|
|
|
export type ButtonHTMLType = 'submit' | 'button' | 'reset';
|
2020-10-13 10:04:02 +00:00
|
|
|
|
2021-06-30 02:03:17 +00:00
|
|
|
export type LegacyButtonType = ButtonType | 'danger';
|
|
|
|
export function convertLegacyProps(type?: LegacyButtonType): ButtonProps {
|
|
|
|
if (type === 'danger') {
|
|
|
|
return { danger: true };
|
|
|
|
}
|
|
|
|
return { type };
|
|
|
|
}
|
|
|
|
|
2022-03-18 01:30:37 +00:00
|
|
|
export const buttonProps = () => ({
|
2022-03-26 14:52:54 +00:00
|
|
|
prefixCls: String,
|
|
|
|
type: String as PropType<ButtonType>,
|
|
|
|
htmlType: { type: String as PropType<ButtonHTMLType>, default: 'button' },
|
|
|
|
shape: { type: String as PropType<ButtonShape> },
|
2021-06-30 02:03:17 +00:00
|
|
|
size: {
|
|
|
|
type: String as PropType<SizeType>,
|
|
|
|
},
|
|
|
|
loading: {
|
2021-09-06 14:47:56 +00:00
|
|
|
type: [Boolean, Object] as PropType<boolean | { delay?: number }>,
|
2021-06-30 02:03:17 +00:00
|
|
|
default: (): boolean | { delay?: number } => false,
|
|
|
|
},
|
2022-03-26 14:52:54 +00:00
|
|
|
disabled: { type: Boolean, default: undefined },
|
|
|
|
ghost: { type: Boolean, default: undefined },
|
|
|
|
block: { type: Boolean, default: undefined },
|
|
|
|
danger: { type: Boolean, default: undefined },
|
2021-12-16 09:20:18 +00:00
|
|
|
icon: PropTypes.any,
|
2022-03-26 14:52:54 +00:00
|
|
|
href: String,
|
|
|
|
target: String,
|
|
|
|
title: String,
|
2021-06-30 02:03:17 +00:00
|
|
|
onClick: {
|
|
|
|
type: Function as PropType<(event: MouseEvent) => void>,
|
|
|
|
},
|
2022-03-26 14:52:54 +00:00
|
|
|
onMousedown: {
|
|
|
|
type: Function as PropType<(event: MouseEvent) => void>,
|
|
|
|
},
|
2020-10-13 10:04:02 +00:00
|
|
|
});
|
2020-10-19 15:09:36 +00:00
|
|
|
|
2020-11-11 13:33:17 +00:00
|
|
|
export type ButtonProps = Partial<ExtractPropTypes<ReturnType<typeof buttonProps>>>;
|
2020-10-19 15:09:36 +00:00
|
|
|
|
|
|
|
export default buttonProps;
|