refactor: avoid circular import (#42764)

This commit is contained in:
Dunqing 2023-06-01 12:41:44 +08:00 committed by GitHub
parent f6dc5f39e0
commit e1e5c740e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -16,7 +16,6 @@ import Menu from '../menu';
import { OverrideProvider } from '../menu/OverrideContext'; import { OverrideProvider } from '../menu/OverrideContext';
import { NoCompactStyle } from '../space/Compact'; import { NoCompactStyle } from '../space/Compact';
import theme from '../theme'; import theme from '../theme';
import DropdownButton from './dropdown-button';
import useStyle from './style'; import useStyle from './style';
const Placements = [ const Placements = [
@ -30,7 +29,7 @@ const Placements = [
'bottom', 'bottom',
] as const; ] as const;
type Placement = typeof Placements[number]; type Placement = (typeof Placements)[number];
type DropdownPlacement = Exclude<Placement, 'topCenter' | 'bottomCenter'>; type DropdownPlacement = Exclude<Placement, 'topCenter' | 'bottomCenter'>;
type OverlayFunc = () => React.ReactElement; type OverlayFunc = () => React.ReactElement;
@ -88,7 +87,6 @@ export interface DropdownProps {
} }
type CompoundedComponent = React.FC<DropdownProps> & { type CompoundedComponent = React.FC<DropdownProps> & {
Button: typeof DropdownButton;
_InternalPanelDoNotUseOrYouWillBeFired: typeof WrapPurePanel; _InternalPanelDoNotUseOrYouWillBeFired: typeof WrapPurePanel;
}; };
@ -305,8 +303,6 @@ const Dropdown: CompoundedComponent = (props) => {
); );
}; };
Dropdown.Button = DropdownButton;
function postPureProps(props: DropdownProps) { function postPureProps(props: DropdownProps) {
return { return {
...props, ...props,

View File

@ -1,10 +1,17 @@
import Dropdown from './dropdown'; import InternalDropdown from './dropdown';
import DropdownButton from './dropdown-button';
export type { export type {
DropdownProps,
// typo, but we need to support it for backwards compatibility // typo, but we need to support it for backwards compatibility
// https://github.com/ant-design/ant-design/pull/35161 // https://github.com/ant-design/ant-design/pull/35161
DropdownProps as DropDownProps, DropdownProps as DropDownProps,
DropdownProps,
} from './dropdown'; } from './dropdown';
export type { DropdownButtonProps, DropdownButtonType } from './dropdown-button'; export type { DropdownButtonProps, DropdownButtonType } from './dropdown-button';
const Dropdown = InternalDropdown as typeof InternalDropdown & {
Button: typeof DropdownButton;
};
Dropdown.Button = DropdownButton;
export default Dropdown; export default Dropdown;