UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

51 lines (50 loc) 1.63 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { MoreSize16Px } from '@coveord/plasma-react-icons'; import { useProps } from '@mantine/core'; import { TableActionsList } from '../table-actions/TableActionsList.js'; import { useTableContext } from '../TableContext.js'; import { TableColumnsSelector } from '../table-columns-selector/TableColumnsSelector.js'; /** * Generic column to use when your table needs actions on rows */ export const TableActionsColumn = { id: 'actions', enableSorting: false, enableHiding: false, meta: { controlColumn: true }, header: ({ table })=>{ const rowConfigurable = table.options.meta?.rowConfigurable; if (!rowConfigurable) { return null; } const options = typeof rowConfigurable === 'boolean' ? {} : rowConfigurable; return /*#__PURE__*/ _jsx(TableColumnsSelector, { table: table, options: options }); }, size: 84, cell: (info)=>/*#__PURE__*/ _jsx(ActionsMenu, { info: info }) }; const defaultProps = { label: 'Actions', icon: /*#__PURE__*/ _jsx(MoreSize16Px, { height: 16 }) }; const ActionsMenu = (props)=>{ const { getRowActions } = useTableContext(); const { info, ...others } = useProps('PlasmaTableActionsColumn', defaultProps, props); const actionsElements = getRowActions([ info.row.original ]); return /*#__PURE__*/ _jsx(TableActionsList, { actions: actionsElements, variant: "combined", ...others }); }; //# sourceMappingURL=TableActionsColumn.js.map