UNPKG

@mui/x-data-grid-pro

Version:

The Pro plan edition of the MUI X Data Grid components.

41 lines (40 loc) 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findSkeletonRowsSection = void 0; var _xDataGrid = require("@mui/x-data-grid"); const findSkeletonRowsSection = ({ apiRef, visibleRows, range }) => { let { firstRowIndex, lastRowIndex } = range; const visibleRowsSection = visibleRows.slice(range.firstRowIndex, range.lastRowIndex); let startIndex = 0; let endIndex = visibleRowsSection.length - 1; let isSkeletonSectionFound = false; while (!isSkeletonSectionFound && firstRowIndex < lastRowIndex) { const isStartingWithASkeletonRow = (0, _xDataGrid.gridRowNodeSelector)(apiRef, visibleRowsSection[startIndex].id)?.type === 'skeletonRow'; const isEndingWithASkeletonRow = (0, _xDataGrid.gridRowNodeSelector)(apiRef, visibleRowsSection[endIndex].id)?.type === 'skeletonRow'; if (isStartingWithASkeletonRow && isEndingWithASkeletonRow) { isSkeletonSectionFound = true; } if (!isStartingWithASkeletonRow) { startIndex += 1; firstRowIndex += 1; } if (!isEndingWithASkeletonRow) { endIndex -= 1; lastRowIndex -= 1; } } return isSkeletonSectionFound ? { firstRowIndex, lastRowIndex } : undefined; }; exports.findSkeletonRowsSection = findSkeletonRowsSection;