@economic/taco 1.21.6 → 1.21.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.
Files changed (32) hide show
  1. package/dist/components/Table2/components/column/Indicator.d.ts +2 -1
  2. package/dist/components/Table2/components/row/Context.d.ts +17 -11
  3. package/dist/components/Table2/components/row/Row.d.ts +1 -6
  4. package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +1 -2
  5. package/dist/components/Table2/hooks/useShouldPauseHoverState.d.ts +2 -0
  6. package/dist/components/Table2/hooks/useTable.d.ts +3 -2
  7. package/dist/esm/packages/taco/src/components/Table2/Table2.js +7 -3
  8. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Table2/components/Search.js +1 -1
  10. package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +46 -20
  12. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +2 -5
  14. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +44 -15
  16. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +23 -44
  18. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +10 -30
  20. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Table2/hooks/useShouldPauseHoverState.js +19 -0
  22. package/dist/esm/packages/taco/src/components/Table2/hooks/useShouldPauseHoverState.js.map +1 -0
  23. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +7 -5
  24. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +8 -0
  26. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +1 -1
  27. package/dist/taco.cjs.development.js +165 -126
  28. package/dist/taco.cjs.development.js.map +1 -1
  29. package/dist/taco.cjs.production.min.js +1 -1
  30. package/dist/taco.cjs.production.min.js.map +1 -1
  31. package/package.json +2 -2
  32. package/types.json +7 -2
@@ -10431,6 +10431,57 @@ const useTableRowCreation = (data, tableRef) => {
10431
10431
  };
10432
10432
  };
10433
10433
 
10434
+ const RowContext = /*#__PURE__*/React__default.createContext({
10435
+ isActive: false,
10436
+ editMode: {
10437
+ validationErrors: null,
10438
+ setValidationErrors: () => {},
10439
+ rowMoveReason: {},
10440
+ setRowMoveReason: () => {}
10441
+ },
10442
+ isHovered: false,
10443
+ setIsHovered: () => {}
10444
+ });
10445
+ const RowContextProvider = ({
10446
+ isActiveRow,
10447
+ children,
10448
+ meta
10449
+ }) => {
10450
+ // we use non-css hovered state to determine whether to render actions or not, for performance
10451
+ const [isHovered, setIsHovered] = React__default.useState(false);
10452
+ // editing specific functionality
10453
+ const [validationErrors, setValidationErrors] = React__default.useState(null);
10454
+ const [rowMoveReason, setRowMoveReason] = React__default.useState({});
10455
+ // This effect aims to focus the first focussable cell when edit mode is turned on.
10456
+ React__default.useEffect(() => {
10457
+ var _meta$tableRef$curren;
10458
+ const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
10459
+ // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.
10460
+ if (isActiveRow && isFocusInsideTable) {
10461
+ meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);
10462
+ }
10463
+ // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,
10464
+ // first focussable cell is not focussed.
10465
+ }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);
10466
+ const context = React__default.useMemo(() => {
10467
+ return {
10468
+ isActive: isActiveRow,
10469
+ editMode: {
10470
+ validationErrors,
10471
+ setValidationErrors,
10472
+ rowMoveReason,
10473
+ setRowMoveReason
10474
+ },
10475
+ isHovered,
10476
+ setIsHovered
10477
+ };
10478
+ }, [isActiveRow, isHovered, rowMoveReason, validationErrors]);
10479
+ return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
10480
+ value: context
10481
+ }, children);
10482
+ };
10483
+ const useRowContext = () => React__default.useContext(RowContext);
10484
+
10434
10485
  const COLUMN_ID_FOR_DRAGGABLE = '__draggable';
10435
10486
  const COLUMN_ID_FOR_SELECTION = '__select';
10436
10487
  const COLUMN_ID_FOR_EXPANSION = '__expansion';
