@procore/data-table 12.2.0 → 13.1.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.
@@ -1,5 +1,5 @@
1
- import React82, { forwardRef, useContext, useRef, useState, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, useEffect, Component as Component$1, createElement } from 'react';
2
- import { startsWith, equals, omit, isNil, mergeDeepLeft, symmetricDifference, intersection, isEmpty, groupBy } from 'ramda';
1
+ import React82, { useState, forwardRef, useContext, useRef, useImperativeHandle, useLayoutEffect, useCallback, useMemo, memo, useEffect, Component as Component$1, createElement } from 'react';
2
+ import { startsWith, equals, omit, isNil, mergeDeepLeft, intersection, isEmpty, groupBy } from 'ramda';
3
3
  import { useI18nContext, Select, Input, UNSAFE_useOverlayTriggerContext, Card, Flex, Box, SegmentedController, Calendar, useDateTime, OverlayTrigger, isEventSource, DateInput, UNSAFE_isValidYearRange, DateSelect, PillSelect, TextArea, UNSAFE_useMenuImperativeControlNavigation, UNSAFE_Menu, UNSAFE_menuItemsWrapperAttribute, Spinner, FlexList, Typography, Tooltip, Button, Required, colors, Form, spacing, Switch, Panel, UNSAFE_StyledFilterTokenLabel, typographyWeights, SelectButton, StyledSelectButton, StyledSelectButtonLabel, StyledButton, StyledSelectArrow, Popover, UNSAFE_StyledSuperSelectTrigger, UNSAFE_StyledSuperSelectLabel, UNSAFE_StyledSuperSelectArrow, DateTimeProvider, useField, Label, UNSAFE_mergeRefs, ContactItem as ContactItem$1, ToggleButton, Pagination, Link, AvatarStack, Pill, Typeahead, UNSAFE_FilterToken, useI18n, I18nContext, UNSAFE_SuperSelect, Avatar, MultiSelect, H3, Checkbox, useVisibility, UNSAFE_useSuperSelectContext, DropdownFlyout, StyledDropdownFlyoutLabel, StyledDropdownFlyoutExpandIcon, EmptyState as EmptyState$1 } from '@procore/core-react';
4
4
  import classnames from 'classnames/bind';
5
5
  import { Error as Error$1, Grip, Pencil, Building, Calendar as Calendar$1, CaretsInVertical, CaretsOutVertical, CaretsOutVerticalWithLine, CaretsIn, CaretsOut, ArrowDown, ArrowUp, CaretDown, CaretRight } from '@procore/core-icons';
@@ -55075,7 +55075,7 @@ function getParentSelectionState(parent, affectedRows, parentChildrenMap) {
55075
55075
  function getAffectedRows(currentRows, selectionNode, affectedRows) {
55076
55076
  const isNodeRootLevel = isNodeRootLevelOfGrid(selectionNode.parent);
55077
55077
  const nodeId = selectionNode.id;
55078
- const isRowSelected = !!selectionNode.isSelected();
55078
+ const isRowSelected2 = !!selectionNode.isSelected();
55079
55079
  const parentChildrenMap = {};
55080
55080
  if (selectionNode.group || selectionNode.parent?.group && !isNodeRootLevel) {
55081
55081
  currentRows.forEach((row) => {
@@ -55094,7 +55094,7 @@ function getAffectedRows(currentRows, selectionNode, affectedRows) {
55094
55094
  }
55095
55095
  });
55096
55096
  }
55097
- const selectedState = isRowSelected ? rowSelectionState.selected : rowSelectionState.unselected;
55097
+ const selectedState = isRowSelected2 ? rowSelectionState.selected : rowSelectionState.unselected;
55098
55098
  affectedRows[nodeId] = {
55099
55099
  node: selectionNode,
55100
55100
  selectedState
@@ -55140,7 +55140,7 @@ function getAffectedRows(currentRows, selectionNode, affectedRows) {
55140
55140
  ).forEach((node) => {
55141
55141
  affectedRows[node.id] = {
55142
55142
  node,
55143
- selectedState: isRowSelected ? rowSelectionState.selected : rowSelectionState.unselected
55143
+ selectedState: isRowSelected2 ? rowSelectionState.selected : rowSelectionState.unselected
55144
55144
  };
55145
55145
  });
55146
55146
  }
@@ -55199,7 +55199,8 @@ function getSelectedState(node, affectedRows) {
55199
55199
  }
55200
55200
  function ServerSideRowCheckbox(props) {
55201
55201
  const { rowSelectionRef } = useInternalTableContext();
55202
- const indeterminate = rowSelectionRef.current?.affectedRows[props.node.id]?.selectedState === "indeterminate" ? true : false;
55202
+ const indeterminate = rowSelectionRef.current?.affectedRows[props.node.id]?.selectedState === "indeterminate";
55203
+ const { tableRef } = useInternalTableContext();
55203
55204
  const checked = getSelectedState(
55204
55205
  props.node,
55205
55206
  rowSelectionRef.current?.affectedRows
@@ -55213,7 +55214,7 @@ function ServerSideRowCheckbox(props) {
55213
55214
  "data-qa": "rowCheckbox",
55214
55215
  onClick: noop2,
55215
55216
  onChange: () => {
55216
- props.node.setSelected(!props.node.isSelected());
55217
+ props.node.isSelected() ? tableRef?.current?.deselectRows([props.node.id]) : tableRef?.current?.selectRows([props.node.id]);
55217
55218
  }
55218
55219
  }
55219
55220
  ));
@@ -55605,18 +55606,31 @@ var DataTableCellRenderer = ({
55605
55606
  )
55606
55607
  ));
55607
55608
  };
