ant-design/components/typography/hooks/useTooltipProps.ts

23 lines
633 B
TypeScript
Raw Normal View History

import { isValidElement, useMemo } from 'react';
import type { TooltipProps } from '../../tooltip';
const useTooltipProps = (
tooltip: React.ReactNode | TooltipProps,
editConfigText: React.ReactNode,
children: React.ReactNode,
) =>
useMemo(() => {
if (tooltip === true) {
return { title: editConfigText ?? children };
}
if (isValidElement(tooltip)) {
return { title: tooltip };
}
if (typeof tooltip === 'object') {
return { title: editConfigText ?? children, ...tooltip };
}
return { title: tooltip };
2024-09-03 16:20:44 +08:00
}, [tooltip, editConfigText, children]);
export default useTooltipProps;