@@ -10676,6 +10727,13 @@ const RowActionsCell = /*#__PURE__*/React__default.memo(({
10676
10727
  table,
10677
10728
  texts
10678
10729
  }) => {
10730
+ const {
10731
+ isActive,
10732
+ isHovered
10733
+ } = useRowContext();
10734
+ if (!isHovered && !isActive) {
10735
+ return null;
10736
+ }
10679
10737
  const isVisible = action => typeof action.visible !== 'undefined' ? typeof action.visible === 'function' ? action.visible(row.original) : action.visible : true;
10680
10738
  const visibleActions = actions.filter(isVisible);
10681
10739
  const visibleMoreActions = moreActions.filter(isVisible);
@@ -11074,28 +11132,6 @@ const getNextIndex = (direction, currentIndex, focussableColumnIndexes) => {
11074
11132
  return currentIndexPosition + 1 < length ? currentIndexPosition + 1 : currentIndexPosition;
11075
11133
  };
11076
11134
 
11077
- const RowContext = /*#__PURE__*/React__default.createContext({
11078
- validationErrors: null,
11079
- setValidationErrors: () => undefined,
11080
- rowMoveReason: {},
11081
- setRowMoveReason: () => undefined
11082
- });
11083
- const useRowContext = () => {
11084
- const context = React__default.useContext(RowContext);
11085
- if (context === undefined) {
11086
- throw new Error('useRowContext must be used within a RowProvider');
11087
- }
11088
- return context;
11089
- };
11090
- const RowProvider = ({
11091
- children,
11092
- ...providerProps
11093
- }) => {
11094
- return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
11095
- value: providerProps
11096
- }, children);
11097
- };
11098
-
11099
11135
  var IndicatorReason;