55609
+ function getStartingValue(eventKey, editorType, existingValue) {
55610
+ if (eventKey && editorType === "input" && eventKey !== "Enter") {
55611
+ if (eventKey === "Backspace") {
55612
+ return "";
55613
+ }
55614
+ return eventKey;
55615
+ }
55616
+ return existingValue;
55617
+ }
55608
55618
  var DataTableCellEditor = React82.forwardRef(
55609
55619
  ({
55620
+ api,
55610
55621
  colDef,
55611
55622
  Component: Component4,
55612
55623
  context,
55613
55624
  data,
55614
55625
  editorType,
55626
+ eventKey,
55615
55627
  node,
55616
55628
  parseValue,
55617
55629
  stopEditing,
55618
55630
  value
55619
55631
  }, ref) => {
55632
+ const startingValue = getStartingValue(eventKey, editorType, value);
55633
+ const [currentValue, setCurrentValue] = useState(startingValue);
55620
55634
  const { rowHeight, tableRef } = useInternalTableContext();
55621
55635
  const inlineEditorRef = React82.useRef(null);
55622
55636
  const inputRef = React82.useRef(null);
@@ -55653,10 +55667,26 @@ var DataTableCellEditor = React82.forwardRef(
55653
55667
  }
55654
55668
  };
55655
55669
  });
