import { MenuItemVariant, type Styleable } from "@trackunit/react-components"; import { IconName } from "@trackunit/ui-icons"; import { MouseEventHandler } from "react"; export type Action = { /** The display text for the action button or menu item */ label: string; /** Visual variant of the action, use "danger" for destructive actions */ variant?: MenuItemVariant; /** Callback function triggered when the action is clicked */ onClick: MouseEventHandler; /** Optional icon to display alongside the action label */ iconName?: IconName; /** When true, the action is shown as an icon button outside the dropdown menu */ isSelected?: boolean; /** When true, the action is visually disabled and cannot be clicked */ disabled?: boolean; /** When true, shows a spinner instead of the icon to indicate processing */ loading?: boolean; /** Controls visibility of the action. Defaults to true if not specified */ isVisible?: boolean | null; }; export interface RowActionsProps extends Styleable { /** * Array of actions to display. Single actions render as a button, * multiple actions render as a dropdown menu with selected actions as icon buttons. */ actions: Array; } /** * The `` component displays contextual actions for a table row. * Automatically adapts its rendering based on the number of actions: * - Single action: renders as a standalone button * - Multiple actions: renders selected actions as icon buttons + overflow menu * * Actions can be marked as `isSelected` to display them as quick-access icon buttons * outside the dropdown menu. Danger actions are automatically separated with a divider. * * ### When to use * - Provide row-level actions like Edit, Delete, Download, etc. * - When rows need multiple contextual actions * - For consistent action patterns across data tables * * ### When not to use * - For bulk actions on selected rows - use `ActionSheet` instead * - For a single simple action - consider `ButtonCell` for simpler UI * - For navigation - use `IdentityCell` with link prop * * @example Basic usage with multiple actions * ```tsx * import { RowActions } from "@trackunit/react-table-base-components"; * import { createColumnHelper } from "@tanstack/react-table"; * * const columnHelper = createColumnHelper(); * * const columns = [ * columnHelper.display({ * id: "actions", * header: "", * cell: ({ row }) => ( * handleEdit(row.original.id), * }, * { * label: "Download", * iconName: "ArrowDownTray", * onClick: () => handleDownload(row.original.id), * }, * { * label: "Delete", * iconName: "Trash", * variant: "danger", * onClick: () => handleDelete(row.original.id), * }, * ]} * /> * ), * }), * ]; * ``` * @example With selected (pinned) actions * ```tsx * import { RowActions } from "@trackunit/react-table-base-components"; * * handleEdit(id), * }, * { * label: "Duplicate", * iconName: "DocumentDuplicate", * onClick: () => handleDuplicate(id), * }, * { * label: "Delete", * iconName: "Trash", * variant: "danger", * onClick: () => handleDelete(id), * }, * ]} * /> * ``` * @example With loading and disabled states * ```tsx * import { RowActions } from "@trackunit/react-table-base-components"; * * {}, * }, * { * label: "Unavailable", * iconName: "NoSymbol", * disabled: true, * onClick: () => {}, * }, * { * label: "Hidden Action", * isVisible: false, // Will not be rendered * onClick: () => {}, * }, * ]} * /> * ``` * @param {RowActionsProps} props - The properties for the component. * @returns {ReactElement} A React component rendering the row actions. */ export declare const RowActions: ({ actions, style }: RowActionsProps) => false | import("react/jsx-runtime").JSX.Element | null | undefined;