11100
11136
  (function (IndicatorReason) {
11101
11137
  IndicatorReason["SEARCH"] = "SEARCH";
@@ -11130,7 +11166,8 @@ const useIndicatorText = reason => {
11130
11166
  const Indicator = ({
11131
11167
  reason,
11132
11168
  columnName,
11133
- mountNode
11169
+ mountNode,
11170
+ validationErrors
11134
11171
  }) => {
11135
11172
  const container = React__default.useMemo(() => {
11136
11173
  const element = document.createElement('div');
@@ -11138,9 +11175,6 @@ const Indicator = ({
11138
11175
  return element;
11139
11176
  }, []);
11140
11177
  const indicatorText = useIndicatorText(reason);
11141
- const {
11142
- validationErrors
11143
- } = useRowContext();
11144
11178
  const hasValidationErrorsInRow = !!validationErrors;
11145
11179
  React__default.useEffect(() => {
11146
11180
  // mountNode could be null when rows are filtered
@@ -11255,8 +11289,11 @@ const Cell = function Cell(props) {
11255
11289
  focussableColumnIndexes: allFocussableColumnIndexes
11256
11290
  } = meta;
11257
11291
  const {
11258
- validationErrors,
11259
- rowMoveReason
11292
+ editMode: {
11293
+ validationErrors,
11294
+ rowMoveReason
11295
+ },
11296
+ isHovered: isHoveredRow
11260
11297
  } = useRowContext();
11261
11298
  const hasValidationErrorsInRow = !!validationErrors;
11262
11299
  const internalRef = React__default.useRef(null);
@@ -11264,7 +11301,6 @@ const Cell = function Cell(props) {
11264
11301
  const disableTruncation = (_cell$column$columnDe = cell.column.columnDef.meta) === null || _cell$column$columnDe === void 0 ? void 0 : _cell$column$columnDe.disableTruncation;
11265
11302
  const cellClassName = (_cell$column$columnDe2 = cell.column.columnDef.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.className;
11266
11303
  const isActiveRow = meta.activeRowIndex === rowIndex;
11267
- const isHoveredRow = meta.hoveredRowIndex === rowIndex;
11268
11304
  const isPinned = !!cell.column.getIsPinned();
11269
11305
  const isDragging = meta.dragging[cell.row.id];
11270
11306
  const isSelected = cell.row.getIsSelected();
@@ -11276,7 +11312,7 @@ const Cell = function Cell(props) {
11276
11312
  const isEditingThisRow = meta.editMode.isEditing && isActiveRow;
11277
11313
  const canEditThisCell = isEditingThisRow && isDataColumn;
11278
11314
  const isEditingThisCell = canEditThisCell && meta.editMode.columnIndex === index;
11279
- const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow;
11315
+ const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow && !meta.shouldPauseHoverState;
11280
11316
  const isIndicatorVisible = Object.keys(rowMoveReason).length > 0;
11281
11317
  React__default.useEffect(() => {
11282
11318
  // Adds padding to the table so that indicator doesn't get cropped
@@ -11293,8 +11329,8 @@ const Cell = function Cell(props) {
11293
11329
  'border-b': !isLastRow,
11294
11330
  'sticky z-[1]': isPinned,
11295
11331
  // use isHoveredRow rather than css group-hover/row because we want to hide hover state when keyboard navigating
11296
- 'bg-white': !isActiveRow && !isSelected && !isHoveredRow,
11297
- 'bg-grey-100': !isActiveRow && !isSelected && isHoveredRow,
11332
+ 'bg-white': !isActiveRow && !isSelected,
11333
+ 'group-hover/row:bg-grey-100': !isActiveRow && !isSelected && !meta.shouldPauseHoverState,
11298
11334
  'bg-grey-200 group-hover/row:bg-grey-200': isActiveRow && !isSelected,
11299
11335
  'bg-blue-100': isSelected,
11300
11336
  '!wcag-blue-500': isDragging,
@@ -11475,7 +11511,7 @@ const Cell = function Cell(props) {
11475
11511
  } else {
11476
11512
  moveRow(MOVE_DIR.PREV);
11477
11513
  }
11478
- meta.setHoveredRowIndex(undefined);
11514
+ meta.setShouldPauseHoverState(true);
11479
11515
  return;
11480
11516
  }
11481
11517
  if (!detailModeEditing && event.key === 'ArrowDown') {
@@ -11491,7 +11527,7 @@ const Cell = function Cell(props) {
11491
11527
  } else {
11492
11528
  moveRow(MOVE_DIR.NEXT);
11493
11529
  }
11494
- meta.setHoveredRowIndex(undefined);
11530
+ meta.setShouldPauseHoverState(true);
11495
11531
  return;
11496
11532
  }
11497
11533
  };
@@ -11505,6 +11541,7 @@ const Cell = function Cell(props) {
11505
11541
  onSave: meta.editMode.onSave,
11506
11542
  rowIndex: rowIndex,
11507
11543
  table: table,
11544
+ tableRef: tableRef,
11508
11545
  ref: controlRef,
11509
11546
  rowValues: rows[rowIndex].original,
11510
11547
  rowsLength: rows.length
@@ -11525,7 +11562,7 @@ const Cell = function Cell(props) {
11525
11562
  }, reactTable$1.flexRender(cell.column.columnDef.cell, cell.getContext())));
11526
11563
  };
11527
11564
  const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__default.forwardRef((props, ref) => {
11528
- var _cell$column$columnDe4, _cell$column$columnDe5, _cellRef$current, _cellRef$current$pare, _rowMoveReason$cellId;
11565
+ var _cell$column$columnDe4, _cell$column$columnDe5, _cellRef$current2, _cellRef$current2$par, _rowMoveReason$cellId;
11529
11566
  const {
11530
11567
  cell,
11531
11568
  cellRef,
@@ -11535,13 +11572,17 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11535
11572
  onSave: handleSave,
11536
11573
  rowIndex,
11537
11574
  rowValues,
11538
- table
11575
+ table,
11576
+ tableRef
11539
11577
  } = props;
11540
11578
  const {
11541
- validationErrors,
11542
- setValidationErrors,
11543
- rowMoveReason,
11544
- setRowMoveReason
11579
+ editMode: {
11580
+ validationErrors,
11581
+ setValidationErrors,
11582
+ rowMoveReason,
11583
+ setRowMoveReason
11584
+ },
11585
+ isHovered
11545
11586
  } = useRowContext();
11546
11587
  const controlRef = useMergedRef(ref);
11547
11588
  const cellId = cell.column.id;
@@ -11553,7 +11594,7 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11553
11594
  globalFilter
11554
11595
  } = table.getState();
11555
11596
  const [state, setState] = React__default.useState(value);
11556
- const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && meta.hoveredRowIndex === rowIndex;
11597
+ const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && isHovered;
11557
11598
  const hasValidationError = !isHoveringAnotherRowWhileEditing && !!cellValidationError;
11558
11599
  // On each save, the initialValue will be set to the new value of the cell
11559
11600
  const initialValue = React__default.useRef(value);
@@ -11614,14 +11655,32 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11614
11655
  (_controlRef$current = controlRef.current) === null || _controlRef$current === void 0 ? void 0 : (_controlRef$current$f = _controlRef$current.focus) === null || _controlRef$current$f === void 0 ? void 0 : _controlRef$current$f.call(_controlRef$current);
11615
11656
  }
11616
11657
  }, [isEditingThisCell, controlRef.current]);
11617
- // make sure the cell becomes active if the field is focused
11658
+ const pinnedColumnsWidth = React__default.useMemo(() => {
11659
+ const pinnedColumns = table.getState().columnPinning.left;
11660
+ if (Array.isArray(pinnedColumns) && pinnedColumns.length > 0) {
11661
+ const lastPinnedColumn = pinnedColumns[pinnedColumns.length - 1];
11662
+ const lastPinnedColumnOffset = meta.columnOffsets[lastPinnedColumn];
11663
+ if (lastPinnedColumnOffset !== undefined) {
11664
+ var _table$getState$colum;
11665
+ return lastPinnedColumnOffset + ((_table$getState$colum = table.getState().columnSizing[lastPinnedColumn]) !== null && _table$getState$colum !== void 0 ? _table$getState$colum : 0);
11666
+ }
11667
+ }
11668
+ return 0;
11669
+ }, [meta.columnOffsets, table.getState().columnSizing]);
11618
11670
  const handleFocus = event => {
11619
- var _event$target;
11671
+ var _event$target, _cellRef$current;
11620
11672
  meta.editMode.setColumn(columnIndex);
11621
11673
  if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
11622
11674
  var _event$target2;
11623
11675
  (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.select();
11624
11676
  }
11677
+ // ensure the field is always visible (e.g. not hidden behind the pinned columns)
11678
+ const rect = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.getBoundingClientRect();
11679
+ const leftOffset = meta.columnOffsets[cellId];
11680
+ if (rect && leftOffset && rect.left < pinnedColumnsWidth) {
11681
+ var _tableRef$current4;
11682
+ (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : _tableRef$current4.scrollTo(leftOffset - pinnedColumnsWidth, tableRef.current.scrollTop);
11683
+ }
11625
11684
  };
11626
11685
  React__default.useEffect(() => {
11627
11686
  if (hasChanged(initialValue.current, state)) {
@@ -11677,7 +11736,7 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11677
11736
  'data-inline-editing-component': 'true'
11678
11737
  };
11679
11738
  const className = cn(getCellAlignmentClasses((_cell$column$columnDe5 = cell.column.columnDef.meta) === null || _cell$column$columnDe5 === void 0 ? void 0 : _cell$column$columnDe5.align));
11680
- const indicatorMountNode = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : (_cellRef$current$pare = _cellRef$current.parentElement) === null || _cellRef$current$pare === void 0 ? void 0 : _cellRef$current$pare.querySelector(':first-child');
11739
+ const indicatorMountNode = (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.querySelector(':first-child');
11681
11740
  let controlComponent;
11682
11741
  if (cellControl) {
11683
11742
  if (typeof cellControl === 'function') {
@@ -11734,7 +11793,8 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11734
11793
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, indicatorReason !== null && /*#__PURE__*/React__default.createElement(Indicator, {
11735
11794
  reason: indicatorReason,
11736
11795
  columnName: String(cell.column.columnDef.header),
11737
- mountNode: indicatorMountNode
11796
+ mountNode: indicatorMountNode,
11797
+ validationErrors: validationErrors
11738
11798
  }), /*#__PURE__*/React__default.createElement("span", {
11739
11799
  className: "relative flex-grow"
11740
11800
  }, controlComponent, hasValidationError && /*#__PURE__*/React__default.createElement(ValidationError, null, String(cellValidationError))));
@@ -12016,44 +12076,24 @@ const getSortingFn = dataType => {
12016
12076
  return 'auto';
12017
12077
  };
12018
12078
 
12019
- const isResizingPinnedColumn = (columnId, table) => {
12020
- var _table$getState$colum, _table$getState$colum2;
12021
- return !!columnId && ((_table$getState$colum = table.getState().columnPinning.left) === null || _table$getState$colum === void 0 ? void 0 : _table$getState$colum.includes((_table$getState$colum2 = table.getState().columnSizingInfo) === null || _table$getState$colum2 === void 0 ? void 0 : _table$getState$colum2.isResizingColumn));
12022
- };
12023
- const getOffsetsFromSize = (pinning, visibility, sizing) => {
12024
- const pinned = pinning.left.filter(c => visibility[c] !== false);
12025
- const offsets = {};
12026
- let leftOffset = 0;
12027
- for (const k of pinned) {
12028
- if (!Number.isInteger(sizing[k])) {
12029
- break;
12030
- }
12031
- offsets[k] = leftOffset;
12032
- leftOffset += sizing[k];
12033
- }
12034
- return offsets;
12035
- };
12036
12079
  // pinned columns have position sticky, and because we support more than one of them
12037
12080
  // we must set a 'left' css value. this hook listens to changes on state that will
12038
12081
  // affect the left offset (resize, visibility, pinning) and updates offsets based on width
12039
12082
  const useColumnOffsetStateListener = (table, setColumnOffsets) => {
12040
12083
  const {
12041
- columnPinning,
12042
- columnSizing,
12084
+ columnOrder,
12043
12085
  columnSizingInfo,
12044
12086
  columnVisibility
12045
12087
  } = table.getState();
12046
12088
  React__default.useEffect(() => {
12047
- if (isResizingPinnedColumn(columnSizingInfo.isResizingColumn, table)) {
12048
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12049
- }
12050
- }, [columnSizingInfo]);
12051
- React__default.useEffect(() => {
12052
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12053
- }, [columnVisibility]);
12054
- React__default.useEffect(() => {
12055
- setColumnOffsets(getOffsetsFromSize(columnPinning, columnVisibility, columnSizing));
12056
- }, [columnPinning.left]);
12089
+ const offsets = {};
12090
+ // store left offsets for each visible column
12091
+ table.getVisibleLeafColumns().reduce((offset, column) => {
12092
+ offsets[column.id] = offset;
12093
+ return offset + column.getSize();
12094
+ }, 0);
12095
+ setColumnOffsets(offsets);
12096
+ }, [columnOrder, columnSizingInfo, columnVisibility]);
12057
12097
  };
12058
12098
 
12059
12099
  const useRowSelectionListener = (table, onRowSelect) => {
@@ -12134,6 +12174,21 @@ const useActiveRowStateListener = (table, rows, activeRowIndex) => {
12134
12174
  }, [table.getState().columnFilters, rows.length]);
12135
12175
  };
12136
12176
 
12177
+ const useShouldPauseHoverState = () => {
12178
+ const [shouldPauseHoverState, setShouldPauseHoverState] = React__default.useState(false);
12179
+ // as soon as the mouse starts moving again, unpause hover state
12180
+ React__default.useEffect(() => {
12181
+ const move = () => setShouldPauseHoverState(false);
12182
+ if (shouldPauseHoverState) {
12183
+ document.addEventListener('mousemove', move);
12184
+ }
12185
+ return () => {
12186
+ document.removeEventListener('mousemove', move);
12187
+ };
12188
+ }, [shouldPauseHoverState]);
12189
+ return [shouldPauseHoverState, setShouldPauseHoverState];
12190
+ };
12191
+
12137
12192
  function useTable$1(children, props, ref) {
12138
12193
  var _settings$columnOrder, _ref, _settings$columnPinni, _settings$columnPinni2, _settings$columnSizin, _settings$columnVisib, _settings$rowDensity;
12139
12194
  const {
@@ -12200,9 +12255,9 @@ function useTable$1(children, props, ref) {
12200
12255
  const dataColumnEndOffset = actionsForRow.length ? 1 : 0;
12201
12256
  // custom
12202
12257
  const activeRow = useActiveRow(defaultActiveRowIndex);
12203
- const [hoveredRowIndex, setHoveredRowIndex] = React__default.useState(undefined);
12258
+ const [shouldPauseHoverState, setShouldPauseHoverState] = useShouldPauseHoverState();
12204
12259
  const editMode = useEditMode(onSave);
12205
- const [columnOffsets, setColumnOffsets] = React__default.useState(getOffsetsFromSize(initialState.columnPinning, initialState.columnVisibility, initialState.columnSizing));
12260
+ const [columnOffsets, setColumnOffsets] = React__default.useState({});
12206
12261
  const [rowDensity, setRowDensity] = React__default.useState((_settings$rowDensity = settings === null || settings === void 0 ? void 0 : settings.rowDensity) !== null && _settings$rowDensity !== void 0 ? _settings$rowDensity : 'normal');
12207
12262
  const [dragging, setDragging] = React__default.useState({});
12208
12263
  const [shouldPauseSortingAndFiltering, setShouldPauseSortingAndFiltering] = React__default.useState(false);
@@ -12273,17 +12328,18 @@ function useTable$1(children, props, ref) {
12273
12328
  rowDensity,
12274
12329
  setRowDensity,
12275
12330
  // dragging
12331
+ enableRowDragging: !!onRowDrag,
12276
12332
  dragging,
12277
12333
  setDragging,
12278
12334
  // computed
12279
12335
  enableColumnReordering: !disableColumnReordering,
12336
+ shouldPauseHoverState,
12337
+ setShouldPauseHoverState,
12280
12338
  // resorting
12281
12339
  shouldPauseSortingAndFiltering,
12282
12340
  setShouldPauseSortingAndFiltering,
12283
12341
  // other
12284
12342
  onRowClick,
12285
- hoveredRowIndex,
12286
- setHoveredRowIndex,
12287
12343
  // data column positions
12288
12344
  dataColumnStartOffset,
12289
12345
  dataColumnEndOffset,
@@ -12894,58 +12950,37 @@ function BatchActionsMenu({
12894
12950
  }, content));
12895
12951
  }
12896
12952
 
12897
- const HOVER_THRESHOLD_MS = 50;
12898
- const Row$1 = ({
12953
+ const InternalRow = ({
12899
12954
  row,
12900
12955
  rowIndex,
12901
12956
  table,
12902
12957
  ...props
12903
12958
  }) => {
12959
+ const {
12960
+ setIsHovered
12961
+ } = useRowContext();
12904
12962
  const meta = table.options.meta;
12905
12963
  const isActiveRow = meta.activeRowIndex === rowIndex;
12906
12964
  const isDragging = meta.dragging[row.id];
12907
- const [validationErrors, setValidationErrors] = React__default.useState(null);
12908
- const [rowMoveReason, setRowMoveReason] = React__default.useState({});
12909
- // This effect aims to focus the first focussable cell when edit mode is turned on.
12910
- React__default.useEffect(() => {
12911
- var _meta$tableRef$curren;
12912
- const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
12913
- // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.
12914
- if (meta.editMode.isEditing && isActiveRow && isFocusInsideTable) {
12915
- meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);
12916
- }
12917
- // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,
12918
- // first focussable cell is not focussed.
12919
- }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);
12920
- const handleSetValidationErrors = errors => {
12921
- if (errors !== null) {
12922
- meta.setShouldDisableTableActions(true);
12923
- }
12924
- setValidationErrors(errors);
12925
- };
12926
- const hoverTimerRef = React__default.useRef();
12927
- const handleEnter = () => {
12928
- hoverTimerRef.current = setTimeout(() => meta.setHoveredRowIndex(rowIndex), HOVER_THRESHOLD_MS);
12929
- };
12930
- const handleLeave = () => {
12931
- clearTimeout(hoverTimerRef.current);
12932
- hoverTimerRef.current = undefined;
12933
- meta.setHoveredRowIndex(undefined);
12934
- };
12935
- return /*#__PURE__*/React__default.createElement(RowProvider, {
12936
- validationErrors: validationErrors,
12937
- setValidationErrors: handleSetValidationErrors,
12938
- rowMoveReason: rowMoveReason,
12939
- setRowMoveReason: setRowMoveReason
12940
- }, /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
12941
- "aria-current": isActiveRow ? 'true' : undefined,
12942
- "aria-grabbed": isDragging ? 'true' : undefined,
12943
- "data-row-index": rowIndex,
12944
- draggable: true,
12945
- onMouseEnter: handleEnter,
12946
- onMouseLeave: handleLeave,
12947
- role: "row"
12948
- })));
12965
+ const attributes = {
12966
+ ...props,
12967
+ 'aria-current': isActiveRow ? true : undefined,
12968
+ 'aria-grabbed': isDragging ? true : undefined,
12969
+ 'data-row-index': rowIndex,
12970
+ draggable: meta.enableRowDragging ? true : undefined,
12971
+ onMouseEnter: () => setIsHovered(true),
12972
+ onMouseLeave: () => setIsHovered(false),
12973
+ role: 'row'
12974
+ };
12975
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes));
12976
+ };
12977
+ const Row$1 = props => {
12978
+ const meta = props.table.options.meta;
12979
+ const isActiveRow = meta.activeRowIndex === props.rowIndex;
12980
+ return /*#__PURE__*/React__default.createElement(RowContextProvider, {
12981
+ isActiveRow: isActiveRow,
12982
+ meta: props.table.options.meta
12983
+ }, /*#__PURE__*/React__default.createElement(InternalRow, Object.assign({}, props)));
12949
12984
  };
12950
12985
 
12951
12986
  const Column$1 = ({
@@ -13355,7 +13390,7 @@ const Search$2 = props => {
13355
13390
  (_props$onSearch3 = props.onSearch) === null || _props$onSearch3 === void 0 ? void 0 : _props$onSearch3.call(props, value);
13356
13391
  };
13357
13392
  useGlobalKeyboardShortcut(event => {
13358
- if (event.key === 'f' && (event.ctrlKey || event.metaKey)) {
13393
+ if (event.key === 'f' && (event.ctrlKey || event.metaKey) && !event.shiftKey) {
13359
13394
  if (document.activeElement !== ref.current) {
13360
13395
  var _ref$current;
13361
13396
  event.preventDefault();
@@ -13601,7 +13636,10 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13601
13636
  meta.setActiveRowIndex(0);
13602
13637
  virtualiser.scrollToOffset(0);
13603
13638
  } else {
13604
- meta.moveToPreviousRow(rows, nextIndex => virtualiser.scrollToIndex(nextIndex - 1));
13639
+ meta.moveToPreviousRow(rows, nextIndex => {
13640
+ meta.setShouldPauseHoverState(true);
13641
+ virtualiser.scrollToIndex(nextIndex - 1);
13642
+ });
13605
13643
  }
13606
13644
  return;
13607
13645
  } else if (event.key === 'ArrowDown') {
@@ -13611,6 +13649,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13611
13649
  virtualiser.scrollToOffset(virtualiser.totalSize + 1);
13612
13650
  } else {
13613
13651
  meta.moveToNextRow(rows, nextIndex => {
13652
+ meta.setShouldPauseHoverState(true);
13614
13653
  // the virtualiser doesn't always scroll right to the bottom for the last row
13615
13654
  if (nextIndex === rows.length - 1) {
13616
13655
  var _tableRef$current;
@@ -13752,9 +13791,9 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13752
13791
  }
13753
13792
  };
13754
13793
  let handleMouseLeave;
13755
- if (meta.hoveredRowIndex !== undefined) {
13794
+ if (meta.shouldPauseHoverState) {
13756
13795
  // sometimes the row's onMouseLeave doesn't trigger, this adds some extra redundancy
13757
- handleMouseLeave = () => meta.setHoveredRowIndex(undefined);
13796
+ handleMouseLeave = () => meta.setShouldPauseHoverState(false);
13758
13797
  }
13759
13798
  const className = cn('bg-white border border-grey-300 focus:yt-focus focus:border-blue-500 grid auto-rows-max overflow-auto relative rounded group', props.className);
13760
13799
  const enableSettingsButton = table.options.enablePinning || table.options.enableHiding || meta.enableColumnReordering;