@procore/data-table 13.2.2 → 13.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 13.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c26355a12a: Allow selecting items across pages in SSRM
8
+
3
9
  ## 13.2.2
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -588,13 +588,13 @@ interface TableApi {
588
588
  * The row node ID is the one you provide from the callback `getRowId(data)`,
589
589
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
590
590
  */
591
- selectRows: (rowIds: (string | number)[]) => void;
591
+ selectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
592
592
  /**
593
593
  * Deselects row nodes by their respective row node IDs.
594
594
  * The row node ID is the one you provide from the callback `getRowId(data)`,
595
595
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
596
596
  */
597
- deselectRows: (rowIds: (string | number)[]) => void;
597
+ deselectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
598
598
  /**
599
599
  * Set a function determining if selection is enabled for each row as it's loaded into the table.
600
600
  * Note: Changing this will not affect existing rows that have already been loaded. Additionally,
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -588,13 +588,13 @@ interface TableApi {
588
588
  * The row node ID is the one you provide from the callback `getRowId(data)`,
589
589
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
590
590
  */
591
- selectRows: (rowIds: (string | number)[]) => void;
591
+ selectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
592
592
  /**
593
593
  * Deselects row nodes by their respective row node IDs.
594
594
  * The row node ID is the one you provide from the callback `getRowId(data)`,
595
595
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
596
596
  */
597
- deselectRows: (rowIds: (string | number)[]) => void;
597
+ deselectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
598
598
  /**
599
599
  * Set a function determining if selection is enabled for each row as it's loaded into the table.
600
600
  * Note: Changing this will not affect existing rows that have already been loaded. Additionally,
@@ -55306,7 +55306,7 @@ function ClientSideRowCheckbox(props) {
55306
55306
  "data-qa": "rowCheckbox",
55307
55307
  onClick: noop2,
55308
55308
  onChange: () => {
55309
- props.node.setSelected(!selected);
55309
+ props.node.setSelected(!selected, void 0, "checkboxSelected");
55310
55310
  }
55311
55311
  }
55312
55312
  ));
@@ -55346,7 +55346,13 @@ function ServerSideRowCheckbox(props) {
55346
55346
  onClick: noop2,
55347
55347
  onChange: () => {
55348
55348
  var _a2, _b2;
55349
- props.node.isSelected() ? (_a2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _a2.deselectRows([props.node.id]) : (_b2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b2.selectRows([props.node.id]);
55349
+ props.node.isSelected() ? (_a2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _a2.deselectRows(
55350
+ [props.node.id],
55351
+ "checkboxSelected"
55352
+ ) : (_b2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b2.selectRows(
55353
+ [props.node.id],
55354
+ "checkboxSelected"
55355
+ );
55350
55356
  }
55351
55357
  }
55352
55358
  ));
@@ -56482,8 +56488,12 @@ var GenericHeaderRenderer = (props) => {
56482
56488
  if (!onSSDR || !isFirstColumn2 || !props.selectionSSREnabled) {
56483
56489
  return;
56484
56490
  }
56485
- function updateSelectAllCheckbox() {
56486
- const currentRows = getCurrentRows(props.api);
56491
+ function updateSelectAllCheckbox(e) {
56492
+ if (e.source === "uiSelectAll") {
56493
+ return;
56494
+ }
56495
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56496
+ const currentRows = getCurrentRows(props.api, isPagination);
56487
56497
  const isAllSelected = currentRows.length && currentRows.every(isRowSelected);
56488
56498
  const isPartialSelected = !isAllSelected && currentRows.some(isRowSelected);
56489
56499
  if (isAllSelected) {
@@ -56500,19 +56510,36 @@ var GenericHeaderRenderer = (props) => {
56500
56510
  props.api.removeEventListener(selectionChanged, updateSelectAllCheckbox);
56501
56511
  props.api.removeEventListener(paginationChanged, updateSelectAllCheckbox);
56502
56512
  };
56503
- }, [isFirstColumn2, selectAll, props.selectionSSREnabled]);
56504
- const toggleSelectAll = () => {
56513
+ }, [isFirstColumn2, props.selectionSSREnabled, props.api, onSSDR]);
56514
+ const toggleSelectAll = React82__default.default.useCallback(() => {
56505
56515
  var _a2, _b, _c;
56506
56516
  const nextSelectedState = selectAll === "all" /* All */ ? "none" /* None */ : "all" /* All */;
56507
56517
  setSelectAll(nextSelectedState);
56508
56518
  (_a2 = props.onSelectAll) == null ? void 0 : _a2.call(props, nextSelectedState);
56509
56519
  const isSelectAll = nextSelectedState == "all" /* All */;
56510
56520
  if (props.selectionSSREnabled) {
56511
- isSelectAll ? (_b = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b.selectAll() : (_c = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _c.deselectAll();
56521
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56522
+ const rowsIdsToSelectOrDeselect = getCurrentRows(
56523
+ props.api,
56524
+ isPagination
56525
+ ).map((node) => node.id);
56526
+ isSelectAll ? (_b = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b.selectRows(
56527
+ rowsIdsToSelectOrDeselect,
56528
+ "uiSelectAll"
56529
+ ) : (_c = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _c.deselectRows(
56530
+ rowsIdsToSelectOrDeselect,
56531
+ "uiSelectAll"
56532
+ );
56512
56533
  } else {
56513
56534
  isSelectAll ? props.api.selectAllFiltered() : props.api.deselectAllFiltered();
56514
56535
  }
56515
- };
56536
+ }, [
56537
+ setSelectAll,
56538
+ selectAll,
56539
+ props.onSelectAll,
56540
+ props.selectionSSREnabled,
56541
+ props.api
56542
+ ]);
56516
56543
  return /* @__PURE__ */ React82__default.default.createElement(
56517
56544
  coreReact.Flex,
56518
56545
  {
@@ -56548,9 +56575,7 @@ var GenericHeaderRenderer = (props) => {
56548
56575
  checked: selectAll === "all" /* All */,
56549
56576
  indeterminate: selectAll === "partial",
56550
56577
  onClick: (e) => e.stopPropagation(),
56551
- onChange: () => {
56552
- toggleSelectAll();
56553
- }
56578
+ onChange: toggleSelectAll
56554
56579
  }
56555
56580
  ),
56556
56581
  /* @__PURE__ */ React82__default.default.createElement("div", { className: "ag-header-cell-label" }, /* @__PURE__ */ React82__default.default.createElement(
@@ -56622,6 +56647,20 @@ function GenericColumnGroupHeader(props) {
56622
56647
  ));
56623
56648
  }
56624
56649
 
56650
+ // src/utils/pagination.ts
56651
+ var getPaginationPageStartEnd = ({
56652
+ activePage,
56653
+ items: totalItems,
56654
+ perPage
56655
+ }) => {
56656
+ const numPages = Math.ceil(totalItems / perPage);
56657
+ const actualActivePage = numPages === 0 ? 0 : activePage + 1;
56658
+ return {
56659
+ end: Math.min(actualActivePage * perPage, totalItems),
56660
+ start: Math.max((actualActivePage - 1) * perPage, 0)
56661
+ };
56662
+ };
56663
+
56625
56664
  // src/utils/cellHelpers.tsx
56626
56665
  function withDataTableEditor(Component4, editorType) {
56627
56666
  return React82__default.default.forwardRef(
@@ -56703,7 +56742,7 @@ function getFrameworkComponents(headerMenuConfig, onSelectAll, selectionSSREnabl
56703
56742
  DefaultFrameworkComponents["autoGroupCellRenderer"] = AutoGroupCellRenderer;
56704
56743
  return { ...DefaultFrameworkComponents, ...customFrameworkComponents };
56705
56744
  }
56706
- function getCurrentRows(gridApi) {
56745
+ function getCurrentRows(gridApi, useCurrentPageOnly) {
56707
56746
  var _a;
56708
56747
  let currentRows = [];
56709
56748
  if (((_a = gridApi == null ? void 0 : gridApi.getModel()) == null ? void 0 : _a.getType()) === "clientSide") {
@@ -56714,6 +56753,16 @@ function getCurrentRows(gridApi) {
56714
56753
  gridApi == null ? void 0 : gridApi.forEachNode((rowNode) => {
56715
56754
  currentRows.push(rowNode);
56716
56755
  });
56756
+ if (useCurrentPageOnly) {
56757
+ const { start, end } = getPaginationPageStartEnd({
56758
+ items: (gridApi == null ? void 0 : gridApi.paginationGetRowCount()) || 0,
56759
+ perPage: (gridApi == null ? void 0 : gridApi.paginationGetPageSize()) || 0,
56760
+ activePage: (gridApi == null ? void 0 : gridApi.paginationGetCurrentPage()) || 0
56761
+ });
56762
+ return currentRows.filter(
56763
+ (row2) => row2.rowIndex >= start && row2.rowIndex < end
56764
+ );
56765
+ }
56717
56766
  }
56718
56767
  return currentRows;
56719
56768
  }
@@ -58831,10 +58880,8 @@ var useRowSelectionState = () => {
58831
58880
  }
58832
58881
  selectionEventFunction();
58833
58882
  gridApi == null ? void 0 : gridApi.addEventListener("selectionChanged", selectionEventFunction);
58834
- gridApi == null ? void 0 : gridApi.addEventListener("paginationChanged", selectionEventFunction);
58835
58883
  return () => {
58836
58884
  gridApi == null ? void 0 : gridApi.removeEventListener("selectionChanged", selectionEventFunction);
58837
- gridApi == null ? void 0 : gridApi.removeEventListener("paginationChanged", selectionEventFunction);
58838
58885
  };
58839
58886
  }, [gridApi]);
58840
58887
  return selectedRows;
@@ -80871,24 +80918,24 @@ var useTableApi = ({
80871
80918
  });
80872
80919
  };
80873
80920
  const selectRows = React82__default.default.useCallback(
80874
- (rowIds) => {
80921
+ (rowIds, source) => {
80875
80922
  rowIds == null ? void 0 : rowIds.forEach((id) => {
80876
80923
  const rowNode = gridApi == null ? void 0 : gridApi.getRowNode(id.toString());
80877
80924
  if (!rowNode)
80878
80925
  return;
80879
- rowNode.setSelected(true);
80926
+ rowNode.setSelected(true, void 0, source);
80880
80927
  onSelectionChanged(rowNode);
80881
80928
  });
80882
80929
  },
80883
80930
  [gridApi]
80884
80931
  );
80885
80932
  const deselectRows = React82__default.default.useCallback(
80886
- (rowIds) => {
80933
+ (rowIds, source) => {
80887
80934
  rowIds == null ? void 0 : rowIds.forEach((id) => {
80888
80935
  const rowNode = gridApi == null ? void 0 : gridApi.getRowNode(id.toString());
80889
80936
  if (!rowNode)
80890
80937
  return;
80891
- rowNode.setSelected(false);
80938
+ rowNode.setSelected(false, void 0, source);
80892
80939
  onSelectionChanged(rowNode);
80893
80940
  });
80894
80941
  },
@@ -82271,19 +82318,13 @@ var TablePagination = ({
82271
82318
  page: 0,
82272
82319
  items: 0
82273
82320
  });
82274
- const { rowSelectionRef } = useInternalTableContext();
82275
82321
  React82__default.default.useEffect(() => {
82276
82322
  function onPaginationChanged(params) {
82277
- var _a;
82278
82323
  if (gridApi && params.api.paginationGetCurrentPage() !== pagination.page || pagination.items !== params.api.paginationGetRowCount()) {
82279
82324
  setPagination({
82280
82325
  page: params.api.paginationGetCurrentPage(),
82281
82326
  items: params.api.paginationGetRowCount()
82282
82327
  });
82283
- if (params.api.getModel().getType() === "serverSide") {
82284
- ((_a = rowSelectionRef == null ? void 0 : rowSelectionRef.current) == null ? void 0 : _a.affectedRows) && (rowSelectionRef.current.affectedRows = {});
82285
- gridApi == null ? void 0 : gridApi.deselectAll();
82286
- }
82287
82328
  }
82288
82329
  }
82289
82330
  gridApi == null ? void 0 : gridApi.addEventListener("paginationChanged", onPaginationChanged);
@@ -55291,7 +55291,7 @@ function ClientSideRowCheckbox(props) {
55291
55291
  "data-qa": "rowCheckbox",
55292
55292
  onClick: noop2,
55293
55293
  onChange: () => {
55294
- props.node.setSelected(!selected);
55294
+ props.node.setSelected(!selected, void 0, "checkboxSelected");
55295
55295
  }
55296
55296
  }
55297
55297
  ));
@@ -55331,7 +55331,13 @@ function ServerSideRowCheckbox(props) {
55331
55331
  onClick: noop2,
55332
55332
  onChange: () => {
55333
55333
  var _a2, _b2;
55334
- props.node.isSelected() ? (_a2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _a2.deselectRows([props.node.id]) : (_b2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b2.selectRows([props.node.id]);
55334
+ props.node.isSelected() ? (_a2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _a2.deselectRows(
55335
+ [props.node.id],
55336
+ "checkboxSelected"
55337
+ ) : (_b2 = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b2.selectRows(
55338
+ [props.node.id],
55339
+ "checkboxSelected"
55340
+ );
55335
55341
  }
55336
55342
  }
55337
55343
  ));
@@ -56467,8 +56473,12 @@ var GenericHeaderRenderer = (props) => {
56467
56473
  if (!onSSDR || !isFirstColumn2 || !props.selectionSSREnabled) {
56468
56474
  return;
56469
56475
  }
56470
- function updateSelectAllCheckbox() {
56471
- const currentRows = getCurrentRows(props.api);
56476
+ function updateSelectAllCheckbox(e) {
56477
+ if (e.source === "uiSelectAll") {
56478
+ return;
56479
+ }
56480
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56481
+ const currentRows = getCurrentRows(props.api, isPagination);
56472
56482
  const isAllSelected = currentRows.length && currentRows.every(isRowSelected);
56473
56483
  const isPartialSelected = !isAllSelected && currentRows.some(isRowSelected);
56474
56484
  if (isAllSelected) {
@@ -56485,19 +56495,36 @@ var GenericHeaderRenderer = (props) => {
56485
56495
  props.api.removeEventListener(selectionChanged, updateSelectAllCheckbox);
56486
56496
  props.api.removeEventListener(paginationChanged, updateSelectAllCheckbox);
56487
56497
  };
56488
- }, [isFirstColumn2, selectAll, props.selectionSSREnabled]);
56489
- const toggleSelectAll = () => {
56498
+ }, [isFirstColumn2, props.selectionSSREnabled, props.api, onSSDR]);
56499
+ const toggleSelectAll = React82.useCallback(() => {
56490
56500
  var _a2, _b, _c;
56491
56501
  const nextSelectedState = selectAll === "all" /* All */ ? "none" /* None */ : "all" /* All */;
56492
56502
  setSelectAll(nextSelectedState);
56493
56503
  (_a2 = props.onSelectAll) == null ? void 0 : _a2.call(props, nextSelectedState);
56494
56504
  const isSelectAll = nextSelectedState == "all" /* All */;
56495
56505
  if (props.selectionSSREnabled) {
56496
- isSelectAll ? (_b = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b.selectAll() : (_c = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _c.deselectAll();
56506
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56507
+ const rowsIdsToSelectOrDeselect = getCurrentRows(
56508
+ props.api,
56509
+ isPagination
56510
+ ).map((node) => node.id);
56511
+ isSelectAll ? (_b = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _b.selectRows(
56512
+ rowsIdsToSelectOrDeselect,
56513
+ "uiSelectAll"
56514
+ ) : (_c = tableRef == null ? void 0 : tableRef.current) == null ? void 0 : _c.deselectRows(
56515
+ rowsIdsToSelectOrDeselect,
56516
+ "uiSelectAll"
56517
+ );
56497
56518
  } else {
56498
56519
  isSelectAll ? props.api.selectAllFiltered() : props.api.deselectAllFiltered();
56499
56520
  }
56500
- };
56521
+ }, [
56522
+ setSelectAll,
56523
+ selectAll,
56524
+ props.onSelectAll,
56525
+ props.selectionSSREnabled,
56526
+ props.api
56527
+ ]);
56501
56528
  return /* @__PURE__ */ React82.createElement(
56502
56529
  Flex,
56503
56530
  {
@@ -56533,9 +56560,7 @@ var GenericHeaderRenderer = (props) => {
56533
56560
  checked: selectAll === "all" /* All */,
56534
56561
  indeterminate: selectAll === "partial",
56535
56562
  onClick: (e) => e.stopPropagation(),
56536
- onChange: () => {
56537
- toggleSelectAll();
56538
- }
56563
+ onChange: toggleSelectAll
56539
56564
  }
56540
56565
  ),
56541
56566
  /* @__PURE__ */ React82.createElement("div", { className: "ag-header-cell-label" }, /* @__PURE__ */ React82.createElement(
@@ -56607,6 +56632,20 @@ function GenericColumnGroupHeader(props) {
56607
56632
  ));
56608
56633
  }
56609
56634
 
56635
+ // src/utils/pagination.ts
56636
+ var getPaginationPageStartEnd = ({
56637
+ activePage,
56638
+ items: totalItems,
56639
+ perPage
56640
+ }) => {
56641
+ const numPages = Math.ceil(totalItems / perPage);
56642
+ const actualActivePage = numPages === 0 ? 0 : activePage + 1;
56643
+ return {
56644
+ end: Math.min(actualActivePage * perPage, totalItems),
56645
+ start: Math.max((actualActivePage - 1) * perPage, 0)
56646
+ };
56647
+ };
56648
+
56610
56649
  // src/utils/cellHelpers.tsx
56611
56650
  function withDataTableEditor(Component4, editorType) {
56612
56651
  return React82.forwardRef(
@@ -56688,7 +56727,7 @@ function getFrameworkComponents(headerMenuConfig, onSelectAll, selectionSSREnabl
56688
56727
  DefaultFrameworkComponents["autoGroupCellRenderer"] = AutoGroupCellRenderer;
56689
56728
  return { ...DefaultFrameworkComponents, ...customFrameworkComponents };
56690
56729
  }
56691
- function getCurrentRows(gridApi) {
56730
+ function getCurrentRows(gridApi, useCurrentPageOnly) {
56692
56731
  var _a;
56693
56732
  let currentRows = [];
56694
56733
  if (((_a = gridApi == null ? void 0 : gridApi.getModel()) == null ? void 0 : _a.getType()) === "clientSide") {
@@ -56699,6 +56738,16 @@ function getCurrentRows(gridApi) {
56699
56738
  gridApi == null ? void 0 : gridApi.forEachNode((rowNode) => {
56700
56739
  currentRows.push(rowNode);
56701
56740
  });
56741
+ if (useCurrentPageOnly) {
56742
+ const { start, end } = getPaginationPageStartEnd({
56743
+ items: (gridApi == null ? void 0 : gridApi.paginationGetRowCount()) || 0,
56744
+ perPage: (gridApi == null ? void 0 : gridApi.paginationGetPageSize()) || 0,
56745
+ activePage: (gridApi == null ? void 0 : gridApi.paginationGetCurrentPage()) || 0
56746
+ });
56747
+ return currentRows.filter(
56748
+ (row2) => row2.rowIndex >= start && row2.rowIndex < end
56749
+ );
56750
+ }
56702
56751
  }
56703
56752
  return currentRows;
56704
56753
  }
@@ -58816,10 +58865,8 @@ var useRowSelectionState = () => {
58816
58865
  }
58817
58866
  selectionEventFunction();
58818
58867
  gridApi == null ? void 0 : gridApi.addEventListener("selectionChanged", selectionEventFunction);
58819
- gridApi == null ? void 0 : gridApi.addEventListener("paginationChanged", selectionEventFunction);
58820
58868
  return () => {
58821
58869
  gridApi == null ? void 0 : gridApi.removeEventListener("selectionChanged", selectionEventFunction);
58822
- gridApi == null ? void 0 : gridApi.removeEventListener("paginationChanged", selectionEventFunction);
58823
58870
  };
58824
58871
  }, [gridApi]);
58825
58872
  return selectedRows;
@@ -80856,24 +80903,24 @@ var useTableApi = ({
80856
80903
  });
80857
80904
  };
80858
80905
  const selectRows = React82.useCallback(
80859
- (rowIds) => {
80906
+ (rowIds, source) => {
80860
80907
  rowIds == null ? void 0 : rowIds.forEach((id) => {
80861
80908
  const rowNode = gridApi == null ? void 0 : gridApi.getRowNode(id.toString());
80862
80909
  if (!rowNode)
80863
80910
  return;
80864
- rowNode.setSelected(true);
80911
+ rowNode.setSelected(true, void 0, source);
80865
80912
  onSelectionChanged(rowNode);
80866
80913
  });
80867
80914
  },
80868
80915
  [gridApi]
80869
80916
  );
80870
80917
  const deselectRows = React82.useCallback(
80871
- (rowIds) => {
80918
+ (rowIds, source) => {
80872
80919
  rowIds == null ? void 0 : rowIds.forEach((id) => {
80873
80920
  const rowNode = gridApi == null ? void 0 : gridApi.getRowNode(id.toString());
80874
80921
  if (!rowNode)
80875
80922
  return;
80876
- rowNode.setSelected(false);
80923
+ rowNode.setSelected(false, void 0, source);
80877
80924
  onSelectionChanged(rowNode);
80878
80925
  });
80879
80926
  },
@@ -82256,19 +82303,13 @@ var TablePagination = ({
82256
82303
  page: 0,
82257
82304
  items: 0
82258
82305
  });
82259
- const { rowSelectionRef } = useInternalTableContext();
82260
82306
  React82.useEffect(() => {
82261
82307
  function onPaginationChanged(params) {
82262
- var _a;
82263
82308
  if (gridApi && params.api.paginationGetCurrentPage() !== pagination.page || pagination.items !== params.api.paginationGetRowCount()) {
82264
82309
  setPagination({
82265
82310
  page: params.api.paginationGetCurrentPage(),
82266
82311
  items: params.api.paginationGetRowCount()
82267
82312
  });
82268
- if (params.api.getModel().getType() === "serverSide") {
82269
- ((_a = rowSelectionRef == null ? void 0 : rowSelectionRef.current) == null ? void 0 : _a.affectedRows) && (rowSelectionRef.current.affectedRows = {});
82270
- gridApi == null ? void 0 : gridApi.deselectAll();
82271
- }
82272
82313
  }
82273
82314
  }
82274
82315
  gridApi == null ? void 0 : gridApi.addEventListener("paginationChanged", onPaginationChanged);
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -588,13 +588,13 @@ interface TableApi {
588
588
  * The row node ID is the one you provide from the callback `getRowId(data)`,
589
589
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
590
590
  */
591
- selectRows: (rowIds: (string | number)[]) => void;
591
+ selectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
592
592
  /**
593
593
  * Deselects row nodes by their respective row node IDs.
594
594
  * The row node ID is the one you provide from the callback `getRowId(data)`,
595
595
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
596
596
  */
597
- deselectRows: (rowIds: (string | number)[]) => void;
597
+ deselectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
598
598
  /**
599
599
  * Set a function determining if selection is enabled for each row as it's loaded into the table.
600
600
  * Note: Changing this will not affect existing rows that have already been loaded. Additionally,
@@ -1,5 +1,5 @@
1
1
  import * as _ag_grid_community_core from '@ag-grid-community/core';
2
- import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
2
+ import { ICellRendererParams, NumberFilterModel as NumberFilterModel$1, ColDef, IRowNode, ICellEditorParams, RowDataTransaction, RowNodeTransaction, ServerSideTransaction, GridApi, ICellEditor, RefreshCellsParams, RowNode as RowNode$1, Column, SelectionEventSourceType, ColumnPinnedType, RowHeightParams, CheckboxSelectionCallbackParams, ExcelDataType, RowGroupOpenedEvent, Module, RowSelectedEvent, ColumnEverythingChangedEvent, GetRowIdParams, ColumnApi, IFilter, IScalarFilterParams, ISimpleFilterParams } from '@ag-grid-community/core';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { AgGridReactProps, AgReactUiProps } from '@ag-grid-community/react';
@@ -588,13 +588,13 @@ interface TableApi {
588
588
  * The row node ID is the one you provide from the callback `getRowId(data)`,
589
589
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
590
590
  */
591
- selectRows: (rowIds: (string | number)[]) => void;
591
+ selectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
592
592
  /**
593
593
  * Deselects row nodes by their respective row node IDs.
594
594
  * The row node ID is the one you provide from the callback `getRowId(data)`,
595
595
  * otherwise the ID is a number auto-generated by the grid when the row data is set.
596
596
  */
597
- deselectRows: (rowIds: (string | number)[]) => void;
597
+ deselectRows: (rowIds: (string | number)[], source?: SelectionEventSourceType) => void;
598
598
  /**
599
599
  * Set a function determining if selection is enabled for each row as it's loaded into the table.
600
600
  * Note: Changing this will not affect existing rows that have already been loaded. Additionally,
@@ -55232,7 +55232,7 @@ function ClientSideRowCheckbox(props) {
55232
55232
  "data-qa": "rowCheckbox",
55233
55233
  onClick: noop2,
55234
55234
  onChange: () => {
55235
- props.node.setSelected(!selected);
55235
+ props.node.setSelected(!selected, void 0, "checkboxSelected");
55236
55236
  }
55237
55237
  }
55238
55238
  ));
@@ -55269,7 +55269,13 @@ function ServerSideRowCheckbox(props) {
55269
55269
  "data-qa": "rowCheckbox",
55270
55270
  onClick: noop2,
55271
55271
  onChange: () => {
55272
- props.node.isSelected() ? tableRef?.current?.deselectRows([props.node.id]) : tableRef?.current?.selectRows([props.node.id]);
55272
+ props.node.isSelected() ? tableRef?.current?.deselectRows(
55273
+ [props.node.id],
55274
+ "checkboxSelected"
55275
+ ) : tableRef?.current?.selectRows(
55276
+ [props.node.id],
55277
+ "checkboxSelected"
55278
+ );
55273
55279
  }
55274
55280
  }
55275
55281
  ));
@@ -56387,8 +56393,12 @@ var GenericHeaderRenderer = (props) => {
56387
56393
  if (!onSSDR || !isFirstColumn2 || !props.selectionSSREnabled) {
56388
56394
  return;
56389
56395
  }
56390
- function updateSelectAllCheckbox() {
56391
- const currentRows = getCurrentRows(props.api);
56396
+ function updateSelectAllCheckbox(e) {
56397
+ if (e.source === "uiSelectAll") {
56398
+ return;
56399
+ }
56400
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56401
+ const currentRows = getCurrentRows(props.api, isPagination);
56392
56402
  const isAllSelected = currentRows.length && currentRows.every(isRowSelected);
56393
56403
  const isPartialSelected = !isAllSelected && currentRows.some(isRowSelected);
56394
56404
  if (isAllSelected) {
@@ -56405,18 +56415,35 @@ var GenericHeaderRenderer = (props) => {
56405
56415
  props.api.removeEventListener(selectionChanged, updateSelectAllCheckbox);
56406
56416
  props.api.removeEventListener(paginationChanged, updateSelectAllCheckbox);
56407
56417
  };
56408
- }, [isFirstColumn2, selectAll, props.selectionSSREnabled]);
56409
- const toggleSelectAll = () => {
56418
+ }, [isFirstColumn2, props.selectionSSREnabled, props.api, onSSDR]);
56419
+ const toggleSelectAll = React82__default.default.useCallback(() => {
56410
56420
  const nextSelectedState = selectAll === "all" /* All */ ? "none" /* None */ : "all" /* All */;
56411
56421
  setSelectAll(nextSelectedState);
56412
56422
  props.onSelectAll?.(nextSelectedState);
56413
56423
  const isSelectAll = nextSelectedState == "all" /* All */;
56414
56424
  if (props.selectionSSREnabled) {
56415
- isSelectAll ? tableRef?.current?.selectAll() : tableRef?.current?.deselectAll();
56425
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56426
+ const rowsIdsToSelectOrDeselect = getCurrentRows(
56427
+ props.api,
56428
+ isPagination
56429
+ ).map((node) => node.id);
56430
+ isSelectAll ? tableRef?.current?.selectRows(
56431
+ rowsIdsToSelectOrDeselect,
56432
+ "uiSelectAll"
56433
+ ) : tableRef?.current?.deselectRows(
56434
+ rowsIdsToSelectOrDeselect,
56435
+ "uiSelectAll"
56436
+ );
56416
56437
  } else {
56417
56438
  isSelectAll ? props.api.selectAllFiltered() : props.api.deselectAllFiltered();
56418
56439
  }
56419
- };
56440
+ }, [
56441
+ setSelectAll,
56442
+ selectAll,
56443
+ props.onSelectAll,
56444
+ props.selectionSSREnabled,
56445
+ props.api
56446
+ ]);
56420
56447
  return /* @__PURE__ */ React82__default.default.createElement(
56421
56448
  coreReact.Flex,
56422
56449
  {
@@ -56452,9 +56479,7 @@ var GenericHeaderRenderer = (props) => {
56452
56479
  checked: selectAll === "all" /* All */,
56453
56480
  indeterminate: selectAll === "partial",
56454
56481
  onClick: (e) => e.stopPropagation(),
56455
- onChange: () => {
56456
- toggleSelectAll();
56457
- }
56482
+ onChange: toggleSelectAll
56458
56483
  }
56459
56484
  ),
56460
56485
  /* @__PURE__ */ React82__default.default.createElement("div", { className: "ag-header-cell-label" }, /* @__PURE__ */ React82__default.default.createElement(
@@ -56526,6 +56551,20 @@ function GenericColumnGroupHeader(props) {
56526
56551
  ));
56527
56552
  }
56528
56553
 
56554
+ // src/utils/pagination.ts
56555
+ var getPaginationPageStartEnd = ({
56556
+ activePage,
56557
+ items: totalItems,
56558
+ perPage
56559
+ }) => {
56560
+ const numPages = Math.ceil(totalItems / perPage);
56561
+ const actualActivePage = numPages === 0 ? 0 : activePage + 1;
56562
+ return {
56563
+ end: Math.min(actualActivePage * perPage, totalItems),
56564
+ start: Math.max((actualActivePage - 1) * perPage, 0)
56565
+ };
56566
+ };
56567
+
56529
56568
  // src/utils/cellHelpers.tsx
56530
56569
  function withDataTableEditor(Component4, editorType) {
56531
56570
  return React82__default.default.forwardRef(
@@ -56605,7 +56644,7 @@ function getFrameworkComponents(headerMenuConfig, onSelectAll, selectionSSREnabl
56605
56644
  DefaultFrameworkComponents["autoGroupCellRenderer"] = AutoGroupCellRenderer;
56606
56645
  return { ...DefaultFrameworkComponents, ...customFrameworkComponents };
56607
56646
  }
56608
- function getCurrentRows(gridApi) {
56647
+ function getCurrentRows(gridApi, useCurrentPageOnly) {
56609
56648
  let currentRows = [];
56610
56649
  if (gridApi?.getModel()?.getType() === "clientSide") {
56611
56650
  gridApi?.forEachNodeAfterFilterAndSort((rowNode) => {
@@ -56615,6 +56654,16 @@ function getCurrentRows(gridApi) {
56615
56654
  gridApi?.forEachNode((rowNode) => {
56616
56655
  currentRows.push(rowNode);
56617
56656
  });
56657
+ if (useCurrentPageOnly) {
56658
+ const { start, end } = getPaginationPageStartEnd({
56659
+ items: gridApi?.paginationGetRowCount() || 0,
56660
+ perPage: gridApi?.paginationGetPageSize() || 0,
56661
+ activePage: gridApi?.paginationGetCurrentPage() || 0
56662
+ });
56663
+ return currentRows.filter(
56664
+ (row2) => row2.rowIndex >= start && row2.rowIndex < end
56665
+ );
56666
+ }
56618
56667
  }
56619
56668
  return currentRows;
56620
56669
  }
@@ -58723,10 +58772,8 @@ var useRowSelectionState = () => {
58723
58772
  }
58724
58773
  selectionEventFunction();
58725
58774
  gridApi?.addEventListener("selectionChanged", selectionEventFunction);
58726
- gridApi?.addEventListener("paginationChanged", selectionEventFunction);
58727
58775
  return () => {
58728
58776
  gridApi?.removeEventListener("selectionChanged", selectionEventFunction);
58729
- gridApi?.removeEventListener("paginationChanged", selectionEventFunction);
58730
58777
  };
58731
58778
  }, [gridApi]);
58732
58779
  return selectedRows;
@@ -80705,24 +80752,24 @@ var useTableApi = ({
80705
80752
  });
80706
80753
  };
80707
80754
  const selectRows = React82__default.default.useCallback(
80708
- (rowIds) => {
80755
+ (rowIds, source) => {
80709
80756
  rowIds?.forEach((id) => {
80710
80757
  const rowNode = gridApi?.getRowNode(id.toString());
80711
80758
  if (!rowNode)
80712
80759
  return;
80713
- rowNode.setSelected(true);
80760
+ rowNode.setSelected(true, void 0, source);
80714
80761
  onSelectionChanged(rowNode);
80715
80762
  });
80716
80763
  },
80717
80764
  [gridApi]
80718
80765
  );
80719
80766
  const deselectRows = React82__default.default.useCallback(
80720
- (rowIds) => {
80767
+ (rowIds, source) => {
80721
80768
  rowIds?.forEach((id) => {
80722
80769
  const rowNode = gridApi?.getRowNode(id.toString());
80723
80770
  if (!rowNode)
80724
80771
  return;
80725
- rowNode.setSelected(false);
80772
+ rowNode.setSelected(false, void 0, source);
80726
80773
  onSelectionChanged(rowNode);
80727
80774
  });
80728
80775
  },
@@ -82065,7 +82112,6 @@ var TablePagination = ({
82065
82112
  page: 0,
82066
82113
  items: 0
82067
82114
  });
82068
- const { rowSelectionRef } = useInternalTableContext();
82069
82115
  React82__default.default.useEffect(() => {
82070
82116
  function onPaginationChanged(params) {
82071
82117
  if (gridApi && params.api.paginationGetCurrentPage() !== pagination.page || pagination.items !== params.api.paginationGetRowCount()) {
@@ -82073,10 +82119,6 @@ var TablePagination = ({
82073
82119
  page: params.api.paginationGetCurrentPage(),
82074
82120
  items: params.api.paginationGetRowCount()
82075
82121
  });
82076
- if (params.api.getModel().getType() === "serverSide") {
82077
- rowSelectionRef?.current?.affectedRows && (rowSelectionRef.current.affectedRows = {});
82078
- gridApi?.deselectAll();
82079
- }
82080
82122
  }
82081
82123
  }
82082
82124
  gridApi?.addEventListener("paginationChanged", onPaginationChanged);
@@ -55217,7 +55217,7 @@ function ClientSideRowCheckbox(props) {
55217
55217
  "data-qa": "rowCheckbox",
55218
55218
  onClick: noop2,
55219
55219
  onChange: () => {
55220
- props.node.setSelected(!selected);
55220
+ props.node.setSelected(!selected, void 0, "checkboxSelected");
55221
55221
  }
55222
55222
  }
55223
55223
  ));
@@ -55254,7 +55254,13 @@ function ServerSideRowCheckbox(props) {
55254
55254
  "data-qa": "rowCheckbox",
55255
55255
  onClick: noop2,
55256
55256
  onChange: () => {
55257
- props.node.isSelected() ? tableRef?.current?.deselectRows([props.node.id]) : tableRef?.current?.selectRows([props.node.id]);
55257
+ props.node.isSelected() ? tableRef?.current?.deselectRows(
55258
+ [props.node.id],
55259
+ "checkboxSelected"
55260
+ ) : tableRef?.current?.selectRows(
55261
+ [props.node.id],
55262
+ "checkboxSelected"
55263
+ );
55258
55264
  }
55259
55265
  }
55260
55266
  ));
@@ -56372,8 +56378,12 @@ var GenericHeaderRenderer = (props) => {
56372
56378
  if (!onSSDR || !isFirstColumn2 || !props.selectionSSREnabled) {
56373
56379
  return;
56374
56380
  }
56375
- function updateSelectAllCheckbox() {
56376
- const currentRows = getCurrentRows(props.api);
56381
+ function updateSelectAllCheckbox(e) {
56382
+ if (e.source === "uiSelectAll") {
56383
+ return;
56384
+ }
56385
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56386
+ const currentRows = getCurrentRows(props.api, isPagination);
56377
56387
  const isAllSelected = currentRows.length && currentRows.every(isRowSelected);
56378
56388
  const isPartialSelected = !isAllSelected && currentRows.some(isRowSelected);
56379
56389
  if (isAllSelected) {
@@ -56390,18 +56400,35 @@ var GenericHeaderRenderer = (props) => {
56390
56400
  props.api.removeEventListener(selectionChanged, updateSelectAllCheckbox);
56391
56401
  props.api.removeEventListener(paginationChanged, updateSelectAllCheckbox);
56392
56402
  };
56393
- }, [isFirstColumn2, selectAll, props.selectionSSREnabled]);
56394
- const toggleSelectAll = () => {
56403
+ }, [isFirstColumn2, props.selectionSSREnabled, props.api, onSSDR]);
56404
+ const toggleSelectAll = React82.useCallback(() => {
56395
56405
  const nextSelectedState = selectAll === "all" /* All */ ? "none" /* None */ : "all" /* All */;
56396
56406
  setSelectAll(nextSelectedState);
56397
56407
  props.onSelectAll?.(nextSelectedState);
56398
56408
  const isSelectAll = nextSelectedState == "all" /* All */;
56399
56409
  if (props.selectionSSREnabled) {
56400
- isSelectAll ? tableRef?.current?.selectAll() : tableRef?.current?.deselectAll();
56410
+ const isPagination = Boolean(props.api.paginationGetRowCount());
56411
+ const rowsIdsToSelectOrDeselect = getCurrentRows(
56412
+ props.api,
56413
+ isPagination
56414
+ ).map((node) => node.id);
56415
+ isSelectAll ? tableRef?.current?.selectRows(
56416
+ rowsIdsToSelectOrDeselect,
56417
+ "uiSelectAll"
56418
+ ) : tableRef?.current?.deselectRows(
56419
+ rowsIdsToSelectOrDeselect,
56420
+ "uiSelectAll"
56421
+ );
56401
56422
  } else {
56402
56423
  isSelectAll ? props.api.selectAllFiltered() : props.api.deselectAllFiltered();
56403
56424
  }
56404
- };
56425
+ }, [
56426
+ setSelectAll,
56427
+ selectAll,
56428
+ props.onSelectAll,
56429
+ props.selectionSSREnabled,
56430
+ props.api
56431
+ ]);
56405
56432
  return /* @__PURE__ */ React82.createElement(
56406
56433
  Flex,
56407
56434
  {
@@ -56437,9 +56464,7 @@ var GenericHeaderRenderer = (props) => {
56437
56464
  checked: selectAll === "all" /* All */,
56438
56465
  indeterminate: selectAll === "partial",
56439
56466
  onClick: (e) => e.stopPropagation(),
56440
- onChange: () => {
56441
- toggleSelectAll();
56442
- }
56467
+ onChange: toggleSelectAll
56443
56468
  }
56444
56469
  ),
56445
56470
  /* @__PURE__ */ React82.createElement("div", { className: "ag-header-cell-label" }, /* @__PURE__ */ React82.createElement(
@@ -56511,6 +56536,20 @@ function GenericColumnGroupHeader(props) {
56511
56536
  ));
56512
56537
  }
56513
56538
 
56539
+ // src/utils/pagination.ts
56540
+ var getPaginationPageStartEnd = ({
56541
+ activePage,
56542
+ items: totalItems,
56543
+ perPage
56544
+ }) => {
56545
+ const numPages = Math.ceil(totalItems / perPage);
56546
+ const actualActivePage = numPages === 0 ? 0 : activePage + 1;
56547
+ return {
56548
+ end: Math.min(actualActivePage * perPage, totalItems),
56549
+ start: Math.max((actualActivePage - 1) * perPage, 0)
56550
+ };
56551
+ };
56552
+
56514
56553
  // src/utils/cellHelpers.tsx
56515
56554
  function withDataTableEditor(Component4, editorType) {
56516
56555
  return React82.forwardRef(
@@ -56590,7 +56629,7 @@ function getFrameworkComponents(headerMenuConfig, onSelectAll, selectionSSREnabl
56590
56629
  DefaultFrameworkComponents["autoGroupCellRenderer"] = AutoGroupCellRenderer;
56591
56630
  return { ...DefaultFrameworkComponents, ...customFrameworkComponents };
56592
56631
  }
56593
- function getCurrentRows(gridApi) {
56632
+ function getCurrentRows(gridApi, useCurrentPageOnly) {
56594
56633
  let currentRows = [];
56595
56634
  if (gridApi?.getModel()?.getType() === "clientSide") {
56596
56635
  gridApi?.forEachNodeAfterFilterAndSort((rowNode) => {
@@ -56600,6 +56639,16 @@ function getCurrentRows(gridApi) {
56600
56639
  gridApi?.forEachNode((rowNode) => {
56601
56640
  currentRows.push(rowNode);
56602
56641
  });
56642
+ if (useCurrentPageOnly) {
56643
+ const { start, end } = getPaginationPageStartEnd({
56644
+ items: gridApi?.paginationGetRowCount() || 0,
56645
+ perPage: gridApi?.paginationGetPageSize() || 0,
56646
+ activePage: gridApi?.paginationGetCurrentPage() || 0
56647
+ });
56648
+ return currentRows.filter(
56649
+ (row2) => row2.rowIndex >= start && row2.rowIndex < end
56650
+ );
56651
+ }
56603
56652
  }
56604
56653
  return currentRows;
56605
56654
  }
@@ -58708,10 +58757,8 @@ var useRowSelectionState = () => {
58708
58757
  }
58709
58758
  selectionEventFunction();
58710
58759
  gridApi?.addEventListener("selectionChanged", selectionEventFunction);
58711
- gridApi?.addEventListener("paginationChanged", selectionEventFunction);
58712
58760
  return () => {
58713
58761
  gridApi?.removeEventListener("selectionChanged", selectionEventFunction);
58714
- gridApi?.removeEventListener("paginationChanged", selectionEventFunction);
58715
58762
  };
58716
58763
  }, [gridApi]);
58717
58764
  return selectedRows;
@@ -80690,24 +80737,24 @@ var useTableApi = ({
80690
80737
  });
80691
80738
  };
80692
80739
  const selectRows = React82.useCallback(
80693
- (rowIds) => {
80740
+ (rowIds, source) => {
80694
80741
  rowIds?.forEach((id) => {
80695
80742
  const rowNode = gridApi?.getRowNode(id.toString());
80696
80743
  if (!rowNode)
80697
80744
  return;
80698
- rowNode.setSelected(true);
80745
+ rowNode.setSelected(true, void 0, source);
80699
80746
  onSelectionChanged(rowNode);
80700
80747
  });
80701
80748
  },
80702
80749
  [gridApi]
80703
80750
  );
80704
80751
  const deselectRows = React82.useCallback(
80705
- (rowIds) => {
80752
+ (rowIds, source) => {
80706
80753
  rowIds?.forEach((id) => {
80707
80754
  const rowNode = gridApi?.getRowNode(id.toString());
80708
80755
  if (!rowNode)
80709
80756
  return;
80710
- rowNode.setSelected(false);
80757
+ rowNode.setSelected(false, void 0, source);
80711
80758
  onSelectionChanged(rowNode);
80712
80759
  });
80713
80760
  },
@@ -82050,7 +82097,6 @@ var TablePagination = ({
82050
82097
  page: 0,
82051
82098
  items: 0
82052
82099
  });
82053
- const { rowSelectionRef } = useInternalTableContext();
82054
82100
  React82.useEffect(() => {
82055
82101
  function onPaginationChanged(params) {
82056
82102
  if (gridApi && params.api.paginationGetCurrentPage() !== pagination.page || pagination.items !== params.api.paginationGetRowCount()) {
@@ -82058,10 +82104,6 @@ var TablePagination = ({
82058
82104
  page: params.api.paginationGetCurrentPage(),
82059
82105
  items: params.api.paginationGetRowCount()
82060
82106
  });
82061
- if (params.api.getModel().getType() === "serverSide") {
82062
- rowSelectionRef?.current?.affectedRows && (rowSelectionRef.current.affectedRows = {});
82063
- gridApi?.deselectAll();
82064
- }
82065
82107
  }
82066
82108
  }
82067
82109
  gridApi?.addEventListener("paginationChanged", onPaginationChanged);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "13.2.2",
3
+ "version": "13.3.0",
4
4
  "description": "Complex data grid built on top of ag-grid, with DST components and styles.",
5
5
  "main": "dist/legacy/index.js",
6
6
  "module": "dist/legacy/index.mjs",
@@ -103,7 +103,7 @@
103
103
  "@procore/core-css": "10.17.0",
104
104
  "@procore/core-icons": "12.0.0",
105
105
  "@procore/core-prettier": "10.2.0",
106
- "@procore/core-react": "11.31.0",
106
+ "@procore/core-react": "11.31.1",
107
107
  "@procore/eslint-config": "10.0.0",
108
108
  "@procore/labs-financials-utils": "3.0.1",
109
109
  "@procore/labs-procore-environment": "3.2.0",