@redsift/table 11.8.2-muiv5 → 11.8.3-muiv5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { a as _extends$1 } from './_rollupPluginBabelHelpers.js';
2
2
  import * as React from 'react';
3
3
  import React__default, { Children, isValidElement, cloneElement, createElement } from 'react';
4
4
  import { Flexbox, Text, LinkButton } from '@redsift/design-system';
5
- import { gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
5
+ import { gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
6
6
  import { t as chainPropTypes, P as PropTypes, p as ownerDocument, w as useEnhancedEffect, u as useTheme$1, z as defaultTheme, T as THEME_ID, v as useForkRef, e as exactProp, j as generateUtilityClass, h as generateUtilityClasses, _ as _objectWithoutPropertiesLoose, a as _extends, x as useSlotProps, q as Portal, H as HTMLElementType, n as composeClasses, y as useClassNamesOverride, k as styled, l as useThemeProps, c as clsx, A as isHostComponent, o as refType, m as capitalize, B as formatMuiErrorMessage, r as rootShouldForwardProp, D as deepmerge, E as reactIsExports, F as resolveComponentProps, G as alpha, I as slotShouldForwardProp, J as lighten, K as darken } from './Portal.js';
7
7
  import { j as jsxRuntimeExports } from './jsx-runtime.js';
8
8
  import { Global, keyframes } from '@emotion/react';
@@ -10321,19 +10321,22 @@ process.env.NODE_ENV !== "production" ? TablePagination.propTypes /* remove-prop
10321
10321
  var TablePagination$1 = TablePagination;
10322
10322
 
10323
10323
  const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionStatus, isRowSelectable, page, pageSize) => {
10324
- const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
10325
- let {
10326
- model
10327
- } = _ref;
10328
- return isRowSelectable({
10329
- row: model
10330
- });
10331
- }).map(_ref2 => {
10324
+ // We can't rely on the gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef) function to fetch the list of visible rows
10325
+ // as it doesn't work properly when all rows are selected on a page via checkbox
10326
+ // and then navigate to another page.
10327
+ // So instead we fetch the visible rows directly from the apiRef state, since the logic in `onServerSideSelectionStatusChange` applies
10328
+ // to server-side pagination only and visible rows are all loaded rows.
10329
+ // The bug may have been latent for several MUI releases now, as it seems to have been fixed in MUI v7.
10330
+ // See https://github.com/mui/mui-x/pull/14083
10331
+ const rowsInPage = Array.from(apiRef.current.getVisibleRowModels().values());
10332
+ const selectableRowsInPage = isRowSelectable ? rowsInPage.filter(model => isRowSelectable({
10333
+ row: model
10334
+ })).map(_ref => {
10332
10335
  let {
10333
10336
  id
10334
- } = _ref2;
10337
+ } = _ref;
10335
10338
  return id;
10336
- }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
10339
+ }) : rowsInPage;
10337
10340
  const numberOfSelectableRowsInPage = selectableRowsInPage.length;
10338
10341
  const numberOfSelectedRows = newSelectionModel.length;
10339
10342
  const selectedRowsInPage = selectableRowsInPage.filter(rowId => newSelectionModel.includes(rowId));
@@ -10375,7 +10378,7 @@ const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionS
10375
10378
  };
10376
10379
  }
10377
10380
  };
10378
- const ServerSideControlledPagination = _ref3 => {
10381
+ const ServerSideControlledPagination = _ref2 => {
10379
10382
  let {
10380
10383
  selectionStatus,
10381
10384
  displaySelection,
@@ -10388,7 +10391,7 @@ const ServerSideControlledPagination = _ref3 => {
10388
10391
  rowsPerPageOptions,
10389
10392
  paginationProps,
10390
10393
  rowCount
10391
- } = _ref3;
10394
+ } = _ref2;
10392
10395
  const totalNumberOfRowsInTable = rowCount;
10393
10396
  const totalRowsLabel = `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`;
10394
10397
  const pageRowsLabel = `All ${selectionStatus.numberOfSelectedRowsInPage} selectable rows on this page are selected${selectionStatus.numberOfSelectedRows != selectionStatus.numberOfSelectedRowsInPage ? ` (${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected in total)` : ''}.`;