| 1 | import React from "react"; |
| 2 | import { type PlacesType } from "react-tooltip"; |
| 3 | import { HeaderButton } from ".."; |
| 4 | import { ToolTip } from "./Tooltip"; |
| 5 | |
| 6 | interface HeaderButtonWithToolTipProps { |
| 7 | text: string | undefined; |
| 8 | onClick?: (e: any) => void; |
| 9 | children: React.ReactNode; |
| 10 | disabled?: boolean; |
| 11 | inverted?: boolean; |
| 12 | active?: boolean; |
| 13 | className?: string; |
| 14 | onKeyDown?: (e: any) => void; |
| 15 | tabIndex?: number; |
| 16 | style?: React.CSSProperties; |
| 17 | backgroundColor?: string; |
| 18 | hoverBackgroundColor?: string; |
| 19 | tooltipPlacement?: PlacesType; |
| 20 | testId?: string; |
| 21 | } |
| 22 | |
| 23 | const HeaderButtonWithToolTip = React.forwardRef< |
| 24 | HTMLButtonElement, |
| 25 | HeaderButtonWithToolTipProps |
| 26 | >((props: HeaderButtonWithToolTipProps, ref) => { |
| 27 | return ( |
| 28 | <ToolTip |
| 29 | place={props.tooltipPlacement ?? "bottom"} |
| 30 | content={<span className="text-xs">{props.text}</span>} |
| 31 | > |
| 32 | <HeaderButton |
| 33 | hoverBackgroundColor={props.hoverBackgroundColor} |
| 34 | backgroundColor={props.backgroundColor} |
| 35 | data-testid={props.testId} |
| 36 | inverted={props.inverted} |
| 37 | disabled={props.disabled} |
| 38 | onClick={props.onClick} |
| 39 | onKeyDown={props.onKeyDown} |
| 40 | className={props.className} |
| 41 | style={props.style} |
| 42 | ref={ref} |
| 43 | tabIndex={props.tabIndex} |
| 44 | > |
| 45 | {props.children} |
| 46 | </HeaderButton> |
| 47 | </ToolTip> |
| 48 | ); |
| 49 | }); |
| 50 | |
| 51 | export default HeaderButtonWithToolTip; |