55670
+ function handleKeyDown(event) {
55671
+ if (node.rowIndex !== null && colDef.field && editorType === "input" && !event.shiftKey && !event.metaKey && !event.altKey && !event.ctrlKey) {
55672
+ if (event.key === "ArrowUp") {
55673
+ stopEditing(true);
55674
+ api.setFocusedCell(node.rowIndex - 1, colDef.field, node.rowPinned);
55675
+ } else if (event.key === "ArrowDown" || event.key === "Enter") {
55676
+ stopEditing(true);
55677
+ api.setFocusedCell(node.rowIndex + 1, colDef.field, node.rowPinned);
55678
+ }
55679
+ }
55680
+ }
55656
55681
  React82.useEffect(() => {
55657
55682
  if (editorType === "input") {
55658
- inputRef.current?.select();
55683
+ if (eventKey) {
55684
+ inputRef.current?.focus();
55685
+ } else {
55686
+ inputRef.current?.select();
55687
+ }
55659
55688
  inlineEditorRef.current?.show();
55689
+ inputRef.current?.addEventListener("keydown", handleKeyDown);
55660
55690
  } else if (editorType === "textarea") {
55661
55691
  textAreaRef.current?.select();
55662
55692
  inlineEditorRef.current?.show();
@@ -55665,6 +55695,9 @@ var DataTableCellEditor = React82.forwardRef(
55665
55695
  selectRef.current?.focus();
55666
55696
  inlineEditorRef.current?.show();
55667
55697
  }
55698
+ return () => {
55699
+ inputRef.current?.removeEventListener("keydown", handleKeyDown);
55700
+ };
55668
55701
  }, []);
55669
55702
  const handleRefs = (editorType2) => {
55670
55703
  const getRef = (refType) => UNSAFE_mergeRefs(refType, ref);
@@ -55695,10 +55728,13 @@ var DataTableCellEditor = React82.forwardRef(
55695
55728
  parentId: context?.parentId,
55696
55729
  rowPinned: node.rowPinned,
55697
55730
  rowHeight,
55698
- setDataValue: (field, newValue) => node.setDataValue(field, newValue),
55731
+ setDataValue: (field, newValue) => {
55732
+ node.setDataValue(field, newValue);
55733
+ setCurrentValue(newValue);
55734
+ },
55699
55735
  stopEditing,
55700
55736
  tableApi: tableRef?.current,
55701
- value,
55737
+ value: currentValue,
55702
55738
  ref: handleRefs(editorType)
55703
55739
  }
55704
55740
  )
@@ -56072,11 +56108,14 @@ var SortComponent = (props) => {
56072
56108
  }
56073
56109
  return null;
56074
56110
  };
56111
+ var isRowSelected = (rowNode) => {
56112
+ return Boolean(rowNode.selectable ? rowNode.isSelected() : true);
56113
+ };
56075
56114
  var GenericHeaderRenderer = (props) => {
56076
56115
  const colDef = props.column.getColDef();
56077
56116
  const HeaderNode = colDef.headerComponentParams?.headerNode;
56078
56117
  const I18n = useI18nContext();
56079
- const { columnApi, gridApi, onServerSideDataRequest } = useInternalTableContext();
56118
+ const { columnApi, tableRef, gridApi, onServerSideDataRequest } = useInternalTableContext();
56080
56119
  const onSSDR = Boolean(onServerSideDataRequest);
56081
56120
  const [sortOrder, setSortOrder] = React82.useState(props.column.getSort());
56082
56121
  const [isFirstColumn2, setIsFirstColumn] = React82.useState(false);
@@ -56112,7 +56151,9 @@ var GenericHeaderRenderer = (props) => {
56112
56151
  }, []);
