overleaf/services/web/frontend/js/features/ui/components/bootstrap-5/dropdown-toggle-with-tooltip.tsx
Tim Down 4138f9707a Merge pull request #20860 from overleaf/td-bs5-history-versions-list
Migrate history versions list to Bootstrap 5

GitOrigin-RevId: 4e006ad353cb11eadaefb2df41d2b8591003c664
2024-10-14 11:11:01 +00:00

52 lines
1.4 KiB
TypeScript

import { ReactNode, forwardRef } from 'react'
import { BsPrefixRefForwardingComponent } from 'react-bootstrap-5/helpers'
import type { DropdownToggleProps } from '@/features/ui/components/types/dropdown-menu-props'
import {
DropdownToggle as BS5DropdownToggle,
OverlayTrigger,
OverlayTriggerProps,
Tooltip,
} from 'react-bootstrap-5'
import type { MergeAndOverride } from '../../../../../../types/utils'
type DropdownToggleWithTooltipProps = MergeAndOverride<
DropdownToggleProps,
{
children: ReactNode
overlayTriggerProps?: Omit<OverlayTriggerProps, 'overlay' | 'children'>
toolTipDescription: string
tooltipProps?: Omit<React.ComponentProps<typeof Tooltip>, 'children'>
'aria-label'?: string
}
>
const DropdownToggleWithTooltip = forwardRef<
BsPrefixRefForwardingComponent<'button', DropdownToggleProps>,
DropdownToggleWithTooltipProps
>(
(
{
children,
toolTipDescription,
overlayTriggerProps,
tooltipProps,
id,
...toggleProps
},
ref
) => {
return (
<OverlayTrigger
overlay={<Tooltip {...tooltipProps}>{toolTipDescription}</Tooltip>}
{...overlayTriggerProps}
>
<BS5DropdownToggle {...toggleProps} ref={ref}>
{children}
</BS5DropdownToggle>
</OverlayTrigger>
)
}
)
DropdownToggleWithTooltip.displayName = 'DropdownToggleWithTooltip'
export default DropdownToggleWithTooltip