2023-12-13 14:32:57 +03:00
|
|
|
'use client';
|
|
|
|
|
2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2023-12-21 00:12:24 +03:00
|
|
|
import { ReactNode } from 'react';
|
2023-12-07 01:33:34 +03:00
|
|
|
import { createPortal } from 'react-dom';
|
2024-01-04 19:30:10 +03:00
|
|
|
import { ITooltip, Tooltip as TooltipImpl } from 'react-tooltip';
|
2023-07-30 16:48:25 +03:00
|
|
|
|
2023-12-13 14:32:57 +03:00
|
|
|
import { useConceptTheme } from '@/context/ThemeContext';
|
2023-07-30 16:48:25 +03:00
|
|
|
|
2024-01-06 03:15:02 +03:00
|
|
|
export type { PlacesType } from 'react-tooltip';
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
interface TooltipProps extends Omit<ITooltip, 'variant'> {
|
2023-12-28 14:04:44 +03:00
|
|
|
layer?: string;
|
|
|
|
text?: string;
|
2023-07-30 16:48:25 +03:00
|
|
|
}
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
function Tooltip({
|
2023-12-28 14:04:44 +03:00
|
|
|
text,
|
|
|
|
children,
|
|
|
|
layer = 'z-tooltip',
|
|
|
|
place = 'bottom',
|
2023-12-18 19:42:27 +03:00
|
|
|
className,
|
2023-11-24 18:03:10 +03:00
|
|
|
style,
|
2023-11-27 13:50:56 +03:00
|
|
|
...restProps
|
2024-01-04 19:30:10 +03:00
|
|
|
}: TooltipProps) {
|
2023-07-30 16:48:25 +03:00
|
|
|
const { darkMode } = useConceptTheme();
|
2023-12-13 14:32:57 +03:00
|
|
|
if (typeof window === 'undefined') {
|
|
|
|
return null;
|
|
|
|
}
|
2023-12-07 01:33:34 +03:00
|
|
|
return createPortal(
|
2024-01-04 19:30:10 +03:00
|
|
|
<TooltipImpl
|
2023-12-28 14:04:44 +03:00
|
|
|
delayShow={1000}
|
|
|
|
delayHide={100}
|
|
|
|
opacity={0.97}
|
|
|
|
className={clsx('overflow-hidden', 'border shadow-md', layer, className)}
|
|
|
|
classNameArrow={layer}
|
|
|
|
style={{ ...{ paddingTop: '2px', paddingBottom: '2px' }, ...style }}
|
|
|
|
variant={darkMode ? 'dark' : 'light'}
|
|
|
|
place={place}
|
|
|
|
{...restProps}
|
|
|
|
>
|
|
|
|
{text ? text : null}
|
|
|
|
{children as ReactNode}
|
2024-01-04 19:30:10 +03:00
|
|
|
</TooltipImpl>,
|
2023-12-28 14:04:44 +03:00
|
|
|
document.body
|
|
|
|
);
|
2023-07-30 16:48:25 +03:00
|
|
|
}
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
export default Tooltip;
|