Browse Source

type: strong type (#37805)

pull/37809/head
lijianan 2 years ago
committed by GitHub
parent
commit
3588ae82c1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/dropdown/dropdown-button.tsx
  2. 23
      components/dropdown/dropdown.tsx

6
components/dropdown/dropdown-button.tsx

@ -70,7 +70,7 @@ const DropdownButton: DropdownButtonInterface = props => {
} = props;
const prefixCls = getPrefixCls('dropdown-button', customizePrefixCls);
const dropdownProps = {
const dropdownProps: DropdownProps = {
align,
overlay,
disabled,
@ -82,7 +82,7 @@ const DropdownButton: DropdownButtonInterface = props => {
overlayClassName,
overlayStyle,
destroyPopupOnHide,
} as DropdownProps;
};
if ('open' in props) {
dropdownProps.open = open;
@ -113,7 +113,7 @@ const DropdownButton: DropdownButtonInterface = props => {
const rightButton = <Button type={type} danger={danger} icon={icon} />;
const [leftButtonToRender, rightButtonToRender] = buttonsRender!([leftButton, rightButton]);
const [leftButtonToRender, rightButtonToRender] = buttonsRender([leftButton, rightButton]);
return (
<ButtonGroup {...restProps} className={classNames(prefixCls, className)}>

23
components/dropdown/dropdown.tsx

@ -109,7 +109,7 @@ const Dropdown: DropdownInterface = props => {
if (transitionName !== undefined) {
return transitionName;
}
if (placement.indexOf('top') >= 0) {
if (placement.includes('top')) {
return `${rootPrefixCls}-slide-down`;
}
return `${rootPrefixCls}-slide-up`;
@ -118,7 +118,7 @@ const Dropdown: DropdownInterface = props => {
const getPlacement = () => {
const { placement } = props;
if (!placement) {
return direction === 'rtl' ? ('bottomRight' as Placement) : ('bottomLeft' as Placement);
return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
}
if (placement.includes('Center')) {
@ -146,6 +146,8 @@ const Dropdown: DropdownInterface = props => {
open,
onVisibleChange,
onOpenChange,
mouseEnterDelay = 0.15,
mouseLeaveDelay = 0.1,
} = props;
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
@ -163,8 +165,8 @@ const Dropdown: DropdownInterface = props => {
});
const triggerActions = disabled ? [] : trigger;
let alignPoint;
if (triggerActions && triggerActions.indexOf('contextMenu') !== -1) {
let alignPoint: boolean;
if (triggerActions && triggerActions.includes('contextMenu')) {
alignPoint = true;
}
@ -198,9 +200,9 @@ const Dropdown: DropdownInterface = props => {
// So we need render the element to check and pass back to rc-dropdown.
const { overlay } = props;
let overlayNode;
let overlayNode: React.ReactNode;
if (typeof overlay === 'function') {
overlayNode = (overlay as OverlayFunc)();
overlayNode = overlay();
} else {
overlayNode = overlay;
}
@ -236,8 +238,10 @@ const Dropdown: DropdownInterface = props => {
// ============================ Render ============================
return (
<RcDropdown
alignPoint={alignPoint}
alignPoint={alignPoint!}
{...props}
mouseEnterDelay={mouseEnterDelay}
mouseLeaveDelay={mouseLeaveDelay}
visible={mergedOpen}
builtinPlacements={builtinPlacements}
arrow={!!arrow}
@ -257,9 +261,4 @@ const Dropdown: DropdownInterface = props => {
Dropdown.Button = DropdownButton;
Dropdown.defaultProps = {
mouseEnterDelay: 0.15,
mouseLeaveDelay: 0.1,
};
export default Dropdown;

Loading…
Cancel
Save