UNPKG

wix-style-react

Version:
48 lines (40 loc) 1.95 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["style", "data", "index"], _excluded2 = ["style", "data", "index"], _excluded3 = ["data"], _excluded4 = ["data"]; import shallowEqual from 'shallowequal'; import { stVars } from './DataTable.st.css'; export function virtualRowsAreEqual(prevProps, nextProps) { var prevStyle = prevProps.style, prevData = prevProps.data, prevIndex = prevProps.index, prevRest = _objectWithoutProperties(prevProps, _excluded); var nextStyle = nextProps.style, nextData = nextProps.data, nextIndex = nextProps.index, nextRest = _objectWithoutProperties(nextProps, _excluded2); var nextItemData = nextData.data, restNextItemData = _objectWithoutProperties(nextData, _excluded3); var prevItemData = prevData.data, restPrevItemData = _objectWithoutProperties(prevData, _excluded4); return nextIndex === prevIndex && shallowEqual(prevStyle, nextStyle) && shallowEqual(prevItemData[prevIndex], nextItemData[nextIndex]) && shallowEqual(restPrevItemData, restNextItemData) && shallowEqual(prevRest, nextRest); } var CELL_PADDING = parseInt(stVars.cellHorizontalPadding, 10); var CELL_EDGE_PADDING = parseInt(stVars.cellHorizontalEdgePadding, 10); var CELL_EDGE_PADDING_REDUCED_SPACING = parseInt(stVars.cellHorizontalEdgePaddingReducedSpacing, 10); export var getStickyColumnStyle = function getStickyColumnStyle(columns, column, reducedSpacingAndImprovedLayout) { var cellEdgePadding = reducedSpacingAndImprovedLayout ? CELL_EDGE_PADDING_REDUCED_SPACING : CELL_EDGE_PADDING; var left = 0; for (var i = 0; i < columns.length; i++) { var col = columns[i]; if (col === column) { break; } var horizontalPadding = i === 0 ? cellEdgePadding + CELL_PADDING : 2 * CELL_PADDING; left += parseInt(col.width, 10) + horizontalPadding; } return { left: left }; };