@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
48 lines (47 loc) • 1.58 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { factory, Grid, Group, useProps } from '@mantine/core';
import { useMemo } from 'react';
import { TableComponentsOrder } from '../Table';
import { useTableContext } from '../TableContext';
import { TableActionsList } from './TableActionsList';
const defaultProps = {};
export const TableHeaderActions = factory((props, ref)=>{
const { store, getStyles, getRowActions } = useTableContext();
const { style, className, classNames, styles, ...others } = useProps('PlasmaTableHeaderActions', defaultProps, props);
const actions = useMemo(()=>{
const selectedRows = store.getSelectedRows();
if (selectedRows.length === 0) {
return [];
}
return getRowActions(selectedRows);
}, [
store.state.rowSelection
]);
if (actions.length === 0) {
return null;
}
const stylesApiProps = {
classNames,
styles
};
return /*#__PURE__*/ _jsx(Grid.Col, {
span: "content",
order: TableComponentsOrder.Actions,
ref: ref,
...getStyles('headerActionsRoot', {
className,
style,
...stylesApiProps
}),
...others,
children: /*#__PURE__*/ _jsx(Group, {
gap: "xs",
...getStyles('headerActionsGroup', stylesApiProps),
children: /*#__PURE__*/ _jsx(TableActionsList, {
actions: actions,
variant: "split"
})
})
});
});
//# sourceMappingURL=TableHeaderActions.js.map