type: strong type (#37805)

This commit is contained in:
lijianan 2022-09-30 09:49:28 +08:00 committed by GitHub
parent c8f9b31168
commit 3588ae82c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -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)}>

View File

@ -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;