@economic/taco 3.0.2-row-active-search.0 → 3.0.2-row-active-search.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/taco.cjs CHANGED
@@ -43906,6 +43906,23 @@ const useIsHoverStatePaused = () => {
43906
43906
  }, [shouldPauseHoverState]);
43907
43907
  return [shouldPauseHoverState, setShouldPauseHoverState];
43908
43908
  };
43909
+ function focusActiveRow(tableRef) {
43910
+ var _a;
43911
+ const activeRow = ((_a = (tableRef == null ? void 0 : tableRef.current) ?? document) == null ? void 0 : _a.querySelector('tbody tr[data-row-active="true"]')) ?? null;
43912
+ if (activeRow) {
43913
+ if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isElementInteractive(document.activeElement)) {
43914
+ activeRow.focus({ preventScroll: true });
43915
+ }
43916
+ }
43917
+ }
43918
+ function useTableRowActiveListener$1(table, tableRef) {
43919
+ const tableMeta = table.options.meta;
43920
+ React.useEffect(() => {
43921
+ if (tableMeta.rowActive.rowActiveIndex !== void 0) {
43922
+ focusActiveRow(tableRef);
43923
+ }
43924
+ }, [tableMeta.rowActive.rowActiveIndex, tableRef]);
43925
+ }
43909
43926
  function useTableRowActive$1(isEnabled = false, initialRowActiveIndex) {
43910
43927
  const [rowActiveIndex, setRowActiveIndex] = React.useState(initialRowActiveIndex);
43911
43928
  const [rowHoverIndex, setRowHoverIndex] = React.useState(void 0);
@@ -43913,7 +43930,11 @@ function useTableRowActive$1(isEnabled = false, initialRowActiveIndex) {
43913
43930
  const move = (direction, length, scrollToIndex) => {
43914
43931
  const nextIndex = rowActiveIndex === void 0 ? 0 : getNextIndex(direction, rowActiveIndex, length);
43915
43932
  scrollToIndex(nextIndex);
43916
- setTimeout(() => setRowActiveIndex(nextIndex), 50);
43933
+ if (nextIndex === rowActiveIndex) {
43934
+ setTimeout(() => focusActiveRow(), 0);
43935
+ } else {
43936
+ setTimeout(() => setRowActiveIndex(nextIndex), 50);
43937
+ }
43917
43938
  };
43918
43939
  const onKeyDown = React.useCallback(
43919
43940
  (event, length, scrollToIndex) => {
@@ -44630,7 +44651,7 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
44630
44651
  handleDrop: isEnabled ? onRowDrop : void 0
44631
44652
  };
44632
44653
  }
44633
- function useTableRowActiveListener$1(table, onRowActive) {
44654
+ function useTableRowActiveListener(table, onRowActive) {
44634
44655
  var _a;
44635
44656
  const meta = table.options.meta;
44636
44657
  const rows = table.getRowModel().flatRows;
@@ -44742,7 +44763,7 @@ function useTableManager(props, ref, meta, internalColumns) {
44742
44763
  useTableDataListener(instance, length);
44743
44764
  useTableFilterListener(instance, props.onChangeFilter);
44744
44765
  useTableFontSizeListener(instance);
44745
- useTableRowActiveListener$1(instance, props.onRowActive);
44766
+ useTableRowActiveListener(instance, props.onRowActive);
44746
44767
  useTableRowHeightListener(instance);
44747
44768
  useTableRowSelectionListener(instance, props.onRowSelect);
44748
44769
  useTableSearchListener(instance);
@@ -45927,18 +45948,6 @@ function useRowGroupVirtualisation(table) {
45927
45948
  );
45928
45949
  return isTableGrouped ? rangeExtractor : void 0;
45929
45950
  }
45930
- function useTableRowActiveListener(table, tableRef) {
45931
- const tableMeta = table.options.meta;
45932
- React.useEffect(() => {
45933
- var _a, _b;
45934
- if (tableMeta.rowActive.rowActiveIndex !== void 0) {
45935
- const activeRow = ((_a = tableRef.current) == null ? void 0 : _a.querySelector('tbody tr[data-row-active="true"]')) ?? null;
45936
- if (!isElementInsideOrTriggeredFromContainer(document.activeElement, activeRow) && !isElementInteractive(document.activeElement)) {
45937
- (_b = activeRow == null ? void 0 : activeRow.focus) == null ? void 0 : _b.call(activeRow, { preventScroll: true });
45938
- }
45939
- }
45940
- }, [tableMeta.rowActive.rowActiveIndex]);
45941
- }
45942
45951
  function Actions(props) {
45943
45952
  var _a, _b;
45944
45953
  const { actions, actionsLength, data, isActiveRow, rowId, table } = props;
@@ -46273,7 +46282,7 @@ function useTable$1(props, externalRef, renderers, meta) {
46273
46282
  const { style, stylesheet } = useTableStyle(manager.id, manager.instance);
46274
46283
  useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex, props.enableLocalKeyboardShortcuts);
46275
46284
  useTableRef(manager.instance, ref);
46276
- useTableRowActiveListener(manager.instance, ref);
46285
+ useTableRowActiveListener$1(manager.instance, ref);
46277
46286
  return {
46278
46287
  ...manager,
46279
46288
  props: {