mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
20 lines
485 B
TypeScript
20 lines
485 B
TypeScript
import type { ReactNode } from 'react';
|
|
import { isValidElement } from 'react';
|
|
|
|
import type { TooltipProps } from '../tooltip';
|
|
import isNonNullable from './isNonNullable';
|
|
|
|
const convertToTooltipProps = <P extends TooltipProps>(tooltip: P | ReactNode) => {
|
|
if (!isNonNullable(tooltip)) {
|
|
return null;
|
|
}
|
|
|
|
if (typeof tooltip === 'object' && !isValidElement(tooltip)) {
|
|
return tooltip as P;
|
|
}
|
|
|
|
return { title: tooltip } as P;
|
|
};
|
|
|
|
export default convertToTooltipProps;
|