@mui/x-data-grid-premium
Version:
The Premium plan edition of the MUI X Data Grid Components.
25 lines • 1.17 kB
JavaScript
import { warnOnce } from '@mui/x-internals/warning';
import { SameParentSwapOperation, CrossParentLeafOperation, CrossParentGroupOperation } from "./operations.js";
/**
* Executor class for handling row reorder operations in grouped data grids.
*
* This class coordinates the execution of different reorder operation types,
* trying each operation in order until one succeeds or all fail.
*/
class RowReorderExecutor {
constructor(operations) {
this.operations = operations;
}
async execute(ctx) {
for (const operation of this.operations) {
const detectedOperation = operation.detectOperation(ctx);
if (detectedOperation) {
// eslint-disable-next-line no-await-in-loop
await operation.executeOperation(detectedOperation, ctx);
return;
}
}
warnOnce(['MUI X: The parameters provided to the `setRowIndex()` resulted in a no-op.', 'Consider looking at the documentation at https://mui.com/x/react-data-grid/row-grouping/'], 'warning');
}
}
export const rowGroupingReorderExecutor = new RowReorderExecutor([new SameParentSwapOperation(), new CrossParentLeafOperation(), new CrossParentGroupOperation()]);