// @ts-nocheck import React from 'react'; import { VariableSizeGrid } from 'react-window'; import tw from 'twin.macro'; import { FilterValue } from '../types'; function getCellIndicies(child) { return { row: child?.props.rowIndex || 0, column: child?.props.columnIndex || 0 }; } function getShownIndicies(children) { const firstCell = children[0] const firstIndices = getCellIndicies(firstCell); const lastCell = children[children.length - 1]; const lastIndices = getCellIndicies(lastCell); const minRow = Math.min(firstIndices.row, Infinity) const maxRow = Math.max(lastIndices.row, 0) const minColumn = Math.min(firstIndices.column, Infinity) const maxColumn = Math.max(lastIndices.column, 0) return { from: { row: minRow == Infinity ? 0 : minRow, column: minColumn == Infinity ? 0 : minColumn, }, to: { row: maxRow, column: maxColumn, }, }; } function useInnerElementType( Cell, columnWidth, rowHeight, itemData, numberOfStickiedColumns, HeaderComponent ) { return React.useMemo( () => React.forwardRef((props, ref) => { function sumRowsHeights(index) { let sum = 0; while (index > 1) { sum += rowHeight(index - 1); index -= 1; } return sum; } function sumColumnWidths(index) { let sum = 0; while (index > numberOfStickiedColumns) { sum += columnWidth(index - 1); index -= 1; } return sum; } const shownIndicies = getShownIndicies(props.children); const shownColumnsCount = shownIndicies.to.column - shownIndicies.from.column + 2 || itemData.columnNames.length; const shownRowsCount = shownIndicies.to.row - shownIndicies.from.row; const shownColumns = new Array(shownColumnsCount).fill(0); const shownRows = new Array(shownRowsCount || 1).fill(0); const columnWidths = [...shownColumns, 0].map( (_, i) => columnWidth(i + shownIndicies.from.column) || 0 ); const totalColumnWidths = columnWidths.reduce((a, b) => a + b, 0); return (