@economic/taco 1.21.5 → 1.21.7

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 (29) 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/useShouldPauseHoverState.d.ts +2 -0
  5. package/dist/components/Table2/hooks/useTable.d.ts +3 -2
  6. package/dist/esm/packages/taco/src/components/Table2/Table2.js +8 -4
  7. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +22 -16
  9. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +2 -5
  11. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +44 -15
  13. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +23 -44
  15. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/Table2/hooks/useShouldPauseHoverState.js +19 -0
  17. package/dist/esm/packages/taco/src/components/Table2/hooks/useShouldPauseHoverState.js.map +1 -0
  18. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +5 -3
  19. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +1 -2
  21. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +88 -52
  23. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +1 -1
  24. package/dist/taco.cjs.development.js +212 -146
  25. package/dist/taco.cjs.development.js.map +1 -1
  26. package/dist/taco.cjs.production.min.js +1 -1
  27. package/dist/taco.cjs.production.min.js.map +1 -1
  28. package/package.json +2 -2
  29. 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';
@@ -10497,6 +10548,44 @@ function createRowDraggableColumn(onRowDrag, texts) {
10497
10548
  size: 10
10498
10549
  };
10499
10550
  }
10551
+ const SelectCell = /*#__PURE__*/React__default.memo(({
10552
+ lastSelectedRowIndex,
10553
+ rowIndex,
10554
+ isSelected,
10555
+ table,
10556
+ tableRef,
10557
+ texts,
10558
+ toggleSelected
10559
+ }) => {
10560
+ const meta = table.options.meta;
10561
+ const handleClick = event => {
10562
+ var _tableRef$current;
10563
+ event.stopPropagation();
10564
+ if (event.shiftKey) {
10565
+ const [fromIndex, toIndex] = toggleBetween$1((lastSelectedRowIndex === null || lastSelectedRowIndex === void 0 ? void 0 : lastSelectedRowIndex.current) || 0, rowIndex);
10566
+ table.getRowModel().rows.slice(fromIndex, toIndex + 1).forEach(row => row.toggleSelected(true));
10567
+ } else {
10568
+ toggleSelected();
10569
+ }
10570
+ lastSelectedRowIndex.current = rowIndex;
10571
+ meta.setActiveRowIndex(rowIndex);
10572
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
10573
+ };
10574
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
10575
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isSelected ? texts.table2.columns.select.select : texts.table2.columns.select.deselect, /*#__PURE__*/React__default.createElement(Shortcut$1, {
10576
+ className: "ml-2",
10577
+ keys: ['Space']
10578
+ }))
10579
+ }, /*#__PURE__*/React__default.createElement(Checkbox, {
10580
+ "aria-label": isSelected ? texts.table2.columns.select.select : texts.table2.columns.select.deselect,
10581
+ className: "hover:border-blue !mt-[0.45rem]",
10582
+ checked: isSelected,
10583
+ onClick: handleClick,
10584
+ // this is necessary to remove console spam from eslint
10585
+ onChange: () => false,
10586
+ tabIndex: -1
10587
+ }));
10588
+ });
10500
10589
  function createRowSelectionColumn(enableMultipleRowSelection, lastSelectedRowIndex, onRowDrag, tableRef, texts) {
10501
10590
  let header;
10502
10591
  let cell;
@@ -10515,44 +10604,23 @@ function createRowSelectionColumn(enableMultipleRowSelection, lastSelectedRowInd
10515
10604
  indeterminate: table.getIsSomePageRowsSelected(),
10516
10605
  onChange: checked => table.toggleAllPageRowsSelected(checked),
10517
10606
  onClick: () => {
10518
- var _tableRef$current;
10519
- (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
10607
+ var _tableRef$current2;
10608
+ (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.focus();
10520
10609
  },
10521
10610
  tabIndex: -1
10522
10611
  }));
10523
10612
  cell = ({
10524
10613
  row,
10525
10614
  table
10526
- }) => {
10527
- const meta = table.options.meta;
10528
- const handleClick = event => {
10529
- var _tableRef$current2;
10530
- event.stopPropagation();
10531
- if (event.shiftKey) {
10532
- const [fromIndex, toIndex] = toggleBetween$1((lastSelectedRowIndex === null || lastSelectedRowIndex === void 0 ? void 0 : lastSelectedRowIndex.current) || 0, row.index);
10533
- table.getRowModel().rows.slice(fromIndex, toIndex + 1).forEach(row => row.toggleSelected(true));
10534
- } else {
10535
- row.toggleSelected();
10536
- }
10537
- lastSelectedRowIndex.current = row.index;
10538
- meta.setActiveRowIndex(row.index);
10539
- (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.focus();
10540
- };
10541
- return /*#__PURE__*/React__default.createElement(Tooltip, {
10542
- title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, row.getIsSelected() ? texts.table2.columns.select.select : texts.table2.columns.select.deselect, /*#__PURE__*/React__default.createElement(Shortcut$1, {
10543
- className: "ml-2",
10544
- keys: ['Space']
10545
- }))
10546
- }, /*#__PURE__*/React__default.createElement(Checkbox, {
10547
- "aria-label": row.getIsSelected() ? texts.table2.columns.select.select : texts.table2.columns.select.deselect,
10548
- className: "hover:border-blue !mt-[0.45rem]",
10549
- checked: row.getIsSelected(),
10550
- onClick: handleClick,
10551
- // this is necessary to remove console spam from eslint
10552
- onChange: () => false,
10553
- tabIndex: -1
10554
- }));
10555
- };
10615
+ }) => /*#__PURE__*/React__default.createElement(SelectCell, {
10616
+ lastSelectedRowIndex: lastSelectedRowIndex,
10617
+ rowIndex: row.index,
10618
+ isSelected: row.getIsSelected(),
10619
+ table: table,
10620
+ tableRef: tableRef,
10621
+ texts: texts,
10622
+ toggleSelected: row.toggleSelected
10623
+ });
10556
10624
  } else {
10557
10625
  cell = ({
10558
10626
  row,
@@ -10594,6 +10662,27 @@ function createRowSelectionColumn(enableMultipleRowSelection, lastSelectedRowInd
10594
10662
  size: 46
10595
10663
  };
10596
10664
  }
10665
+ const ExpandCell = /*#__PURE__*/React__default.memo(({
10666
+ isExpanded,
10667
+ toggleExpanded,
10668
+ texts
10669
+ }) => {
10670
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
10671
+ title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isExpanded ? texts.table2.columns.expansion.collapse : texts.table2.columns.expansion.expand, /*#__PURE__*/React__default.createElement(Shortcut$1, {
10672
+ className: "ml-2",
10673
+ keys: ['Ctrl', isExpanded ? '←' : '→']
10674
+ }))
10675
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
10676
+ title: isExpanded ? texts.table2.columns.expansion.collapse : texts.table2.columns.expansion.expand,
10677
+ appearance: "discrete",
10678
+ icon: isExpanded ? 'chevron-down' : 'chevron-right',
10679
+ onClick: event => {
10680
+ event.stopPropagation();
10681
+ toggleExpanded();
10682
+ },
10683
+ tabIndex: -1
10684
+ }));
10685
+ });
10597
10686
  function createRowExpansionColumn(texts) {
10598
10687
  return {
10599
10688
  id: COLUMN_ID_FOR_EXPANSION,
@@ -10614,21 +10703,11 @@ function createRowExpansionColumn(texts) {
10614
10703
  })),
