import type { FunctionComponent, MouseEvent, Ref } from 'react'; import { forwardRef } from 'react'; import { Button, ButtonProps, Icon, Tooltip, TooltipProps } from '@patternfly/react-core'; export interface ResponseActionButtonProps extends ButtonProps { /** Aria-label for the button. Defaults to the value of the tooltipContent if none provided */ ariaLabel?: string; /** Aria-label for the button, shown when the button is clicked. Defaults to the value of ariaLabel or tooltipContent if not provided. */ clickedAriaLabel?: string; /** Icon for the button */ icon: React.ReactNode; /** On-click handler for the button */ onClick?: ((event: MouseEvent | React.MouseEvent | KeyboardEvent) => void) | undefined; /** Class name for the button */ className?: string; /** Props to control if the attach button should be disabled */ isDisabled?: boolean; /** Content shown in the tooltip */ tooltipContent?: string; /** Content shown in the tooltip when the button is clicked. Defaults to the value of tooltipContent if not provided. */ clickedTooltipContent?: string; /** Props to control the PF Tooltip component */ tooltipProps?: TooltipProps; /** Whether button is in clicked state */ isClicked?: boolean; /** Ref applied to button */ innerRef?: React.Ref; } export const ResponseActionButtonBase: FunctionComponent = ({ ariaLabel, clickedAriaLabel = ariaLabel, className, icon, isDisabled, onClick, tooltipContent, clickedTooltipContent = tooltipContent, tooltipProps, isClicked = false, innerRef, ...props }) => { const generateAriaLabel = () => { if (ariaLabel) { return isClicked ? clickedAriaLabel : ariaLabel; } return isClicked ? clickedTooltipContent : tooltipContent; }; return ( ); }; const ResponseActionButton = forwardRef((props: ResponseActionButtonProps, ref: Ref) => ( )); export default ResponseActionButton;