import { IdType } from 'react-table'; import React, { ReactElement, useState } from 'react'; import css from '../../../utils/css'; import { CommonProps } from '../../common'; import { IconName } from '../../Icon'; import { Wrapper } from './Styled'; import Badge from '../../Badge'; import Button from '../../Button'; import Divider from '../../Divider'; import Dropdown from '../../Dropdown'; import Menu from '../../Menu'; import theme from '../../../theme'; interface BulkActionsProps> extends CommonProps { /** * List of actions */ actions: { divider?: 'top' | 'bottom'; icon?: IconName; intent?: 'text' | 'danger'; onClick: (selectedData: D[]) => void; text: string; }[]; /** * Table data */ data: D[]; /** * Table selected rows */ selectedRows: Record, boolean>; } const BulkActions = >({ data, selectedRows, actions, id, className, style, sx = {}, 'data-test-id': dataTestId, }: BulkActionsProps): ReactElement => { const [open, setOpen] = useState(false); const selectedData = data.filter((_, index) => selectedRows[index]); return ( {actions.map(({ text, icon, intent, onClick, divider }, index) => ( <> {divider === 'top' && } onClick(selectedData)} /> {divider === 'bottom' && ( )} ))} } placement="bottom-right" target={