10615
10704
  cell: ({
10616
10705
  row
10617
- }) => /*#__PURE__*/React__default.createElement(Tooltip, {
10618
- title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, row.getIsExpanded() ? texts.table2.columns.expansion.collapse : texts.table2.columns.expansion.expand, /*#__PURE__*/React__default.createElement(Shortcut$1, {
10619
- className: "ml-2",
10620
- keys: ['Ctrl', row.getIsExpanded() ? '←' : '→']
10621
- }))
10622
- }, /*#__PURE__*/React__default.createElement(IconButton, {
10623
- title: row.getIsExpanded() ? texts.table2.columns.expansion.collapse : texts.table2.columns.expansion.expand,
10624
- appearance: "discrete",
10625
- icon: row.getIsExpanded() ? 'chevron-down' : 'chevron-right',
10626
- onClick: event => {
10627
- event.stopPropagation();
10628
- row.toggleExpanded();
10629
- },
10630
- tabIndex: -1
10631
- })),
10706
+ }) => /*#__PURE__*/React__default.createElement(ExpandCell, {
10707
+ isExpanded: row.getIsExpanded(),
10708
+ toggleExpanded: row.toggleExpanded,
10709
+ texts: texts
10710
+ }),
10632
10711
  meta: {
10633
10712
  align: 'center',
10634
10713
  className: 'items-center !p-0',
@@ -10641,13 +10720,20 @@ function createRowExpansionColumn(texts) {
10641
10720
  };
10642
10721
  }
