import { useState } from "react"; import { BiCaretDown } from "react-icons/bi"; import { VuiOptionsList } from "../optionsList/OptionsList"; import { VuiPopover } from "../popover/Popover"; import { VuiIcon } from "../icon/Icon"; import { VuiButtonSecondary } from "../button/ButtonSecondary"; import { Action } from "./TableRowActions"; import { Row } from "./types"; export type Props = { selectedRows: any; actions: Action[]; }; export const VuiTableBulkActions = ({ selectedRows, actions }: Props) => { const [isOpen, setIsOpen] = useState(false); let content; if (actions.length === 1) { content = ( actions[0].onClick && actions[0].onClick(selectedRows)} > {actions[0].label} ); } else { content = ( setIsOpen(!isOpen)} button={ } > {selectedRows.length} selected } > { setIsOpen(false); }} options={actions.map(({ href, ...action }) => ({ ...action, href: href?.(selectedRows), value: selectedRows }))} size="m" /> ); } return content; };