@linzjs/step-ag-grid 7.11.6 → 7.11.8

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,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useMemo, useLayoutEffect, useEffect, createContext, memo, forwardRef, useRef, useContext, useState, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
3
3
  import ReactDOM, { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
4
- import { findIndex, debounce, negate, isEmpty, delay, sortBy, last, difference, castArray, remove, flatten, xorBy, partition, pick, groupBy, fromPairs, toPairs, omit } from 'lodash-es';
4
+ import { findIndex, debounce, negate, isEmpty, delay, sortBy, defer as defer$1, last, difference, castArray, remove, flatten, xorBy, partition, pick, groupBy, fromPairs, toPairs, omit } from 'lodash-es';
5
5
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
6
6
  import { AgGridReact } from 'ag-grid-react';
7
7
  import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput, LuiButton } from '@linzjs/lui';
@@ -2145,7 +2145,20 @@ var GridContextProvider = function (props) {
2145
2145
  }
2146
2146
  var rowsThatNeedSelecting = sortBy(rowNodes.filter(function (node) { return !node.isSelected(); }), function (node) { return node.data.id; });
2147
2147
  var firstNode = rowsThatNeedSelecting[0];
2148
- firstNode && gridApi.ensureNodeVisible(firstNode);
2148
+ if (firstNode) {
2149
+ gridApi.ensureNodeVisible(firstNode);
2150
+ var colDefs = gridApi.getColumnDefs();
2151
+ if (colDefs && colDefs.length) {
2152
+ var col = colDefs[0]; // We don't support ColGroupDef
2153
+ var rowIndex_1 = firstNode.rowIndex;
2154
+ if (rowIndex_1 != null && col != null) {
2155
+ var colId_1 = col.colId;
2156
+ // We need to make sure we aren't currently editing a cell otherwise tests will fail
2157
+ // as they will start to edit the cell before this stuff has a chance to run
2158
+ colId_1 != null && defer$1(function () { return isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex_1, colId_1); });
2159
+ }
2160
+ }
2161
+ }
2149
2162
  if (select) {
2150
2163
  // Select rows that shouldn't be selected
2151
2164
  rowsThatNeedSelecting.forEach(function (node) { return node.setSelected(true); });
@@ -2812,6 +2825,19 @@ var Grid = function (params) {
2812
2825
  suppressSizeToFit: true,
2813
2826
  checkboxSelection: true,
2814
2827
  headerComponent: GridHeaderSelect,
2828
+ suppressHeaderKeyboardEvent: function (e) {
2829
+ if (e.event.key === "Enter" && !e.event.repeat) {
2830
+ var selectedNodeCount = e.api.getSelectedRows().length;
2831
+ if (selectedNodeCount == 0) {
2832
+ e.api.selectAllFiltered();
2833
+ }
2834
+ else {
2835
+ e.api.deselectAll();
2836
+ }
2837
+ return true;
2838
+ }
2839
+ return false;
2840
+ },
2815
2841
  onCellClicked: clickSelectorCheckboxWhenContainingCellClicked
2816
2842
  }
2817
2843
  ], adjustColDefs, true) : adjustColDefs;