10643
10722
  const getActionPropertyValue = (property, row) => typeof property === 'function' ? property(row) : property;
10644
- function RowActionCell({
10723
+ const RowActionsCell = /*#__PURE__*/React__default.memo(({
10645
10724
  row,
10646
10725
  actions,
10647
10726
  moreActions,
10648
10727
  table,
10649
10728
  texts
10650
- }) {
10729
+ }) => {
10730
+ const {
10731
+ isActive,
10732
+ isHovered
10733
+ } = useRowContext();
10734
+ if (!isHovered && !isActive) {
10735
+ return null;
10736
+ }
10651
10737
  const isVisible = action => typeof action.visible !== 'undefined' ? typeof action.visible === 'function' ? action.visible(row.original) : action.visible : true;
10652
10738
  const visibleActions = actions.filter(isVisible);
10653
10739
  const visibleMoreActions = moreActions.filter(isVisible);
@@ -10695,7 +10781,7 @@ function RowActionCell({
10695
10781
  }, getActionPropertyValue(action.text, row.original))))),
10696
10782
  tooltip: texts.table2.columns.actions.tooltip
10697
10783
  }) : null);
10698
- }
10784
+ });
10699
10785
  function createRowActionsColumn(rowActions, texts) {
10700
10786
  const actions = rowActions.length === 4 ? rowActions : rowActions.slice(0, 3);
10701
10787
  const moreActions = rowActions.slice(rowActions.length === 4 ? 4 : 3);
@@ -10704,7 +10790,7 @@ function createRowActionsColumn(rowActions, texts) {
10704
10790
  cell: ({
10705
10791
  row,
10706
10792
  table
10707
- }) => /*#__PURE__*/React__default.createElement(RowActionCell, {
10793
+ }) => /*#__PURE__*/React__default.createElement(RowActionsCell, {
10708
10794
  row: row,
10709
10795
  actions: actions,
10710
10796
  moreActions: moreActions,
@@ -10714,7 +10800,7 @@ function createRowActionsColumn(rowActions, texts) {
10714
10800
  meta: {
10715
10801
  align: 'right',
10716
10802
  className: row => cn('items-center print:opacity-0 group-[[aria-current]]/row:sticky group-hover/row:sticky right-0 bg-transparent !px-1', {
10717
- 'group-[[aria-current]]/row:!shadow-[-6px_0px_6px_theme(colors.grey.200)]': !row.getIsSelected(),
10803
+ 'group-[[aria-current]]/row:!shadow-[-6px_0px_6px_theme(colors.grey.200)] group-hover/row:!shadow-[-6px_0px_6px_theme(colors.grey.100)]': !row.getIsSelected(),
10718
10804
  'shadow-[-6px_0px_6px_theme(colors.blue.100)]': row.getIsSelected()
10719
10805
  }),
10720
10806
  disableTruncation: true,
@@ -11046,28 +11132,6 @@ const getNextIndex = (direction, currentIndex, focussableColumnIndexes) => {
11046
11132
  return currentIndexPosition + 1 < length ? currentIndexPosition + 1 : currentIndexPosition;
11047
11133
  };
11048
11134
 
11049
- const RowContext = /*#__PURE__*/React__default.createContext({
11050
- validationErrors: null,
11051
- setValidationErrors: () => undefined,
11052
- rowMoveReason: {},
11053
- setRowMoveReason: () => undefined
11054
- });
11055
- const useRowContext = () => {
11056
- const context = React__default.useContext(RowContext);
11057
- if (context === undefined) {
11058
- throw new Error('useRowContext must be used within a RowProvider');
11059
- }
11060
- return context;
11061
- };
11062
- const RowProvider = ({
11063
- children,
11064
- ...providerProps
11065
- }) => {
11066
- return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
11067
- value: providerProps
11068
- }, children);
11069
- };
11070
-
11071
11135
  var IndicatorReason;
11072
11136
  (function (IndicatorReason) {
11073
11137
  IndicatorReason["SEARCH"] = "SEARCH";
@@ -11102,7 +11166,8 @@ const useIndicatorText = reason => {
11102
11166
  const Indicator = ({
11103
11167
  reason,
11104
11168
  columnName,
11105
- mountNode
11169
+ mountNode,
11170
+ validationErrors
11106
11171
  }) => {
11107
11172
  const container = React__default.useMemo(() => {
11108
11173
  const element = document.createElement('div');
@@ -11110,9 +11175,6 @@ const Indicator = ({
11110
11175
  return element;
11111
11176
  }, []);
11112
11177
  const indicatorText = useIndicatorText(reason);
11113
- const {
11114
- validationErrors
11115
- } = useRowContext();
11116
11178
  const hasValidationErrorsInRow = !!validationErrors;
11117
11179
  React__default.useEffect(() => {
11118
11180
  // mountNode could be null when rows are filtered
@@ -11227,8 +11289,11 @@ const Cell = function Cell(props) {
11227
11289
  focussableColumnIndexes: allFocussableColumnIndexes
11228
11290
  } = meta;
11229
11291
  const {
11230
- validationErrors,
11231
- rowMoveReason
11292
+ editMode: {
11293
+ validationErrors,
11294
+ rowMoveReason
11295
+ },
11296
+ isHovered: isHoveredRow
11232
11297
  } = useRowContext();
11233
11298
  const hasValidationErrorsInRow = !!validationErrors;
11234
11299
  const internalRef = React__default.useRef(null);
@@ -11236,7 +11301,6 @@ const Cell = function Cell(props) {
11236
11301
  const disableTruncation = (_cell$column$columnDe = cell.column.columnDef.meta) === null || _cell$column$columnDe === void 0 ? void 0 : _cell$column$columnDe.disableTruncation;
11237
11302
  const cellClassName = (_cell$column$columnDe2 = cell.column.columnDef.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.className;
11238
11303
  const isActiveRow = meta.activeRowIndex === rowIndex;
11239
- const isHoveredRow = meta.hoveredRowIndex === rowIndex;
11240
11304
  const isPinned = !!cell.column.getIsPinned();
11241
11305
  const isDragging = meta.dragging[cell.row.id];
11242
11306
  const isSelected = cell.row.getIsSelected();
@@ -11248,7 +11312,7 @@ const Cell = function Cell(props) {
11248
11312
  const isEditingThisRow = meta.editMode.isEditing && isActiveRow;
11249
11313
  const canEditThisCell = isEditingThisRow && isDataColumn;
11250
11314
  const isEditingThisCell = canEditThisCell && meta.editMode.columnIndex === index;
11251
- const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow;
11315
+ const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow && !meta.shouldPauseHoverState;
11252
11316
  const isIndicatorVisible = Object.keys(rowMoveReason).length > 0;
11253
11317
  React__default.useEffect(() => {
11254
11318
  // Adds padding to the table so that indicator doesn't get cropped
@@ -11265,8 +11329,8 @@ const Cell = function Cell(props) {
11265
11329
  'border-b': !isLastRow,
11266
11330
  'sticky z-[1]': isPinned,
11267
11331
  // use isHoveredRow rather than css group-hover/row because we want to hide hover state when keyboard navigating
11268
- 'bg-white': !isActiveRow && !isSelected && !isHoveredRow,
11269
- 'bg-grey-100': !isActiveRow && !isSelected && isHoveredRow,
11332
+ 'bg-white': !isActiveRow && !isSelected,
11333
+ 'group-hover/row:bg-grey-100': !isActiveRow && !isSelected && !meta.shouldPauseHoverState,
11270
11334
  'bg-grey-200 group-hover/row:bg-grey-200': isActiveRow && !isSelected,
11271
11335
  'bg-blue-100': isSelected,
11272
11336
  '!wcag-blue-500': isDragging,
@@ -11447,7 +11511,7 @@ const Cell = function Cell(props) {
11447
11511
  } else {
11448
11512
  moveRow(MOVE_DIR.PREV);
11449
11513
  }
11450
- meta.setHoveredRowIndex(undefined);
11514
+ meta.setShouldPauseHoverState(true);
11451
11515
  return;
11452
11516
  }
11453
11517
  if (!detailModeEditing && event.key === 'ArrowDown') {
@@ -11463,7 +11527,7 @@ const Cell = function Cell(props) {
11463
11527
  } else {
11464
11528
  moveRow(MOVE_DIR.NEXT);
11465
11529
  }
11466
- meta.setHoveredRowIndex(undefined);
11530
+ meta.setShouldPauseHoverState(true);
11467
11531
  return;
11468
11532
  }
11469
11533
  };
@@ -11510,10 +11574,13 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11510
11574
  table
11511
11575
  } = props;
11512
11576
  const {
11513
- validationErrors,
11514
- setValidationErrors,
11515
- rowMoveReason,
11516
- setRowMoveReason
11577
+ editMode: {
11578
+ validationErrors,
11579
+ setValidationErrors,
11580
+ rowMoveReason,
11581
+ setRowMoveReason
11582
+ },
11583
+ isHovered
11517
11584
  } = useRowContext();
11518
11585
  const controlRef = useMergedRef(ref);
11519
11586
  const cellId = cell.column.id;
@@ -11525,7 +11592,7 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11525
11592
  globalFilter
11526
11593
  } = table.getState();
11527
11594
  const [state, setState] = React__default.useState(value);
11528
- const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && meta.hoveredRowIndex === rowIndex;
11595
+ const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && isHovered;
11529
11596
  const hasValidationError = !isHoveringAnotherRowWhileEditing && !!cellValidationError;
11530
11597
  // On each save, the initialValue will be set to the new value of the cell
11531
11598
  const initialValue = React__default.useRef(value);
@@ -11682,7 +11749,7 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11682
11749
  break;
11683
11750
  case 'switch':
11684
11751
  controlComponent = /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
11685
- className: cn('mx-2', detailModeClassName),
11752
+ className: cn('mx-2 mt-1.5', detailModeClassName),
11686
11753
  checked: Boolean(state),
11687
11754
  onChange: setState,
11688
11755
  ref: controlRef
@@ -11706,7 +11773,8 @@ const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__defaul
11706
11773
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, indicatorReason !== null && /*#__PURE__*/React__default.createElement(Indicator, {
11707
11774
  reason: indicatorReason,
11708
11775
  columnName: String(cell.column.columnDef.header),
11709
- mountNode: indicatorMountNode
11776
+ mountNode: indicatorMountNode,
11777
+ validationErrors: validationErrors
11710
11778
  }), /*#__PURE__*/React__default.createElement("span", {
11711
11779
  className: "relative flex-grow"
11712
11780
  }, controlComponent, hasValidationError && /*#__PURE__*/React__default.createElement(ValidationError, null, String(cellValidationError))));
@@ -12106,6 +12174,21 @@ const useActiveRowStateListener = (table, rows, activeRowIndex) => {
12106
12174
  }, [table.getState().columnFilters, rows.length]);
12107
12175
  };
12108
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
+
12109
12192
  function useTable$1(children, props, ref) {
12110
12193
  var _settings$columnOrder, _ref, _settings$columnPinni, _settings$columnPinni2, _settings$columnSizin, _settings$columnVisib, _settings$rowDensity;
12111
12194
  const {
@@ -12172,7 +12255,7 @@ function useTable$1(children, props, ref) {
12172
12255
  const dataColumnEndOffset = actionsForRow.length ? 1 : 0;
12173
12256
  // custom
12174
12257
  const activeRow = useActiveRow(defaultActiveRowIndex);
12175
- const [hoveredRowIndex, setHoveredRowIndex] = React__default.useState(undefined);
12258
+ const [shouldPauseHoverState, setShouldPauseHoverState] = useShouldPauseHoverState();
12176
12259
  const editMode = useEditMode(onSave);
12177
12260
  const [columnOffsets, setColumnOffsets] = React__default.useState(getOffsetsFromSize(initialState.columnPinning, initialState.columnVisibility, initialState.columnSizing));
12178
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');
@@ -12245,17 +12328,18 @@ function useTable$1(children, props, ref) {
12245
12328
  rowDensity,
12246
12329
  setRowDensity,
12247
12330
  // dragging
12331
+ enableRowDragging: !!onRowDrag,
12248
12332
  dragging,
12249
12333
  setDragging,
12250
12334
  // computed
12251
12335
  enableColumnReordering: !disableColumnReordering,
12336
+ shouldPauseHoverState,
12337
+ setShouldPauseHoverState,
12252
12338
  // resorting
12253
12339
  shouldPauseSortingAndFiltering,
12254
12340
  setShouldPauseSortingAndFiltering,
12255
12341
  // other
12256
12342
  onRowClick,
12257
- hoveredRowIndex,
12258
- setHoveredRowIndex,
12259
12343
  // data column positions
12260
12344
  dataColumnStartOffset,
12261
12345
  dataColumnEndOffset,
@@ -12324,8 +12408,7 @@ const useVirtualiser = ({
12324
12408
  const virtualiser = reactVirtual.useVirtual({
12325
12409
  parentRef: tableRef,
12326
12410
  size: rows.length,
12327
- estimateSize,
12328
- overscan: 10
12411
+ estimateSize
12329
12412
  });
12330
12413
  const paddingTop = virtualiser.virtualItems.length > 0 ? ((_virtualiser$virtualI = virtualiser.virtualItems) === null || _virtualiser$virtualI === void 0 ? void 0 : (_virtualiser$virtualI2 = _virtualiser$virtualI[0]) === null || _virtualiser$virtualI2 === void 0 ? void 0 : _virtualiser$virtualI2.start) || 0 : 0;
12331
12414
  const paddingBottom = virtualiser.virtualItems.length > 0 ? virtualiser.totalSize - (((_virtualiser$virtualI3 = virtualiser.virtualItems) === null || _virtualiser$virtualI3 === void 0 ? void 0 : (_virtualiser$virtualI4 = _virtualiser$virtualI3[virtualiser.virtualItems.length - 1]) === null || _virtualiser$virtualI4 === void 0 ? void 0 : _virtualiser$virtualI4.end) || 0) : 0;
@@ -12867,58 +12950,37 @@ function BatchActionsMenu({
12867
12950
  }, content));
12868
12951
  }
12869
12952
 
12870
- const HOVER_THRESHOLD_MS = 50;
12871
- const Row$1 = ({
12953
+ const InternalRow = ({
12872
12954
  row,
12873
12955
  rowIndex,
12874
12956
  table,
12875
12957
  ...props
12876
12958
  }) => {
12959
+ const {
12960
+ setIsHovered
12961
+ } = useRowContext();
12877
12962
  const meta = table.options.meta;
12878
12963
  const isActiveRow = meta.activeRowIndex === rowIndex;
12879
12964
  const isDragging = meta.dragging[row.id];
12880
- const [validationErrors, setValidationErrors] = React__default.useState(null);
12881
- const [rowMoveReason, setRowMoveReason] = React__default.useState({});
12882
- // This effect aims to focus the first focussable cell when edit mode is turned on.
12883
- React__default.useEffect(() => {
12884
- var _meta$tableRef$curren;
12885
- const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
12886
- // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.
12887
- if (meta.editMode.isEditing && isActiveRow && isFocusInsideTable) {
12888
- meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);
12889
- }
12890
- // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,
12891
- // first focussable cell is not focussed.
12892
- }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);
12893
- const handleSetValidationErrors = errors => {
12894
- if (errors !== null) {
12895
- meta.setShouldDisableTableActions(true);
12896
- }
12897
- setValidationErrors(errors);
12898
- };
12899
- const hoverTimerRef = React__default.useRef();
12900
- const handleEnter = () => {
12901
- hoverTimerRef.current = setTimeout(() => meta.setHoveredRowIndex(rowIndex), HOVER_THRESHOLD_MS);
12902
- };
12903
- const handleLeave = () => {
12904
- clearTimeout(hoverTimerRef.current);
12905
- hoverTimerRef.current = undefined;
12906
- meta.setHoveredRowIndex(undefined);
12907
- };
12908
- return /*#__PURE__*/React__default.createElement(RowProvider, {
12909
- validationErrors: validationErrors,
12910
- setValidationErrors: handleSetValidationErrors,
12911
- rowMoveReason: rowMoveReason,
12912
- setRowMoveReason: setRowMoveReason
12913
- }, /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
12914
- "aria-current": isActiveRow ? 'true' : undefined,
12915
- "aria-grabbed": isDragging ? 'true' : undefined,
12916
- "data-row-index": rowIndex,
12917
- draggable: true,
12918
- onMouseEnter: handleEnter,
12919
- onMouseLeave: handleLeave,
12920
- role: "row"
12921
- })));
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)));
12922
12984
  };
12923
12985
 
12924
12986
  const Column$1 = ({
@@ -13574,7 +13636,10 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13574
13636
  meta.setActiveRowIndex(0);
13575
13637
  virtualiser.scrollToOffset(0);
13576
13638
  } else {
13577
- meta.moveToPreviousRow(rows, nextIndex => virtualiser.scrollToIndex(nextIndex - 1));
13639
+ meta.moveToPreviousRow(rows, nextIndex => {
13640
+ meta.setShouldPauseHoverState(true);
13641
+ virtualiser.scrollToIndex(nextIndex - 1);
13642
+ });
13578
13643
  }
13579
13644
  return;
13580
13645
  } else if (event.key === 'ArrowDown') {
@@ -13584,6 +13649,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13584
13649
  virtualiser.scrollToOffset(virtualiser.totalSize + 1);
13585
13650
  } else {
13586
13651
  meta.moveToNextRow(rows, nextIndex => {
13652
+ meta.setShouldPauseHoverState(true);
13587
13653
  // the virtualiser doesn't always scroll right to the bottom for the last row
13588
13654
  if (nextIndex === rows.length - 1) {
13589
13655
  var _tableRef$current;
@@ -13725,9 +13791,9 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13725
13791
  }
13726
13792
  };
13727
13793
  let handleMouseLeave;
13728
- if (meta.hoveredRowIndex !== undefined) {
13794
+ if (meta.shouldPauseHoverState) {
13729
13795
  // sometimes the row's onMouseLeave doesn't trigger, this adds some extra redundancy
13730
- handleMouseLeave = () => meta.setHoveredRowIndex(undefined);
13796
+ handleMouseLeave = () => meta.setShouldPauseHoverState(false);
13731
13797
  }
13732
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);
13733
13799
  const enableSettingsButton = table.options.enablePinning || table.options.enableHiding || meta.enableColumnReordering;
@@ -13739,7 +13805,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
13739
13805
  return summaryIds.length && summaryIds.some(v => !visibleIds.includes(v));
13740
13806
  }, [footers, columnVisibility]);
13741
13807
  return /*#__PURE__*/React__default.createElement("div", {
13742
- className: "flex h-full w-full flex-col gap-4 overflow-hidden"
13808
+ className: "-m-0.5 flex h-full w-[calc(100%_+_0.25rem)] flex-col gap-4 overflow-hidden p-0.5"
13743
13809
  }, hasToolbar ? /*#__PURE__*/React__default.createElement("div", {
13744
13810
  className: "flex flex-wrap gap-2"
13745
13811
  }, toolbar, hasInternalToolbar ? /*#__PURE__*/React__default.createElement(Group, {