mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
type: strong type (#37805)
This commit is contained in:
parent
c8f9b31168
commit
3588ae82c1
@ -70,7 +70,7 @@ const DropdownButton: DropdownButtonInterface = props => {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const prefixCls = getPrefixCls('dropdown-button', customizePrefixCls);
|
const prefixCls = getPrefixCls('dropdown-button', customizePrefixCls);
|
||||||
const dropdownProps = {
|
const dropdownProps: DropdownProps = {
|
||||||
align,
|
align,
|
||||||
overlay,
|
overlay,
|
||||||
disabled,
|
disabled,
|
||||||
@ -82,7 +82,7 @@ const DropdownButton: DropdownButtonInterface = props => {
|
|||||||
overlayClassName,
|
overlayClassName,
|
||||||
overlayStyle,
|
overlayStyle,
|
||||||
destroyPopupOnHide,
|
destroyPopupOnHide,
|
||||||
} as DropdownProps;
|
};
|
||||||
|
|
||||||
if ('open' in props) {
|
if ('open' in props) {
|
||||||
dropdownProps.open = open;
|
dropdownProps.open = open;
|
||||||
@ -113,7 +113,7 @@ const DropdownButton: DropdownButtonInterface = props => {
|
|||||||
|
|
||||||
const rightButton = <Button type={type} danger={danger} icon={icon} />;
|
const rightButton = <Button type={type} danger={danger} icon={icon} />;
|
||||||
|
|
||||||
const [leftButtonToRender, rightButtonToRender] = buttonsRender!([leftButton, rightButton]);
|
const [leftButtonToRender, rightButtonToRender] = buttonsRender([leftButton, rightButton]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ButtonGroup {...restProps} className={classNames(prefixCls, className)}>
|
<ButtonGroup {...restProps} className={classNames(prefixCls, className)}>
|
||||||
|
@ -109,7 +109,7 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
if (transitionName !== undefined) {
|
if (transitionName !== undefined) {
|
||||||
return transitionName;
|
return transitionName;
|
||||||
}
|
}
|
||||||
if (placement.indexOf('top') >= 0) {
|
if (placement.includes('top')) {
|
||||||
return `${rootPrefixCls}-slide-down`;
|
return `${rootPrefixCls}-slide-down`;
|
||||||
}
|
}
|
||||||
return `${rootPrefixCls}-slide-up`;
|
return `${rootPrefixCls}-slide-up`;
|
||||||
@ -118,7 +118,7 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
const getPlacement = () => {
|
const getPlacement = () => {
|
||||||
const { placement } = props;
|
const { placement } = props;
|
||||||
if (!placement) {
|
if (!placement) {
|
||||||
return direction === 'rtl' ? ('bottomRight' as Placement) : ('bottomLeft' as Placement);
|
return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placement.includes('Center')) {
|
if (placement.includes('Center')) {
|
||||||
@ -146,6 +146,8 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
open,
|
open,
|
||||||
onVisibleChange,
|
onVisibleChange,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
|
mouseEnterDelay = 0.15,
|
||||||
|
mouseLeaveDelay = 0.1,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
|
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
|
||||||
@ -163,8 +165,8 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const triggerActions = disabled ? [] : trigger;
|
const triggerActions = disabled ? [] : trigger;
|
||||||
let alignPoint;
|
let alignPoint: boolean;
|
||||||
if (triggerActions && triggerActions.indexOf('contextMenu') !== -1) {
|
if (triggerActions && triggerActions.includes('contextMenu')) {
|
||||||
alignPoint = true;
|
alignPoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +200,9 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
// So we need render the element to check and pass back to rc-dropdown.
|
// So we need render the element to check and pass back to rc-dropdown.
|
||||||
const { overlay } = props;
|
const { overlay } = props;
|
||||||
|
|
||||||
let overlayNode;
|
let overlayNode: React.ReactNode;
|
||||||
if (typeof overlay === 'function') {
|
if (typeof overlay === 'function') {
|
||||||
overlayNode = (overlay as OverlayFunc)();
|
overlayNode = overlay();
|
||||||
} else {
|
} else {
|
||||||
overlayNode = overlay;
|
overlayNode = overlay;
|
||||||
}
|
}
|
||||||
@ -236,8 +238,10 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
// ============================ Render ============================
|
// ============================ Render ============================
|
||||||
return (
|
return (
|
||||||
<RcDropdown
|
<RcDropdown
|
||||||
alignPoint={alignPoint}
|
alignPoint={alignPoint!}
|
||||||
{...props}
|
{...props}
|
||||||
|
mouseEnterDelay={mouseEnterDelay}
|
||||||
|
mouseLeaveDelay={mouseLeaveDelay}
|
||||||
visible={mergedOpen}
|
visible={mergedOpen}
|
||||||
builtinPlacements={builtinPlacements}
|
builtinPlacements={builtinPlacements}
|
||||||
arrow={!!arrow}
|
arrow={!!arrow}
|
||||||
@ -257,9 +261,4 @@ const Dropdown: DropdownInterface = props => {
|
|||||||
|
|
||||||
Dropdown.Button = DropdownButton;
|
Dropdown.Button = DropdownButton;
|
||||||
|
|
||||||
Dropdown.defaultProps = {
|
|
||||||
mouseEnterDelay: 0.15,
|
|
||||||
mouseLeaveDelay: 0.1,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Dropdown;
|
export default Dropdown;
|
||||||
|
Loading…
Reference in New Issue
Block a user