import type { CellContext } from "@tanstack/react-table"; import type { CellMetadata, Operation } from "../../../interfaces"; import type { JSONRecord } from "../../../interfaces/JSONRecord.js"; import { getComponent, registerComponent } from "../../../registries/components"; import type { DefaultOperationButton } from "./DefaultOperationButton"; export interface DefaultCellOperationsProps { info: CellContext; operations: Operation[]; metadata?: CellMetadata; i18n: (i18n: string) => string; onClick?: (data: any, operation: Operation) => void; } export function DefaultCellOperations({ info, metadata, operations, i18n, onClick }: DefaultCellOperationsProps) { const Button = getComponent>("OperationButton"); return (
{operations .filter(({ permissionsResolver, ...operation }) => { return !permissionsResolver || permissionsResolver(info.row.original, metadata || {}, operation); }) .map((operation) => { return (
); } registerComponent("CellOperations", DefaultCellOperations);