import * as DropdownMenu from "@radix-ui/react-dropdown-menu" import clsx from "clsx" import React from "react" import Button from "../fundamentals/button" import MoreHorizontalIcon from "../fundamentals/icons/more-horizontal-icon" export type ActionType = { label: string onClick: (e: React.MouseEvent) => void variant?: "normal" | "danger" disabled?: boolean icon?: React.ReactNode } type ActionablesProps = { actions?: ActionType[] customTrigger?: React.ReactNode forceDropdown?: boolean } const Actionables: React.FC = ({ actions, customTrigger, forceDropdown = false, }) => { if (actions && (forceDropdown || actions.length > 1)) { return (
{!customTrigger ? ( ) : ( customTrigger )} {actions.map((action, i) => { return ( { } ) })}
) } if (customTrigger) { const triggers = Array.isArray(customTrigger) ? customTrigger : [customTrigger] return (
{triggers.map((trigger, i) => (
{trigger}
))}
) } const [action] = actions ?? [] if (action) { return (
) } return null } export default Actionables