|
@ -27,7 +27,9 @@ import useStyle from './style'; |
|
|
|
|
|
|
|
|
export type LegacyButtonType = ButtonType | 'danger'; |
|
|
export type LegacyButtonType = ButtonType | 'danger'; |
|
|
|
|
|
|
|
|
export function convertLegacyProps(type?: LegacyButtonType): ButtonProps { |
|
|
export function convertLegacyProps( |
|
|
|
|
|
type?: LegacyButtonType, |
|
|
|
|
|
): Pick<BaseButtonProps, 'danger' | 'type'> { |
|
|
if (type === 'danger') { |
|
|
if (type === 'danger') { |
|
|
return { danger: true }; |
|
|
return { danger: true }; |
|
|
} |
|
|
} |
|
@ -66,7 +68,9 @@ export type NativeButtonProps = { |
|
|
} & BaseButtonProps & |
|
|
} & BaseButtonProps & |
|
|
Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick'>; |
|
|
Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick'>; |
|
|
|
|
|
|
|
|
export type ButtonProps = Partial<AnchorButtonProps & NativeButtonProps>; |
|
|
export type ButtonProps = AnchorButtonProps | NativeButtonProps; |
|
|
|
|
|
|
|
|
|
|
|
type InternalButtonProps = Partial<AnchorButtonProps & NativeButtonProps>; |
|
|
|
|
|
|
|
|
type CompoundedComponent = React.ForwardRefExoticComponent< |
|
|
type CompoundedComponent = React.ForwardRefExoticComponent< |
|
|
ButtonProps & React.RefAttributes<HTMLElement> |
|
|
ButtonProps & React.RefAttributes<HTMLElement> |
|
@ -121,7 +125,7 @@ const InternalButton: React.ForwardRefRenderFunction< |
|
|
classNames: customClassNames, |
|
|
classNames: customClassNames, |
|
|
style: customStyle = {}, |
|
|
style: customStyle = {}, |
|
|
...rest |
|
|
...rest |
|
|
} = props; |
|
|
} = props as InternalButtonProps; |
|
|
|
|
|
|
|
|
const { getPrefixCls, autoInsertSpaceInButton, direction, button } = useContext(ConfigContext); |
|
|
const { getPrefixCls, autoInsertSpaceInButton, direction, button } = useContext(ConfigContext); |
|
|
const prefixCls = getPrefixCls('btn', customizePrefixCls); |
|
|
const prefixCls = getPrefixCls('btn', customizePrefixCls); |
|
@ -214,7 +218,7 @@ const InternalButton: React.ForwardRefRenderFunction< |
|
|
|
|
|
|
|
|
const iconType = innerLoading ? 'loading' : icon; |
|
|
const iconType = innerLoading ? 'loading' : icon; |
|
|
|
|
|
|
|
|
const linkButtonRestProps = omit(rest as ButtonProps & { navigate: any }, ['navigate']); |
|
|
const linkButtonRestProps = omit(rest as InternalButtonProps & { navigate: any }, ['navigate']); |
|
|
|
|
|
|
|
|
const classes = classNames( |
|
|
const classes = classNames( |
|
|
prefixCls, |
|
|
prefixCls, |
|
|