56113
56152
  const onSortToggled = (event) => {
56114
56153
  let currentSort = null;
56115
- if (event.target.parentElement === checkbox.current?.parentElement) {
56154
+ if (Array.from(checkbox.current?.parentElement?.children || []).includes(
56155
+ event.target?.parentElement
56156
+ )) {
56116
56157
  return;
56117
56158
  }
56118
56159
  if (props.enableSorting) {
@@ -56164,6 +56205,9 @@ var GenericHeaderRenderer = (props) => {
56164
56205
  }, [props.column]);
56165
56206
  const [isExpandable, setIsExpandable] = React82.useState(false);
56166
56207
  React82.useEffect(() => {
56208
+ if (onSSDR) {
56209
+ return;
56210
+ }
56167
56211
  const hasExpandableNodes = !!findNode(
56168
56212
  (node) => node.isExpandable(),
56169
56213
  props.api
@@ -56288,14 +56332,9 @@ var GenericHeaderRenderer = (props) => {
56288
56332
  return;
56289
56333
  }
56290
56334
  function updateSelectAllCheckbox() {
56291
- const currentPageIds = getCurrentPageIds();
56292
- const selectedRowIds = (props.api.getSelectedRows() ?? []).map(
56293
- ({ id }) => id
56294
- );
56295
- const isAllSelected = currentPageIds.every(
56296
- (id) => selectedRowIds.includes(id)
56297
- );
56298
- const isPartialSelected = !isAllSelected && currentPageIds.some((id) => selectedRowIds.includes(id));
56335
+ const currentRows = getCurrentRows(gridApi);
56336
+ const isAllSelected = currentRows.length && currentRows.every(isRowSelected);
56337
+ const isPartialSelected = !isAllSelected && currentRows.some(isRowSelected);
56299
56338
  if (isAllSelected) {
56300
56339
  setSelectAll("all" /* All */);
56301
56340
  } else if (isPartialSelected) {
@@ -56307,49 +56346,19 @@ var GenericHeaderRenderer = (props) => {
56307
56346
  props.api.addEventListener(selectionChanged, updateSelectAllCheckbox);
56308
56347
  props.api.addEventListener(paginationChanged, updateSelectAllCheckbox);
56309
56348
  return () => {
56310
- props.api.removeEventListener(
56311
- "selectionChanged",
56312
- updateSelectAllCheckbox
56313
- );
56314
- props.api.removeEventListener(
56315
- "paginationChanged",
56316
- updateSelectAllCheckbox
56317
- );
56349
+ props.api.removeEventListener(selectionChanged, updateSelectAllCheckbox);
56350
+ props.api.removeEventListener(paginationChanged, updateSelectAllCheckbox);
56318
56351
  };
56319
56352
  }, [isFirstColumn2, selectAll, props.selectionSSREnabled]);
56320
- const getCurrentPageIds = () => {
56321
- const rowCount = props.api.getDisplayedRowCount();
56322
- const lastGridIndex = rowCount - 1;
56323
- const currentPage = props.api.paginationGetCurrentPage();
56324
- const pageSize = props.api.paginationGetPageSize();
56325
- const startPageIndex = currentPage * pageSize;
56326
- let endPageIndex = (currentPage + 1) * pageSize - 1;
56327
- if (endPageIndex > lastGridIndex) {
56328
- endPageIndex = lastGridIndex;
56329
- }
56330
- return [...Array(endPageIndex - startPageIndex + 1).keys()].map(
56331
- (index) => props.api.getDisplayedRowAtIndex(index + startPageIndex)?.data?.id
56332
- );
56333
- };
56334
- const handleSSRSelectAll = (param) => {
56335
- if (!props.selectionSSREnabled) {
56336
- return;
56337
- }
56338
- const selectedRowIds = (props.api.getSelectedRows() ?? []).map(
56339
- ({ id }) => id
56340
- );
56341
- const currentPageIds = getCurrentPageIds();
56342
- if (param === "all" /* All */) {
56343
- [.../* @__PURE__ */ new Set([...selectedRowIds, ...currentPageIds])]?.forEach(
56344
- (id) => {
56345
- props.api.getRowNode(id.toString())?.setSelected(true);
56346
- }
56347
- );
56348
- }
56349
- if (param === "none" /* None */) {
56350
- currentPageIds.forEach((id) => {
56351
- props.api.getRowNode(id.toString())?.setSelected(false);
56352
- });
56353
+ const toggleSelectAll = () => {
56354
+ const nextSelectedState = selectAll === "all" /* All */ ? "none" /* None */ : "all" /* All */;
56355
+ setSelectAll(nextSelectedState);
56356
+ props.onSelectAll?.(nextSelectedState);
56357
+ const isSelectAll = nextSelectedState == "all" /* All */;
56358
+ if (props.selectionSSREnabled) {
56359
+ isSelectAll ? tableRef?.current?.selectAll() : tableRef?.current?.deselectAll();
56360
+ } else {
56361
+ isSelectAll ? props.api.selectAllFiltered() : props.api.deselectAllFiltered();
56353
56362
  }
56354
56363
  };
56355
56364
  return /* @__PURE__ */ React82.createElement(
@@ -56388,15 +56397,7 @@ var GenericHeaderRenderer = (props) => {
56388
56397
  indeterminate: selectAll === "partial",
56389
56398
  onClick: (e) => e.stopPropagation(),
56390
56399
  onChange: () => {
56391
- if (selectAll === "all" /* All */) {
56392
- setSelectAll("none" /* None */);
56393
- props.onSelectAll?.("none" /* None */);
56394
- onSSDR ? handleSSRSelectAll("none" /* None */) : props.api.deselectAllFiltered();
56395
- } else {
56396
- setSelectAll("all" /* All */);
56397
- props.onSelectAll?.("all" /* All */);
56398
- onSSDR ? handleSSRSelectAll("all" /* All */) : props.api.selectAllFiltered();
56399
- }
56400
+ toggleSelectAll();
56400
56401
  }
56401
56402
  }
56402
56403
  ),
@@ -58669,18 +58670,30 @@ var ClientSideRowModelModule = {
58669
58670
  rowModel: "clientSide",
58670
58671
  beans: [ClientSideRowModel, FilterStage, SortStage, FlattenStage, SortService, FilterService, ImmutableService]
58671
58672
  };
58673
+ var getSelectedRows = ({
58674
+ gridApi,
58675
+ rowSelectionRef
58676
+ }) => {
58677
+ const serverSideRows = Object.values(
58678
+ rowSelectionRef?.current?.affectedRows || {}
58679
+ ).filter(
58680
+ (affectedRow) => affectedRow.selectedState === rowSelectionState.selected
58681
+ ).map((affectedRow) => affectedRow.node);
58682
+ return gridApi?.getModel().getType() === "serverSide" ? serverSideRows : gridApi?.getSelectedNodes() ?? [];
58683
+ };
58672
58684
  var useRowSelectionState = () => {
58673
58685
  const [selectedRows, setSelectedRows] = React82.useState([]);
58674
- const { gridApi } = useInternalTableContext();
58686
+ const { gridApi, rowSelectionRef } = useInternalTableContext();
58675
58687
  React82.useEffect(() => {
58676
58688
  function selectionEventFunction() {
58677
- const rows = gridApi?.getSelectedNodes() ?? [];
58678
- setSelectedRows(rows);
58689
+ setSelectedRows(getSelectedRows({ gridApi, rowSelectionRef }));
58679
58690
  }
58680
58691
  selectionEventFunction();
58681
58692
  gridApi?.addEventListener("selectionChanged", selectionEventFunction);
58693
+ gridApi?.addEventListener("paginationChanged", selectionEventFunction);
58682
58694
  return () => {
58683
58695
  gridApi?.removeEventListener("selectionChanged", selectionEventFunction);
58696
+ gridApi?.removeEventListener("paginationChanged", selectionEventFunction);
58684
58697
  };
58685
58698
  }, [gridApi]);
58686
58699
  return selectedRows;
@@ -75536,6 +75549,7 @@ var useTableApi = ({
75536
75549
  filterStorage,
75537
75550
  onTableConfigChange,
75538
75551
  rowHeight,
75552
+ rowSelectionRef,
75539
75553
  setRowHeight: internalSetRowHeight,
75540
75554
  searchStorage
75541
75555
  } = useInternalTableContext();
@@ -75668,11 +75682,11 @@ var useTableApi = ({
75668
75682
  columnDefinition: colDef,
75669
75683
  node: { rowPinned: false },
75670
75684
  data: {}
75671
- }) === true
75685
+ })
75672
75686
  );
75673
75687
  }
75674
75688
  if (typeof colDef.bulkEditable === "boolean") {
75675
- return colDef.bulkEditable === true;
75689
+ return colDef.bulkEditable;
75676
75690
  }
75677
75691
  if (typeof colDef.editable === "function") {
75678
75692
  return (
@@ -75684,7 +75698,7 @@ var useTableApi = ({
75684
75698
  columnDefinition: colDef,
75685
75699
  node: { rowPinned: false },
75686
75700
  data: {}
75687
- }) === true
75701
+ })
75688
75702
  );
75689
75703
  }
75690
75704
  return colDef.editable === true;
@@ -75856,13 +75870,58 @@ var useTableApi = ({
75856
75870
  [internalSetRowHeight]
75857
75871
  );
75858
75872
  const gridApiMethods = React82.useMemo(
75859
- () => buildPartialTableApi({ gridApi, columnApi, rowHeight, filterStorage }),
75873
+ () => buildPartialTableApi({
75874
+ gridApi,
75875
+ columnApi,
75876
+ rowHeight,
75877
+ filterStorage,
75878
+ rowSelectionRef
75879
+ }),
75860
75880
  [columnApi, gridApi, rowHeight, filterStorage]
75861
75881
  );
75882
+ const onSelectionChanged = (rowNode) => {
75883
+ const isGrouped = rowNode.group || rowNode.parent?.group && !isNodeRootLevelOfGrid(rowNode.parent);
75884
+ const currAffectedRows = rowSelectionRef.current.affectedRows;
75885
+ if (!isGrouped) {
75886
+ rowSelectionRef.current.affectedRows = {
75887
+ ...currAffectedRows,
75888
+ [rowNode.id]: {
75889
+ node: rowNode,
75890
+ selectedState: rowNode.isSelected() ? rowSelectionState.selected : rowSelectionState.unselected
75891
+ }
75892
+ };
75893
+ gridApi?.redrawRows({ rowNodes: [rowNode] });
75894
+ return;
75895
+ }
75896
+ const rowsToUpdate = getAffectedRows(
75897
+ getCurrentRows(gridApi),
75898
+ rowNode,
75899
+ currAffectedRows
75900
+ );
75901
+ const rowValues = Object.values(rowsToUpdate);
75902
+ rowValues.forEach((row) => {
75903
+ row.node.setSelected(
75904
+ row.selectedState === rowSelectionState.selected,
75905
+ false,
75906
+ "checkboxSelected"
75907
+ );
75908
+ });
75909
+ rowSelectionRef.current.affectedRows = {
75910
+ ...currAffectedRows,
75911
+ ...rowsToUpdate
75912
+ };
75913
+ gridApi?.redrawRows({
75914
+ rowNodes: rowValues.map((rowValue) => rowValue.node)
75915
+ });
75916
+ };
75862
75917
  const selectRows = React82.useCallback(
75863
75918
  (rowIds) => {
75864
75919
  rowIds?.forEach((id) => {
75865
- gridApi?.getRowNode(id.toString())?.setSelected(true);
75920
+ const rowNode = gridApi?.getRowNode(id.toString());
75921
+ if (!rowNode)
75922
+ return;
75923
+ rowNode.setSelected(true);
75924
+ onSelectionChanged(rowNode);
75866
75925
  });
75867
75926
  },
75868
75927
  [gridApi]
@@ -75870,7 +75929,11 @@ var useTableApi = ({
75870
75929
  const deselectRows = React82.useCallback(
75871
75930
  (rowIds) => {
75872
75931
  rowIds?.forEach((id) => {
75873
- gridApi?.getRowNode(id.toString())?.setSelected(false);
75932
+ const rowNode = gridApi?.getRowNode(id.toString());
75933
+ if (!rowNode)
75934
+ return;
75935
+ rowNode.setSelected(false);
75936
+ onSelectionChanged(rowNode);
75874
75937
  });
75875
75938
  },
75876
75939
  [gridApi]
@@ -75919,7 +75982,8 @@ function buildPartialTableApi({
75919
75982
  gridApi,
75920
75983
  rowHeight,
75921
75984
  columnApi,
75922
- filterStorage
75985
+ filterStorage,
75986
+ rowSelectionRef
75923
75987
  }) {
75924
75988
  const setRowData = (rows) => {
75925
75989
  if (gridApi?.getModel().getType() === "serverSide") {
@@ -75959,7 +76023,8 @@ function buildPartialTableApi({
75959
76023
  gridApi: detailGridApi,
75960
76024
  columnApi: detailGridColumnApi,
75961
76025
  rowHeight,
75962
- filterStorage
76026
+ filterStorage,
76027
+ rowSelectionRef
75963
76028
  }) : void 0;
75964
76029
  };
75965
76030
  const getTableConfiguration = () => {
@@ -75992,44 +76057,58 @@ function buildPartialTableApi({
75992
76057
  }
75993
76058
  return {};
75994
76059
  };
75995
- const getSelectedRows = () => {
76060
+ const getSelectedRows2 = () => {
75996
76061
  return gridApi?.getSelectedRows() || [];
75997
76062
  };
75998
- const selectAll = () => {
75999
- const model = gridApi?.getModel();
76000
- if (model?.getType() === "clientSide") {
76001
- gridApi?.selectAll();
76002
- }
76003
- gridApi?.forEachNode(function(node) {
76004
- if (node.isSelected() === false) {
76005
- node.setSelected(true, void 0, "apiSelectAll");
76063
+ const rowsNeedingUpdateAfterSelectAll = (isSelectAll) => {
76064
+ const prevRowNodes = gridApi?.getRenderedNodes() || [];
76065
+ return prevRowNodes.filter((prevRowNode) => {
76066
+ if (!prevRowNode.selectable) {
76067
+ return false;
76006
76068
  }
76069
+ return isSelectAll ? !prevRowNode.isSelected() : prevRowNode.isSelected();
76007
76070
  });
76071
+ };
76072
+ const updateAffectedRowsOnToggle = (isSelected) => {
76073
+ const prevAffectedRows = rowSelectionRef.current.affectedRows;
76074
+ const currentRows = getCurrentRows(gridApi);
76075
+ rowSelectionRef.current.affectedRows = currentRows.reduce(
76076
+ (accum, rowNode) => {
76077
+ if (!rowNode.id) {
76078
+ return accum;
76079
+ }
76080
+ return {
76081
+ ...accum,
76082
+ [rowNode.id]: {
76083
+ node: rowNode,
76084
+ selectedState: isSelected ? rowSelectionState.selected : rowSelectionState.unselected
76085
+ }
76086
+ };
76087
+ },
76088
+ prevAffectedRows
76089
+ );
76090
+ };
76091
+ const selectAll = () => {
76092
+ const nodesToUpdate = rowsNeedingUpdateAfterSelectAll(true);
76093
+ gridApi?.selectAll();
76008
76094
  if (gridApi?.getModel().getType() === "serverSide") {
76009
- gridApi?.redrawRows();
76095
+ updateAffectedRowsOnToggle(true);
76096
+ gridApi?.redrawRows({ rowNodes: nodesToUpdate });
76010
76097
  }
76011
76098
  };
76012
76099
  const deselectAll = () => {
76013
- const model = gridApi?.getModel();
76014
- if (model?.getType() === "clientSide") {
76015
- gridApi?.deselectAll();
76016
- }
76017
- gridApi?.forEachNode(function(node) {
76018
- if (node.isSelected() === true) {
76019
- node.setSelected(false, void 0, "apiSelectAll");
76020
- }
76021
- });
76100
+ const nodesToUpdate = rowsNeedingUpdateAfterSelectAll(false);
76101
+ gridApi?.deselectAll();
76022
76102
  if (gridApi?.getModel().getType() === "serverSide") {
76023
- gridApi?.redrawRows();
76103
+ updateAffectedRowsOnToggle(false);
76104
+ gridApi?.redrawRows({ rowNodes: nodesToUpdate });
76024
76105
  }
76025
76106
  };
76026
76107
  const collapseAll = () => {
76027
76108
  gridApi?.collapseAll();
76028
76109
  };
76029
76110
  const expandAll = () => {
76030
- gridApi?.forEachNode((node) => {
76031
- node.setExpanded(true);
76032
- });
76111
+ gridApi?.expandAll();
76033
76112
  };
76034
76113
  const setRowNodeExpanded = (rowNode, expanded) => {
76035
76114
  return gridApi?.setRowNodeExpanded(rowNode, expanded);
@@ -76060,7 +76139,7 @@ function buildPartialTableApi({
76060
76139
  getFilteredAndSortedRowNodes,
76061
76140
  getRootAggregateData,
76062
76141
  getRowData,
76063
- getSelectedRows,
76142
+ getSelectedRows: getSelectedRows2,
76064
76143
  getTableConfiguration,
76065
76144
  refreshCells,
76066
76145
  setPinnedBottomRowData,
@@ -76980,42 +77059,6 @@ var Table = (props) => {
76980
77059
  },
76981
77060
  [props.onRowGroupOpened]
76982
77061
  );
76983
- const onSelectionChanged = (event) => {
76984
- if (!internalTableContext.onServerSideDataRequest || event.source === "apiSelectAll") {
76985
- return;
76986
- }
76987
- const previousSelectedIds = Object.keys(
76988
- rowSelectionRef.current.affectedRows
76989
- ).filter(
76990
- (nodeId) => rowSelectionRef.current.affectedRows[nodeId].selectedState === rowSelectionState.selected
76991
- );
76992
- const affectedRows = rowSelectionRef.current.affectedRows;
76993
- const eventSelectedIds = event.api.getSelectedNodes().map((node) => node.id);
76994
- const diff = symmetricDifference(eventSelectedIds, previousSelectedIds);
76995
- const selectionNode = event.api.getRowNode(diff[0]);
76996
- if (selectionNode === void 0) {
76997
- return;
76998
- }
76999
- const rowsToUpdate = getAffectedRows(
77000
- getCurrentRows(event.api),
77001
- selectionNode,
77002
- affectedRows
77003
- );
77004
- Object.values(rowsToUpdate).forEach((row) => {
77005
- row.node.setSelected(
77006
- row.selectedState === rowSelectionState.selected,
77007
- void 0,
77008
- event.source
77009
- );
77010
- });
77011
- rowSelectionRef.current.affectedRows = {
77012
- ...affectedRows,
77013
- ...rowsToUpdate
77014
- };
77015
- gridApi?.redrawRows({
77016
- rowNodes: Object.values(rowsToUpdate).map((val) => val.node)
77017
- });
77018
- };
77019
77062
  const getGroupRowAgg = React82.useCallback(
77020
77063
  (params) => {
77021
77064
  const agNodes = params.nodes;
@@ -77147,7 +77190,7 @@ var Table = (props) => {
77147
77190
  style: {
77148
77191
  flex: 1,
77149
77192
  width: "100%",
77150
- height: props.maxHeight && tableHeight < props.maxHeight ? void 0 : props.maxHeight
77193
+ maxHeight: props.maxHeight && tableHeight < props.maxHeight ? void 0 : props.maxHeight
77151
77194
  },
77152
77195
  className: cx21("ag-theme-alpine", {
77153
77196
  "ag-suppress-column-virtualization": suppressColumnVirtualisation
@@ -77168,6 +77211,7 @@ var Table = (props) => {
77168
77211
  cacheBlockSize: props.paginationPageSize || defaultPaginationPageSize,
77169
77212
  defaultColDef,
77170
77213
  enableGroupEdit: internalTableContext.enableGroupEditAndValidation,
77214
+ enableCellEditingOnBackspace: true,
77171
77215
  excelStyles: transformToExcelStyles(props.excelDataTypeFormats),
77172
77216
  components: frameworkComponents,
77173
77217
  fullWidthCellRenderer: FullWidthCellRenderer(
@@ -77224,7 +77268,6 @@ var Table = (props) => {
77224
77268
  onRowDragMove,
77225
77269
  onRowGroupOpened: internalRowGroupOpened,
77226
77270
  onRowSelected: internalOnRowSelected,
77227
- onSelectionChanged,
77228
77271
  onSortChanged: onSortEventChanged,
77229
77272
  onFilterChanged,
77230
77273
  onFirstDataRendered: props.onFirstDataRendered,
@@ -77277,6 +77320,7 @@ var TablePagination = ({
77277
77320
  page: 0,
77278
77321
  items: 0
77279
77322
  });
77323
+ const { rowSelectionRef } = useInternalTableContext();
77280
77324
  React82.useEffect(() => {
77281
77325
  function onPaginationChanged(params) {
77282
77326
  if (gridApi && params.api.paginationGetCurrentPage() !== pagination.page || pagination.items !== params.api.paginationGetRowCount()) {
@@ -77284,6 +77328,10 @@ var TablePagination = ({
77284
77328
  page: params.api.paginationGetCurrentPage(),
77285
77329
  items: params.api.paginationGetRowCount()
77286
77330
  });
77331
+ if (params.api.getModel().getType() === "serverSide") {
77332
+ rowSelectionRef?.current?.affectedRows && (rowSelectionRef.current.affectedRows = {});
77333
+ gridApi?.deselectAll();
77334
+ }
77287
77335
  }
77288
77336
  }
77289
77337
  gridApi?.addEventListener("paginationChanged", onPaginationChanged);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/data-table",
3
- "version": "12.2.0",
3
+ "version": "13.1.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",