import * as React from 'react';
import { IconElement, OmitPolyfill, TooltipCommonProps } from '../common';
import { PopoverMenuProps } from '../PopoverMenu';
import { ButtonWithAsProp } from '../Button';

type CommonTableActionCellProps = {
  dataHook?: string;
  primaryAction?: TableActionCellPrimaryAction;
  secondaryActions?: (
    | TableActionCellSecondaryAction
    | TableActionCellSecondaryDivider
  )[];
  numOfVisibleSecondaryActions?: number;
  alwaysShowSecondaryActions?: boolean;
  moreActionsTooltipText?: string;
  size?: 'tiny' | 'small' | 'medium';
};

export type TableActionCellProps = CommonTableActionCellProps & {
  popoverMenuProps?: OmitPolyfill<
    PopoverMenuProps,
    'triggerElement' | 'children' | 'dataHook' | 'className'
  >;
};

export declare const TableActionCell: React.FC<TableActionCellProps>;
export default TableActionCell;

export type TableActionCellPrimaryActionVisibility = 'onHover' | 'always';
export type TableActionCellPrimaryAction = ButtonWithAsProp<{
  text: string;
  onClick: () => void;
  skin?: 'standard' | 'inverted';
  disabled?: boolean;
  prefixIcon?: IconElement;
  suffixIcon?: IconElement;
  visibility?: TableActionCellPrimaryActionVisibility;
}>;

export type TableActionCellSecondaryAction = {
  text: string;
  icon: IconElement;
  onClick: () => void;
  disabled?: boolean;
  disabledDescription?: string;
  tooltipProps?: TooltipCommonProps;
  skin?: 'dark' | 'destructive';
  subtitle?: string;
  dataHook?: string;
};

export type TableActionCellSecondaryDivider = {
  divider: boolean;
};
