diff --git a/components/_util/PurePanel.tsx b/components/_util/PurePanel.tsx index 4aae173e1d..004e26d220 100644 --- a/components/_util/PurePanel.tsx +++ b/components/_util/PurePanel.tsx @@ -1,22 +1,15 @@ -import useMergedState from 'rc-util/lib/hooks/useMergedState'; import * as React from 'react'; -import ConfigProvider, { ConfigContext } from '../config-provider'; +import useMergedState from 'rc-util/lib/hooks/useMergedState'; -export function withPureRenderTheme(Component: any) { - return function PureRenderThemeComponent(props: any) { - return ( - - - - ); - }; +import ConfigProvider, { ConfigContext } from '../config-provider'; +import type { AnyObject } from './type'; + +export function withPureRenderTheme(Component: React.FC) { + return (props: T) => ( + + + + ); } export interface BaseProps { @@ -25,15 +18,15 @@ export interface BaseProps { } /* istanbul ignore next */ -export default function genPurePanel( +const genPurePanel = ( Component: any, defaultPrefixCls?: string, getDropdownCls?: null | ((prefixCls: string) => string), postProps?: (props: ComponentProps) => ComponentProps, -) { - type WrapProps = Omit & { open?: boolean }; +) => { + type WrapProps = ComponentProps & AnyObject; - function PurePanel(props: WrapProps) { + const PurePanel: React.FC = (props) => { const { prefixCls: customizePrefixCls, style } = props; const holderRef = React.useRef(null); @@ -90,20 +83,19 @@ export default function genPurePanel( if (postProps) { mergedProps = postProps(mergedProps as ComponentProps); } - + const mergedStyle: React.CSSProperties = { + paddingBottom: popupHeight, + position: 'relative', + minWidth: popupWidth, + }; return ( -
+
); - } + }; return withPureRenderTheme(PurePanel); -} +}; + +export default genPurePanel; diff --git a/components/_util/extendsObject.ts b/components/_util/extendsObject.ts index 80e033c937..f956840637 100644 --- a/components/_util/extendsObject.ts +++ b/components/_util/extendsObject.ts @@ -1,7 +1,7 @@ -type RecordType = Record; +import type { AnyObject } from './type'; -function extendsObject(...list: T[]) { - const result: RecordType = { ...list[0] }; +const extendsObject = (...list: T[]) => { + const result: AnyObject = { ...list[0] }; for (let i = 1; i < list.length; i++) { const obj = list[i]; @@ -16,6 +16,6 @@ function extendsObject(...list: T[]) { } return result; -} +}; export default extendsObject; diff --git a/components/_util/getRenderPropValue.ts b/components/_util/getRenderPropValue.ts index fe673166b5..fd03c931c7 100644 --- a/components/_util/getRenderPropValue.ts +++ b/components/_util/getRenderPropValue.ts @@ -9,9 +9,5 @@ export const getRenderPropValue = ( return null; } - if (typeof propValue === 'function') { - return propValue(); - } - - return propValue; + return typeof propValue === 'function' ? propValue() : propValue; };