2023-04-26 03:52:25 -04:00
|
|
|
import { forwardRef } from 'react'
|
|
|
|
import Tooltip from '../tooltip'
|
|
|
|
import classnames from 'classnames'
|
|
|
|
import { DropdownProps } from 'react-bootstrap'
|
|
|
|
import { MergeAndOverride } from '../../../../../types/utils'
|
|
|
|
|
|
|
|
type CustomToggleProps = MergeAndOverride<
|
2023-05-12 05:19:05 -04:00
|
|
|
Pick<DropdownProps, 'bsClass' | 'open'>,
|
2023-04-26 03:52:25 -04:00
|
|
|
{
|
|
|
|
children: React.ReactNode
|
|
|
|
bsRole: 'toggle'
|
|
|
|
className?: string
|
|
|
|
tooltipProps: Omit<React.ComponentProps<typeof Tooltip>, 'children'>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
|
|
|
|
const DropdownToggleWithTooltip = forwardRef<
|
|
|
|
HTMLButtonElement,
|
|
|
|
CustomToggleProps
|
|
|
|
>(function (props, ref) {
|
|
|
|
const {
|
|
|
|
tooltipProps,
|
|
|
|
children,
|
|
|
|
bsClass,
|
|
|
|
className,
|
2023-05-12 05:19:05 -04:00
|
|
|
open,
|
2023-04-26 03:52:25 -04:00
|
|
|
bsRole: _bsRole,
|
|
|
|
...rest
|
|
|
|
} = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Tooltip {...tooltipProps}>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
ref={ref}
|
|
|
|
className={classnames(bsClass, 'btn', className)}
|
2023-05-12 05:19:05 -04:00
|
|
|
aria-expanded={open}
|
|
|
|
aria-haspopup="true"
|
2023-04-26 03:52:25 -04:00
|
|
|
{...rest}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
})
|
|
|
|
DropdownToggleWithTooltip.displayName = 'DropdownToggleWithTooltip'
|
|
|
|
|
|
|
|
export default DropdownToggleWithTooltip
|