@redsift/table 11.8.2 → 11.8.3

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 { b 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 { gridExpandedSortedRowEntriesSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
6
6
  import { p as chainPropTypes, P as PropTypes, o as ownerDocument, t as useEnhancedEffect, u as useTheme$1, y as defaultTheme, T as THEME_ID, q as useForkRef, z as exactProp, f as generateUtilityClass, g as generateUtilityClasses, _ as _objectWithoutPropertiesLoose, a as _extends, v as useSlotProps, n as Portal, H as HTMLElementType, l as composeClasses, w as useClassNamesOverride, h as styled, j as useThemeProps, c as clsx, A as isHostComponent, m as refType, k 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,11 +10321,21 @@ 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 => {
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(gridExpandedSortedRowEntriesSelector(apiRef.current.state));
10332
+ const selectableRowsInPage = isRowSelectable ? rowsInPage.filter(_ref => {
10325
10333
  let {
10334
+ id,
10326
10335
  model
10327
10336
  } = _ref;
10328
10337
  return isRowSelectable({
10338
+ id,
10329
10339
  row: model
10330
10340
  });
10331
10341
  }).map(_ref2 => {
@@ -10333,7 +10343,12 @@ const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionS
10333
10343
  id
10334
10344
  } = _ref2;
10335
10345
  return id;
10336
- }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
10346
+ }) : rowsInPage.map(_ref3 => {
10347
+ let {
10348
+ id
10349
+ } = _ref3;
10350
+ return id;
10351
+ });
10337
10352
  const numberOfSelectableRowsInPage = selectableRowsInPage.length;
10338
10353
  const numberOfSelectedRows = newSelectionModel.length;
10339
10354
  const selectedRowsInPage = selectableRowsInPage.filter(rowId => newSelectionModel.includes(rowId));
@@ -10375,7 +10390,7 @@ const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionS
10375
10390
  };
10376
10391
  }
10377
10392
  };
10378
- const ServerSideControlledPagination = _ref3 => {
10393
+ const ServerSideControlledPagination = _ref4 => {
10379
10394
  let {
10380
10395
  selectionStatus,
10381
10396
  displaySelection,
@@ -10386,7 +10401,7 @@ const ServerSideControlledPagination = _ref3 => {
10386
10401
  displayRowsPerPage,
10387
10402
  paginationProps,
10388
10403
  rowCount
10389
- } = _ref3;
10404
+ } = _ref4;
10390
10405
  const totalNumberOfRowsInTable = rowCount;
10391
10406
  const totalRowsLabel = `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`;
10392
10407
  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)` : ''}.`;