@infinite-table/infinite-react 11.0.3 → 11.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.
package/index.dev.mjs CHANGED
@@ -3813,6 +3813,11 @@ function getInfiniteTableStoreContext() {
3813
3813
  }
3814
3814
 
3815
3815
  // src/components/InfiniteTable/hooks/useInfiniteTableSelector.ts
3816
+ function useInfiniteTableSingleValue(selector2) {
3817
+ const StoreContext = getInfiniteTableStoreContext();
3818
+ const store = useContext3(StoreContext);
3819
+ return useComponentStoreSingleValue(store, selector2);
3820
+ }
3816
3821
  function useInfiniteTableSelector(selector2) {
3817
3822
  const StoreContext = getInfiniteTableStoreContext();
3818
3823
  const store = useContext3(StoreContext);
@@ -4219,6 +4224,9 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
4219
4224
  ...baseClasses.map((c) => `${c}--first-row-in-horizontal-layout-page`)
4220
4225
  );
4221
4226
  }
4227
+ if (extraFlags.focused) {
4228
+ result.push(...baseClasses.map((c) => `${c}--focused`));
4229
+ }
4222
4230
  if (extraFlags.rowDisabled) {
4223
4231
  result.push(...baseClasses.map((c) => `${c}--disabled`));
4224
4232
  }
@@ -5610,60 +5618,814 @@ function reorderColumnsOnDrag(params) {
5610
5618
  }
5611
5619
  return null;
5612
5620
  }
5613
- speedScroller.scroll({
5614
- mousePosition: currentMousePosition,
5615
- get scrollLeft() {
5616
- return autoScrollLeft.value;
5617
- },
5618
- set scrollLeft(value) {
5619
- autoScrollLeft.value = value;
5620
- }
5621
- });
5622
- const breakpoints = getBreakPoints(computedVisibleColumns, {
5623
- dragColumn,
5624
- restrictToParentGroup: draggableColumnsRestrictTo === "group"
5625
- });
5626
- let currentPos = dir === -1 ? dragColumn.computedOffset + diffX : dragColumn.computedOffset + dragColumn.computedWidth + diffX;
5627
- let idx = (0, import_binary_search.default)(
5628
- breakpoints,
5629
- currentPos,
5630
- ({ offsetX }, value) => {
5631
- return offsetX < value ? -1 : offsetX > value ? 1 : 0;
5632
- }
5633
- );
5634
- if (idx < 0) {
5635
- idx = ~idx;
5621
+ speedScroller.scroll({
5622
+ mousePosition: currentMousePosition,
5623
+ get scrollLeft() {
5624
+ return autoScrollLeft.value;
5625
+ },
5626
+ set scrollLeft(value) {
5627
+ autoScrollLeft.value = value;
5628
+ }
5629
+ });
5630
+ const breakpoints = getBreakPoints(computedVisibleColumns, {
5631
+ dragColumn,
5632
+ restrictToParentGroup: draggableColumnsRestrictTo === "group"
5633
+ });
5634
+ let currentPos = dir === -1 ? dragColumn.computedOffset + diffX : dragColumn.computedOffset + dragColumn.computedWidth + diffX;
5635
+ let idx = (0, import_binary_search.default)(
5636
+ breakpoints,
5637
+ currentPos,
5638
+ ({ offsetX }, value) => {
5639
+ return offsetX < value ? -1 : offsetX > value ? 1 : 0;
5640
+ }
5641
+ );
5642
+ if (idx < 0) {
5643
+ idx = ~idx;
5644
+ }
5645
+ if (!breakpoints.length) {
5646
+ if (computedVisibleColumns.length > 1) {
5647
+ console.error("No breakpoints available, something is wrong!");
5648
+ }
5649
+ idx = 0;
5650
+ } else {
5651
+ idx = breakpoints[idx] ? breakpoints[idx].columnIndex : breakpoints[breakpoints.length - 1].columnIndex + 1;
5652
+ }
5653
+ if (idx === dragColumnIndex + 1) {
5654
+ idx = dragColumnIndex;
5655
+ }
5656
+ updateDropIndex(idx);
5657
+ const columnPinning = {};
5658
+ computedPinnedEndColumns.forEach((col) => {
5659
+ columnPinning[col.id] = "end";
5660
+ });
5661
+ for (let i = 0; i < currentPinnedStartCount; i++) {
5662
+ const colIndex = currentIndexes[i];
5663
+ const col = computedVisibleColumns[colIndex];
5664
+ columnPinning[col.id] = "start";
5665
+ }
5666
+ const columnOrder = currentIndexes.map((colIndex) => {
5667
+ return computedVisibleColumns[colIndex].id;
5668
+ });
5669
+ return {
5670
+ columnPinning,
5671
+ columnOrder
5672
+ };
5673
+ }
5674
+ };
5675
+ }
5676
+
5677
+ // src/components/InfiniteTable/components/InfiniteTableHeader/headerClassName.ts
5678
+ var InfiniteTableHeaderCellClassName = `${rootClassName}HeaderCell`;
5679
+ var InfiniteTableHeaderWrapperClassName = `${rootClassName}HeaderWrapper`;
5680
+ var getHeaderWrapperNodes = (root) => {
5681
+ return Array.from(
5682
+ root.querySelectorAll(`.${InfiniteTableHeaderWrapperClassName}`)
5683
+ );
5684
+ };
5685
+
5686
+ // src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts
5687
+ function buildColumnAndGroupTree(columns, columnGroups, columnGroupsDepthsMap, columnGroupsMaxDepth) {
5688
+ const map2 = /* @__PURE__ */ new Map();
5689
+ const temporaryMap = /* @__PURE__ */ new Map();
5690
+ const mapOfAllParentGroupsForColumns = /* @__PURE__ */ new Map();
5691
+ columns.forEach((col, index) => {
5692
+ const colId = col.id;
5693
+ const previousColumn = columns[index - 1];
5694
+ const previousColumnId = previousColumn?.id ?? "";
5695
+ const parentGroups = /* @__PURE__ */ new Set();
5696
+ const parentGroupsOfPreviousColumn = previousColumn?.computedPinned !== col.computedPinned ? /* @__PURE__ */ new Set() : mapOfAllParentGroupsForColumns.get(previousColumnId) ?? /* @__PURE__ */ new Set();
5697
+ mapOfAllParentGroupsForColumns.set(colId, parentGroups);
5698
+ const colItem = {
5699
+ type: "column",
5700
+ id: colId,
5701
+ ref: col,
5702
+ groupOffset: 0,
5703
+ computedPinned: col.computedPinned,
5704
+ computedWidth: col.computedWidth,
5705
+ depth: col.columnGroup ? (columnGroupsDepthsMap.get(col.columnGroup) ?? 0) + 1 : 0
5706
+ };
5707
+ map2.set([colId], colItem);
5708
+ let groupId = col.columnGroup;
5709
+ let colGroupItem;
5710
+ let prevGroupItem = colItem;
5711
+ while (groupId) {
5712
+ const colGroup = columnGroups[groupId];
5713
+ if (colGroup) {
5714
+ parentGroups.add(groupId);
5715
+ const groupAbsoluteId = [colId, ...parentGroups];
5716
+ colGroupItem = parentGroupsOfPreviousColumn.has(groupId) ? temporaryMap.get(groupId) : void 0;
5717
+ if (!colGroupItem) {
5718
+ colGroupItem = {
5719
+ id: groupId,
5720
+ type: "group",
5721
+ ref: colGroup,
5722
+ columnItems: [],
5723
+ children: [],
5724
+ groupOffset: 0,
5725
+ uniqueGroupId: [groupId],
5726
+ computedWidth: 0,
5727
+ computedPinned: colItem.computedPinned,
5728
+ depth: columnGroupsDepthsMap.get(groupId) ?? 0
5729
+ };
5730
+ map2.set(groupAbsoluteId, colGroupItem);
5731
+ temporaryMap.set(groupId, colGroupItem);
5732
+ }
5733
+ colGroupItem.columnItems.push(colItem);
5734
+ colGroupItem.uniqueGroupId.push(colItem.id);
5735
+ if (prevGroupItem && !parentGroupsOfPreviousColumn.has(prevGroupItem.id)) {
5736
+ colGroupItem.children.push(prevGroupItem);
5737
+ }
5738
+ prevGroupItem = colGroupItem;
5739
+ groupId = colGroup.columnGroup;
5740
+ } else {
5741
+ break;
5742
+ }
5743
+ }
5744
+ });
5745
+ const result = [];
5746
+ const pathsToCells = new DeepMap();
5747
+ let groupOffset = 0;
5748
+ map2.forEach((item) => {
5749
+ if (!item.ref.columnGroup) {
5750
+ const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce(
5751
+ (sum2, col) => sum2 + col.ref.computedWidth,
5752
+ 0
5753
+ );
5754
+ item.groupOffset = groupOffset;
5755
+ item.computedWidth = itemWidth;
5756
+ if (item.type === "group") {
5757
+ assignGroupOffsetsAndComputedWidths(item.children);
5758
+ }
5759
+ result.push(item);
5760
+ groupOffset += itemWidth;
5761
+ }
5762
+ if (item.type === "group") {
5763
+ item.columnItems.forEach((colItem) => {
5764
+ pathsToCells.set([item.depth, colItem.ref.computedVisibleIndex], item);
5765
+ });
5766
+ } else {
5767
+ for (let i = item.depth; i <= columnGroupsMaxDepth + 1; i++) {
5768
+ pathsToCells.set([i, item.ref.computedVisibleIndex], item);
5769
+ }
5770
+ }
5771
+ });
5772
+ map2.clear();
5773
+ temporaryMap.clear();
5774
+ return { tree: result, pathsToCells };
5775
+ }
5776
+ function assignGroupOffsetsAndComputedWidths(items, groupOffset = 0) {
5777
+ items.forEach((item) => {
5778
+ const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce((sum2, col) => sum2 + col.ref.computedWidth, 0);
5779
+ item.computedWidth = itemWidth;
5780
+ item.groupOffset = groupOffset;
5781
+ if (item.type === "group") {
5782
+ assignGroupOffsetsAndComputedWidths(item.children);
5783
+ }
5784
+ groupOffset += itemWidth;
5785
+ });
5786
+ }
5787
+
5788
+ // src/components/InfiniteTable/utils/getFocusableChildrenForNode.ts
5789
+ var selector = [
5790
+ "input",
5791
+ "textarea",
5792
+ "select",
5793
+ "[tabindex]",
5794
+ "a[href]",
5795
+ "button",
5796
+ "object"
5797
+ ].join(", ");
5798
+ var getFocusableChildrenForNode = (node) => {
5799
+ const children = Array.from(node.querySelectorAll(selector));
5800
+ return children.filter(
5801
+ (child) => !!child.offsetParent
5802
+ );
5803
+ };
5804
+ var getFirstFocusableChildForNode = (node) => {
5805
+ return node.querySelector(selector);
5806
+ };
5807
+
5808
+ // src/components/InfiniteTable/eventHandlers/headerKeyboardNavigation.ts
5809
+ var HEADER_GROUP_CLASS_NAME = `${rootClassName}HeaderGroup`;
5810
+ var FILTER_SELECTOR = `.${InfiniteTableColumnHeaderFilterClassName}`;
5811
+ var TABBABLE_SELECTOR = [
5812
+ "input",
5813
+ "select",
5814
+ "textarea",
5815
+ "button",
5816
+ "a[href]",
5817
+ "[tabindex]"
5818
+ ].join(", ");
5819
+ var WRAPPER_SELECTOR = `.${InfiniteTableHeaderWrapperClassName}`;
5820
+ var ROOT_SELECTOR = `.${rootClassName}`;
5821
+ var lastPositions = /* @__PURE__ */ new WeakMap();
5822
+ function getRoot(context) {
5823
+ return context.getState().domRef.current;
5824
+ }
5825
+ function getOwnHeaderWrapper(context) {
5826
+ const root = getRoot(context);
5827
+ if (!root) {
5828
+ return null;
5829
+ }
5830
+ const wrappers = Array.from(
5831
+ root.querySelectorAll(WRAPPER_SELECTOR)
5832
+ );
5833
+ return wrappers.find((wrapper) => wrapper.closest(ROOT_SELECTOR) === root) ?? null;
5834
+ }
5835
+ function isHeaderEventTarget(context, target) {
5836
+ if (!(target instanceof Element)) {
5837
+ return false;
5838
+ }
5839
+ const wrapper = target.closest(WRAPPER_SELECTOR);
5840
+ return !!wrapper && wrapper.closest(ROOT_SELECTOR) === getRoot(context);
5841
+ }
5842
+ function getHeaderGrid(context) {
5843
+ const state = context.getState();
5844
+ const { computedVisibleColumns } = context.getComputed();
5845
+ const hasGroups = !!state.computedColumnGroups && Object.keys(state.computedColumnGroups).length > 0;
5846
+ const rowCount = hasGroups ? state.columnGroupsMaxDepth + 2 : 1;
5847
+ const colCount = computedVisibleColumns.length;
5848
+ const tree2 = hasGroups ? buildColumnAndGroupTree(
5849
+ computedVisibleColumns,
5850
+ state.computedColumnGroups,
5851
+ state.columnGroupsDepthsMap,
5852
+ state.columnGroupsMaxDepth
5853
+ ) : null;
5854
+ const toItem = (treeItem) => {
5855
+ if (treeItem.type === "column") {
5856
+ const index = treeItem.ref.computedVisibleIndex;
5857
+ return {
5858
+ type: "column",
5859
+ key: treeItem.ref.id,
5860
+ columnId: treeItem.ref.id,
5861
+ firstCol: index,
5862
+ lastCol: index
5863
+ };
5864
+ }
5865
+ const indexes = treeItem.columnItems.map(
5866
+ (colItem) => colItem.ref.computedVisibleIndex
5867
+ );
5868
+ return {
5869
+ type: "group",
5870
+ key: treeItem.uniqueGroupId.join(","),
5871
+ firstCol: Math.min(...indexes),
5872
+ lastCol: Math.max(...indexes)
5873
+ };
5874
+ };
5875
+ const itemAt = ({ row, col }) => {
5876
+ if (row < 0 || row >= rowCount || col < 0 || col >= colCount) {
5877
+ return null;
5878
+ }
5879
+ if (!tree2) {
5880
+ const column = computedVisibleColumns[col];
5881
+ return column ? {
5882
+ type: "column",
5883
+ key: column.id,
5884
+ columnId: column.id,
5885
+ firstCol: col,
5886
+ lastCol: col
5887
+ } : null;
5888
+ }
5889
+ const treeItem = tree2.pathsToCells.get([row, col]);
5890
+ return treeItem ? toItem(treeItem) : null;
5891
+ };
5892
+ return { rowCount, colCount, itemAt };
5893
+ }
5894
+ function getItemElement(context, item) {
5895
+ const wrapper = getOwnHeaderWrapper(context);
5896
+ if (!wrapper) {
5897
+ return null;
5898
+ }
5899
+ const selector2 = item.type === "column" ? `.${InfiniteTableHeaderCellClassName}[data-column-id="${CSS.escape(
5900
+ item.columnId
5901
+ )}"]` : `.${HEADER_GROUP_CLASS_NAME}[data-group-id="${CSS.escape(item.key)}"]`;
5902
+ const nodes = Array.from(wrapper.querySelectorAll(selector2));
5903
+ return nodes.find(
5904
+ (node) => node.closest(ROOT_SELECTOR) === getRoot(context) && node.offsetParent !== null
5905
+ ) ?? null;
5906
+ }
5907
+ function getCurrentPosition(context, grid, element) {
5908
+ const root = getRoot(context);
5909
+ const remembered = root ? lastPositions.get(root) : void 0;
5910
+ const columnId = element.getAttribute("data-column-id");
5911
+ const groupId = element.classList.contains(HEADER_GROUP_CLASS_NAME) ? element.getAttribute("data-group-id") : null;
5912
+ const key = groupId ?? columnId;
5913
+ if (key == null) {
5914
+ return null;
5915
+ }
5916
+ if (remembered && grid.itemAt(remembered)?.key === key) {
5917
+ return remembered;
5918
+ }
5919
+ if (columnId != null && groupId == null) {
5920
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
5921
+ if (!column) {
5922
+ return null;
5923
+ }
5924
+ return { row: grid.rowCount - 1, col: column.computedVisibleIndex };
5925
+ }
5926
+ for (let row = 0; row < grid.rowCount; row++) {
5927
+ for (let col = 0; col < grid.colCount; col++) {
5928
+ if (grid.itemAt({ row, col })?.key === key) {
5929
+ return { row, col };
5930
+ }
5931
+ }
5932
+ }
5933
+ return null;
5934
+ }
5935
+ function nextFrame() {
5936
+ return new Promise((resolve) => requestAnimationFrame(() => resolve()));
5937
+ }
5938
+ async function focusHeaderPosition(context, position2, grid = getHeaderGrid(context)) {
5939
+ const item = grid.itemAt(position2);
5940
+ if (!item) {
5941
+ return false;
5942
+ }
5943
+ if (item.type === "column") {
5944
+ position2 = { row: grid.rowCount - 1, col: item.firstCol };
5945
+ }
5946
+ const root = getRoot(context);
5947
+ if (root) {
5948
+ lastPositions.set(root, position2);
5949
+ }
5950
+ const element = await revealHeaderItem(
5951
+ context,
5952
+ item,
5953
+ Math.min(Math.max(position2.col, item.firstCol), item.lastCol)
5954
+ );
5955
+ if (!element) {
5956
+ return false;
5957
+ }
5958
+ element.focus({ preventScroll: true });
5959
+ return true;
5960
+ }
5961
+ async function revealHeaderItem(context, item, colIndex) {
5962
+ const column = context.getComputed().computedVisibleColumns[colIndex];
5963
+ if (column && column.computedPinned === false) {
5964
+ context.api.scrollColumnIntoView(column.id);
5965
+ }
5966
+ const focusedBefore = document.activeElement;
5967
+ let element = getItemElement(context, item);
5968
+ for (let i = 0; i < 20 && (!element || !isInView(context, element)); i++) {
5969
+ await nextFrame();
5970
+ const active = document.activeElement;
5971
+ if (active !== focusedBefore && active && active !== document.body) {
5972
+ return null;
5973
+ }
5974
+ element = getItemElement(context, item);
5975
+ }
5976
+ return element;
5977
+ }
5978
+ function columnItem(context, colIndex) {
5979
+ const column = context.getComputed().computedVisibleColumns[colIndex];
5980
+ return column ? {
5981
+ type: "column",
5982
+ key: column.id,
5983
+ columnId: column.id,
5984
+ firstCol: colIndex,
5985
+ lastCol: colIndex
5986
+ } : null;
5987
+ }
5988
+ function columnHasFilter(context, colIndex) {
5989
+ const column = context.getComputed().computedVisibleColumns[colIndex];
5990
+ return !!context.getState().showColumnFilters && !!column?.computedFilterable;
5991
+ }
5992
+ function getTabbables(node) {
5993
+ if (!node) {
5994
+ return [];
5995
+ }
5996
+ return Array.from(node.querySelectorAll(TABBABLE_SELECTOR)).filter(
5997
+ (el) => el.tabIndex >= 0 && !el.disabled && el.offsetParent !== null
5998
+ );
5999
+ }
6000
+ async function focusColumnFilter(context, colIndex, grid = getHeaderGrid(context)) {
6001
+ const item = columnItem(context, colIndex);
6002
+ if (!item) {
6003
+ return false;
6004
+ }
6005
+ const root = getRoot(context);
6006
+ if (root) {
6007
+ lastPositions.set(root, { row: grid.rowCount - 1, col: colIndex });
6008
+ }
6009
+ const headerCell = await revealHeaderItem(context, item, colIndex);
6010
+ const [first] = getTabbables(
6011
+ headerCell?.querySelector(FILTER_SELECTOR) ?? null
6012
+ );
6013
+ if (!first) {
6014
+ return false;
6015
+ }
6016
+ first.focus({ preventScroll: true });
6017
+ return true;
6018
+ }
6019
+ function getNextTabStop(context, stop, direction) {
6020
+ const colCount = context.getComputed().computedVisibleColumns.length;
6021
+ if (direction === 1) {
6022
+ if (stop.part === "header" && columnHasFilter(context, stop.col)) {
6023
+ return { col: stop.col, part: "filter" };
6024
+ }
6025
+ return stop.col + 1 < colCount ? { col: stop.col + 1, part: "header" } : "after";
6026
+ }
6027
+ if (stop.part === "filter") {
6028
+ return { col: stop.col, part: "header" };
6029
+ }
6030
+ if (stop.col <= 0) {
6031
+ return "before";
6032
+ }
6033
+ return columnHasFilter(context, stop.col - 1) ? { col: stop.col - 1, part: "filter" } : { col: stop.col - 1, part: "header" };
6034
+ }
6035
+ function focusTabStop(context, stop) {
6036
+ if (stop === "before") {
6037
+ return focusBeforeHeader(context);
6038
+ }
6039
+ if (stop === "after") {
6040
+ context.getState().scrollerDOMRef.current?.focus({ preventScroll: true });
6041
+ return true;
6042
+ }
6043
+ const grid = getHeaderGrid(context);
6044
+ if (stop.part === "filter") {
6045
+ focusColumnFilter(context, stop.col, grid);
6046
+ } else {
6047
+ focusHeaderPosition(
6048
+ context,
6049
+ { row: grid.rowCount - 1, col: stop.col },
6050
+ grid
6051
+ );
6052
+ }
6053
+ return true;
6054
+ }
6055
+ function focusLastHeaderTabStop(context) {
6056
+ if (!getOwnHeaderWrapper(context)) {
6057
+ return false;
6058
+ }
6059
+ const colCount = context.getComputed().computedVisibleColumns.length;
6060
+ if (!colCount) {
6061
+ return false;
6062
+ }
6063
+ const col = colCount - 1;
6064
+ return focusTabStop(context, {
6065
+ col,
6066
+ part: columnHasFilter(context, col) ? "filter" : "header"
6067
+ });
6068
+ }
6069
+ function isInView(context, element) {
6070
+ const wrapper = getOwnHeaderWrapper(context);
6071
+ if (!wrapper) {
6072
+ return true;
6073
+ }
6074
+ if (getComputedStyle(element).visibility === "hidden") {
6075
+ return false;
6076
+ }
6077
+ const wrapperRect = wrapper.getBoundingClientRect();
6078
+ const rect = element.getBoundingClientRect();
6079
+ return rect.right > wrapperRect.left + 1 && rect.left < wrapperRect.right - 1;
6080
+ }
6081
+ function getEntryPosition(context, grid) {
6082
+ const root = getRoot(context);
6083
+ const remembered = root ? lastPositions.get(root) : void 0;
6084
+ if (remembered && grid.itemAt(remembered)) {
6085
+ return remembered;
6086
+ }
6087
+ return { row: grid.rowCount - 1, col: 0 };
6088
+ }
6089
+ function handleHeaderWrapperFocus(context, event) {
6090
+ if (event.target !== event.currentTarget) {
6091
+ setFocusedHeaderItem(context, getFocusedHeaderItem(event.target));
6092
+ if (event.currentTarget instanceof HTMLElement) {
6093
+ keepHeaderAligned(context, event.currentTarget, event.target);
6094
+ }
6095
+ return;
6096
+ }
6097
+ const grid = getHeaderGrid(context);
6098
+ if (!grid.colCount) {
6099
+ return;
6100
+ }
6101
+ focusHeaderPosition(context, getEntryPosition(context, grid), grid);
6102
+ }
6103
+ function handleHeaderWrapperBlur(context, event) {
6104
+ const wrapper = event.currentTarget;
6105
+ const next = event.relatedTarget;
6106
+ if (!(wrapper instanceof Node) || !(next instanceof Node) || !wrapper.contains(next)) {
6107
+ setFocusedHeaderItem(context, null);
6108
+ }
6109
+ }
6110
+ function getFocusedHeaderItem(target) {
6111
+ if (!(target instanceof HTMLElement)) {
6112
+ return null;
6113
+ }
6114
+ if (target.classList.contains(InfiniteTableHeaderCellClassName)) {
6115
+ const key = target.getAttribute("data-column-id");
6116
+ return key != null ? { type: "column", key } : null;
6117
+ }
6118
+ if (target.classList.contains(HEADER_GROUP_CLASS_NAME)) {
6119
+ const key = target.getAttribute("data-group-id");
6120
+ return key != null ? { type: "group", key } : null;
6121
+ }
6122
+ return null;
6123
+ }
6124
+ function setFocusedHeaderItem(context, item) {
6125
+ const current = context.getState().focusedHeaderItem;
6126
+ if (current?.type === item?.type && current?.key === item?.key) {
6127
+ return;
6128
+ }
6129
+ context.actions.focusedHeaderItem = item;
6130
+ }
6131
+ function keepHeaderFocusOnColumnReorder(context) {
6132
+ const item = context.getState().focusedHeaderItem;
6133
+ if (item?.type !== "column") {
6134
+ return () => {
6135
+ };
6136
+ }
6137
+ const columnId = item.key;
6138
+ return () => {
6139
+ void (async () => {
6140
+ await nextFrame();
6141
+ const active = document.activeElement;
6142
+ const wrapper = getOwnHeaderWrapper(context);
6143
+ if (active && active !== document.body && !(wrapper && wrapper.contains(active))) {
6144
+ return;
6145
+ }
6146
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
6147
+ if (!column) {
6148
+ return;
6149
+ }
6150
+ const grid = getHeaderGrid(context);
6151
+ await focusHeaderPosition(
6152
+ context,
6153
+ { row: grid.rowCount - 1, col: column.computedVisibleIndex },
6154
+ grid
6155
+ );
6156
+ })();
6157
+ };
6158
+ }
6159
+ function keepHeaderAligned(context, wrapper, target) {
6160
+ const headerCell = target instanceof Element ? target.closest(
6161
+ `.${InfiniteTableHeaderCellClassName}`
6162
+ ) : null;
6163
+ const columnId = headerCell?.getAttribute("data-column-id");
6164
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6165
+ const resetNativeScroll = () => {
6166
+ if (wrapper.scrollLeft || wrapper.scrollTop) {
6167
+ wrapper.scrollLeft = 0;
6168
+ wrapper.scrollTop = 0;
6169
+ }
6170
+ };
6171
+ resetNativeScroll();
6172
+ if (column && column.computedPinned === false) {
6173
+ context.api.scrollColumnIntoView(column.id);
6174
+ }
6175
+ requestAnimationFrame(resetNativeScroll);
6176
+ }
6177
+ function focusHeaderFromBody(context, colIndex) {
6178
+ if (!getOwnHeaderWrapper(context)) {
6179
+ return false;
6180
+ }
6181
+ const grid = getHeaderGrid(context);
6182
+ if (!grid.colCount) {
6183
+ return false;
6184
+ }
6185
+ const col = colIndex ?? getEntryPosition(context, grid).col;
6186
+ if (columnHasFilter(context, col)) {
6187
+ focusColumnFilter(context, col, grid).then((focused) => {
6188
+ if (!focused) {
6189
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6190
+ }
6191
+ });
6192
+ return true;
6193
+ }
6194
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6195
+ return true;
6196
+ }
6197
+ function focusBody(context, colIndex) {
6198
+ const state = context.getState();
6199
+ const { brain, keyboardNavigation } = state;
6200
+ if (brain.getRowCount() > 0) {
6201
+ const firstVisibleRow = Math.max(
6202
+ 0,
6203
+ brain.getItemAt(brain.getScrollPosition().scrollTop, "vertical")
6204
+ );
6205
+ if (keyboardNavigation === "cell") {
6206
+ context.actions.activeCellIndex = [firstVisibleRow, colIndex];
6207
+ } else if (keyboardNavigation === "row") {
6208
+ context.actions.activeRowIndex = firstVisibleRow;
6209
+ }
6210
+ }
6211
+ state.scrollerDOMRef.current?.focus({ preventScroll: true });
6212
+ }
6213
+ function focusBeforeHeader(context) {
6214
+ const wrapper = getOwnHeaderWrapper(context);
6215
+ if (!wrapper) {
6216
+ return false;
6217
+ }
6218
+ const nodes = getFocusableChildrenForNode(document.body);
6219
+ const index = nodes.indexOf(wrapper);
6220
+ const previous = index > 0 ? nodes[index - 1] : null;
6221
+ if (previous) {
6222
+ previous.focus();
6223
+ } else {
6224
+ document.activeElement?.blur();
6225
+ }
6226
+ return true;
6227
+ }
6228
+ function isTargetEditable(target) {
6229
+ if (!(target instanceof HTMLElement)) {
6230
+ return false;
6231
+ }
6232
+ const tagName = target.tagName;
6233
+ return tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT" || tagName === "BUTTON" || target.isContentEditable;
6234
+ }
6235
+ function handleHeaderKeyDown(context, event) {
6236
+ const target = event.target;
6237
+ if (!(target instanceof HTMLElement)) {
6238
+ return false;
6239
+ }
6240
+ const filter = target.closest(FILTER_SELECTOR);
6241
+ if (filter) {
6242
+ return handleKeyInFilter(context, filter, target, event);
6243
+ }
6244
+ if (isTargetEditable(target)) {
6245
+ return false;
6246
+ }
6247
+ const isHeaderCell = target.classList.contains(InfiniteTableHeaderCellClassName) || target.classList.contains(HEADER_GROUP_CLASS_NAME);
6248
+ if (!isHeaderCell) {
6249
+ return false;
6250
+ }
6251
+ const grid = getHeaderGrid(context);
6252
+ const position2 = getCurrentPosition(context, grid, target);
6253
+ if (!position2) {
6254
+ return false;
6255
+ }
6256
+ const item = grid.itemAt(position2);
6257
+ if (!item) {
6258
+ return false;
6259
+ }
6260
+ if (event.key === "Tab") {
6261
+ const direction = event.shiftKey ? -1 : 1;
6262
+ if (item.type === "group" && direction === 1) {
6263
+ return focusTabStop(context, { col: item.firstCol, part: "header" });
6264
+ }
6265
+ return focusTabStop(
6266
+ context,
6267
+ getNextTabStop(
6268
+ context,
6269
+ { col: item.firstCol, part: "header" },
6270
+ direction
6271
+ )
6272
+ );
6273
+ }
6274
+ const { computedVisibleColumns } = context.getComputed();
6275
+ if (event.key === "Enter") {
6276
+ if (item.type !== "column") {
6277
+ return false;
6278
+ }
6279
+ toggleSort(context, item.columnId, event);
6280
+ return true;
6281
+ }
6282
+ if (event.key === "ArrowDown" && event.altKey) {
6283
+ if (item.type !== "column") {
6284
+ return false;
6285
+ }
6286
+ const menuIcon = target.querySelector(
6287
+ `[data-name="menu-icon"]`
6288
+ );
6289
+ context.api.getColumnApi(item.columnId)?.toggleContextMenu(menuIcon ?? target);
6290
+ restoreFocusAfterColumnMenu(context, item.columnId, position2);
6291
+ return true;
6292
+ }
6293
+ if (event.altKey || event.ctrlKey || event.metaKey) {
6294
+ return false;
6295
+ }
6296
+ const lastCol = computedVisibleColumns.length - 1;
6297
+ switch (event.key) {
6298
+ case "ArrowRight": {
6299
+ if (item.lastCol < lastCol) {
6300
+ focusHeaderPosition(
6301
+ context,
6302
+ { row: position2.row, col: item.lastCol + 1 },
6303
+ grid
6304
+ );
6305
+ }
6306
+ return true;
6307
+ }
6308
+ case "ArrowLeft": {
6309
+ if (item.firstCol > 0) {
6310
+ focusHeaderPosition(
6311
+ context,
6312
+ { row: position2.row, col: item.firstCol - 1 },
6313
+ grid
6314
+ );
5636
6315
  }
5637
- if (!breakpoints.length) {
5638
- if (computedVisibleColumns.length > 1) {
5639
- console.error("No breakpoints available, something is wrong!");
5640
- }
5641
- idx = 0;
5642
- } else {
5643
- idx = breakpoints[idx] ? breakpoints[idx].columnIndex : breakpoints[breakpoints.length - 1].columnIndex + 1;
6316
+ return true;
6317
+ }
6318
+ case "Home": {
6319
+ focusHeaderPosition(context, { row: position2.row, col: 0 }, grid);
6320
+ return true;
6321
+ }
6322
+ case "End": {
6323
+ focusHeaderPosition(context, { row: position2.row, col: lastCol }, grid);
6324
+ return true;
6325
+ }
6326
+ case "ArrowUp": {
6327
+ let row = position2.row - 1;
6328
+ while (row >= 0 && grid.itemAt({ row, col: position2.col })?.key === item.key) {
6329
+ row--;
5644
6330
  }
5645
- if (idx === dragColumnIndex + 1) {
5646
- idx = dragColumnIndex;
6331
+ if (row >= 0) {
6332
+ focusHeaderPosition(context, { row, col: position2.col }, grid);
5647
6333
  }
5648
- updateDropIndex(idx);
5649
- const columnPinning = {};
5650
- computedPinnedEndColumns.forEach((col) => {
5651
- columnPinning[col.id] = "end";
5652
- });
5653
- for (let i = 0; i < currentPinnedStartCount; i++) {
5654
- const colIndex = currentIndexes[i];
5655
- const col = computedVisibleColumns[colIndex];
5656
- columnPinning[col.id] = "start";
6334
+ return true;
6335
+ }
6336
+ case "ArrowDown": {
6337
+ let row = position2.row + 1;
6338
+ while (row < grid.rowCount && grid.itemAt({ row, col: position2.col })?.key === item.key) {
6339
+ row++;
6340
+ }
6341
+ if (row < grid.rowCount) {
6342
+ focusHeaderPosition(context, { row, col: position2.col }, grid);
6343
+ } else if (columnHasFilter(context, position2.col)) {
6344
+ focusColumnFilter(context, position2.col, grid).then((focused) => {
6345
+ if (!focused) {
6346
+ focusBody(context, position2.col);
6347
+ }
6348
+ });
6349
+ } else {
6350
+ focusBody(context, position2.col);
5657
6351
  }
5658
- const columnOrder = currentIndexes.map((colIndex) => {
5659
- return computedVisibleColumns[colIndex].id;
5660
- });
5661
- return {
5662
- columnPinning,
5663
- columnOrder
5664
- };
6352
+ return true;
5665
6353
  }
5666
- };
6354
+ }
6355
+ return false;
6356
+ }
6357
+ function handleKeyInFilter(context, filter, target, event) {
6358
+ if (event.defaultPrevented) {
6359
+ return false;
6360
+ }
6361
+ if (event.key === "Tab") {
6362
+ return handleTabInFilter(context, filter, target, event.shiftKey);
6363
+ }
6364
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown" || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
6365
+ return false;
6366
+ }
6367
+ const columnId = filter.closest(`.${InfiniteTableHeaderCellClassName}`)?.getAttribute("data-column-id");
6368
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6369
+ if (!column) {
6370
+ return false;
6371
+ }
6372
+ const col = column.computedVisibleIndex;
6373
+ if (event.key === "ArrowUp") {
6374
+ const grid = getHeaderGrid(context);
6375
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6376
+ } else {
6377
+ focusBody(context, col);
6378
+ }
6379
+ return true;
6380
+ }
6381
+ function handleTabInFilter(context, filter, target, shiftKey) {
6382
+ const headerCell = filter.closest(`.${InfiniteTableHeaderCellClassName}`);
6383
+ const columnId = headerCell?.getAttribute("data-column-id");
6384
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6385
+ if (!column) {
6386
+ return false;
6387
+ }
6388
+ const tabbables = getTabbables(filter);
6389
+ const index = tabbables.findIndex(
6390
+ (el) => el === target || el.contains(target)
6391
+ );
6392
+ const isFirst = index <= 0;
6393
+ const isLast = index === -1 || index === tabbables.length - 1;
6394
+ if (shiftKey ? !isFirst : !isLast) {
6395
+ return false;
6396
+ }
6397
+ return focusTabStop(
6398
+ context,
6399
+ getNextTabStop(
6400
+ context,
6401
+ { col: column.computedVisibleIndex, part: "filter" },
6402
+ shiftKey ? -1 : 1
6403
+ )
6404
+ );
6405
+ }
6406
+ async function restoreFocusAfterColumnMenu(context, columnId, position2) {
6407
+ const menuOpen = () => context.getState().columnMenuVisibleForColumnId === columnId;
6408
+ for (let i = 0; i < 10 && !menuOpen(); i++) {
6409
+ await nextFrame();
6410
+ }
6411
+ while (menuOpen()) {
6412
+ await nextFrame();
6413
+ }
6414
+ await nextFrame();
6415
+ const active = document.activeElement;
6416
+ if (!active || active === document.body) {
6417
+ focusHeaderPosition(context, position2);
6418
+ }
6419
+ }
6420
+ function toggleSort(context, columnId, event) {
6421
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
6422
+ if (!column || !column.computedSortable) {
6423
+ return;
6424
+ }
6425
+ const { multiSortBehavior } = context.getState();
6426
+ context.api.toggleSortingForColumn(columnId, {
6427
+ multiSortBehavior: multiSortBehavior === "replace" && (event.ctrlKey || event.metaKey) ? "append" : multiSortBehavior
6428
+ });
5667
6429
  }
5668
6430
 
5669
6431
  // src/components/InfiniteTable/hooks/adjustColumnOrderForAllColumns.ts
@@ -6299,15 +7061,6 @@ var getBodyNode = (root) => {
6299
7061
  return root.querySelector(`.${InfiniteTableBodyClassName}`);
6300
7062
  };
6301
7063
 
6302
- // src/components/InfiniteTable/components/InfiniteTableHeader/headerClassName.ts
6303
- var InfiniteTableHeaderCellClassName = `${rootClassName}HeaderCell`;
6304
- var InfiniteTableHeaderWrapperClassName = `${rootClassName}HeaderWrapper`;
6305
- var getHeaderWrapperNodes = (root) => {
6306
- return Array.from(
6307
- root.querySelectorAll(`.${InfiniteTableHeaderWrapperClassName}`)
6308
- );
6309
- };
6310
-
6311
7064
  // src/utils/isTargetInput.ts
6312
7065
  function isTargetInput(target) {
6313
7066
  if (!target) {
@@ -6520,6 +7273,12 @@ var useColumnPointerEvents = ({
6520
7273
  multiSortBehavior: multiSortBehavior === "replace" && (e2.ctrlKey || e2.metaKey) ? "append" : multiSortBehavior
6521
7274
  });
6522
7275
  }
7276
+ const restoreHeaderFocus = reorderDragResult ? keepHeaderFocusOnColumnReorder({
7277
+ getState,
7278
+ getComputed,
7279
+ api,
7280
+ actions
7281
+ }) : null;
6523
7282
  flushSync(() => {
6524
7283
  if (reorderDragResult) {
6525
7284
  persistColumnOrder(reorderDragResult);
@@ -6533,6 +7292,7 @@ var useColumnPointerEvents = ({
6533
7292
  actions.columnReorderInPageIndex = null;
6534
7293
  }
6535
7294
  });
7295
+ restoreHeaderFocus?.();
6536
7296
  computedVisibleColumns.forEach((col) => {
6537
7297
  clearInfiniteColumnReorderDuration(
6538
7298
  col.computedVisibleIndex,
@@ -17920,108 +18680,6 @@ function HeadlessTable(props) {
17920
18680
  );
17921
18681
  }
17922
18682
 
17923
- // src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts
17924
- function buildColumnAndGroupTree(columns, columnGroups, columnGroupsDepthsMap, columnGroupsMaxDepth) {
17925
- const map2 = /* @__PURE__ */ new Map();
17926
- const temporaryMap = /* @__PURE__ */ new Map();
17927
- const mapOfAllParentGroupsForColumns = /* @__PURE__ */ new Map();
17928
- columns.forEach((col, index) => {
17929
- const colId = col.id;
17930
- const previousColumn = columns[index - 1];
17931
- const previousColumnId = previousColumn?.id ?? "";
17932
- const parentGroups = /* @__PURE__ */ new Set();
17933
- const parentGroupsOfPreviousColumn = previousColumn?.computedPinned !== col.computedPinned ? /* @__PURE__ */ new Set() : mapOfAllParentGroupsForColumns.get(previousColumnId) ?? /* @__PURE__ */ new Set();
17934
- mapOfAllParentGroupsForColumns.set(colId, parentGroups);
17935
- const colItem = {
17936
- type: "column",
17937
- id: colId,
17938
- ref: col,
17939
- groupOffset: 0,
17940
- computedPinned: col.computedPinned,
17941
- computedWidth: col.computedWidth,
17942
- depth: col.columnGroup ? (columnGroupsDepthsMap.get(col.columnGroup) ?? 0) + 1 : 0
17943
- };
17944
- map2.set([colId], colItem);
17945
- let groupId = col.columnGroup;
17946
- let colGroupItem;
17947
- let prevGroupItem = colItem;
17948
- while (groupId) {
17949
- const colGroup = columnGroups[groupId];
17950
- if (colGroup) {
17951
- parentGroups.add(groupId);
17952
- const groupAbsoluteId = [colId, ...parentGroups];
17953
- colGroupItem = parentGroupsOfPreviousColumn.has(groupId) ? temporaryMap.get(groupId) : void 0;
17954
- if (!colGroupItem) {
17955
- colGroupItem = {
17956
- id: groupId,
17957
- type: "group",
17958
- ref: colGroup,
17959
- columnItems: [],
17960
- children: [],
17961
- groupOffset: 0,
17962
- uniqueGroupId: [groupId],
17963
- computedWidth: 0,
17964
- computedPinned: colItem.computedPinned,
17965
- depth: columnGroupsDepthsMap.get(groupId) ?? 0
17966
- };
17967
- map2.set(groupAbsoluteId, colGroupItem);
17968
- temporaryMap.set(groupId, colGroupItem);
17969
- }
17970
- colGroupItem.columnItems.push(colItem);
17971
- colGroupItem.uniqueGroupId.push(colItem.id);
17972
- if (prevGroupItem && !parentGroupsOfPreviousColumn.has(prevGroupItem.id)) {
17973
- colGroupItem.children.push(prevGroupItem);
17974
- }
17975
- prevGroupItem = colGroupItem;
17976
- groupId = colGroup.columnGroup;
17977
- } else {
17978
- break;
17979
- }
17980
- }
17981
- });
17982
- const result = [];
17983
- const pathsToCells = new DeepMap();
17984
- let groupOffset = 0;
17985
- map2.forEach((item) => {
17986
- if (!item.ref.columnGroup) {
17987
- const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce(
17988
- (sum2, col) => sum2 + col.ref.computedWidth,
17989
- 0
17990
- );
17991
- item.groupOffset = groupOffset;
17992
- item.computedWidth = itemWidth;
17993
- if (item.type === "group") {
17994
- assignGroupOffsetsAndComputedWidths(item.children);
17995
- }
17996
- result.push(item);
17997
- groupOffset += itemWidth;
17998
- }
17999
- if (item.type === "group") {
18000
- item.columnItems.forEach((colItem) => {
18001
- pathsToCells.set([item.depth, colItem.ref.computedVisibleIndex], item);
18002
- });
18003
- } else {
18004
- for (let i = item.depth; i <= columnGroupsMaxDepth + 1; i++) {
18005
- pathsToCells.set([i, item.ref.computedVisibleIndex], item);
18006
- }
18007
- }
18008
- });
18009
- map2.clear();
18010
- temporaryMap.clear();
18011
- return { tree: result, pathsToCells };
18012
- }
18013
- function assignGroupOffsetsAndComputedWidths(items, groupOffset = 0) {
18014
- items.forEach((item) => {
18015
- const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce((sum2, col) => sum2 + col.ref.computedWidth, 0);
18016
- item.computedWidth = itemWidth;
18017
- item.groupOffset = groupOffset;
18018
- if (item.type === "group") {
18019
- assignGroupOffsetsAndComputedWidths(item.children);
18020
- }
18021
- groupOffset += itemWidth;
18022
- });
18023
- }
18024
-
18025
18683
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
18026
18684
  import * as React46 from "react";
18027
18685
  import { useCallback as useCallback20, useEffect as useEffect16, useMemo as useMemo8, useRef as useRef20 } from "react";
@@ -18226,6 +18884,10 @@ function InfiniteTableHeaderGroup(props) {
18226
18884
  horizontalLayoutPageIndex: props.horizontalLayoutPageIndex
18227
18885
  });
18228
18886
  }
18887
+ const groupKey = columnGroup.uniqueGroupId.join(",");
18888
+ const focused = useInfiniteTableSingleValue(
18889
+ (ctx) => ctx.state.focusedHeaderItem?.type === "group" && ctx.state.focusedHeaderItem.key === groupKey
18890
+ );
18229
18891
  const handle = useColumnGroupResizeHandle(columns, {
18230
18892
  bodyBrain,
18231
18893
  groupHeight: height2,
@@ -18249,7 +18911,12 @@ function InfiniteTableHeaderGroup(props) {
18249
18911
  {
18250
18912
  ref: props.domRef,
18251
18913
  "data-group-id": columnGroup.uniqueGroupId,
18252
- className: join(HeaderGroupCls, TableHeaderGroupClassName),
18914
+ tabIndex: -1,
18915
+ className: join(
18916
+ HeaderGroupCls,
18917
+ TableHeaderGroupClassName,
18918
+ focused ? `${TableHeaderGroupClassName}--focused` : ""
18919
+ ),
18253
18920
  style: style2,
18254
18921
  "data-z-index": zIndex2
18255
18922
  },
@@ -18654,13 +19321,29 @@ function TableHeaderWrapper(props) {
18654
19321
  }
18655
19322
  }
18656
19323
  ) : null;
19324
+ const stableContext = useInfiniteTableStableContext();
19325
+ const onFocus = React47.useCallback(
19326
+ (event) => {
19327
+ handleHeaderWrapperFocus(stableContext, event);
19328
+ },
19329
+ []
19330
+ );
19331
+ const onBlur = React47.useCallback(
19332
+ (event) => {
19333
+ handleHeaderWrapperBlur(stableContext, event);
19334
+ },
19335
+ []
19336
+ );
18657
19337
  return /* @__PURE__ */ React47.createElement(
18658
19338
  "div",
18659
19339
  {
18660
19340
  className: `${InfiniteTableHeaderWrapperClassName} ${HeaderWrapperCls}`,
18661
19341
  style: {
18662
19342
  height: height2
18663
- }
19343
+ },
19344
+ tabIndex: 0,
19345
+ onFocus,
19346
+ onBlur
18664
19347
  },
18665
19348
  header,
18666
19349
  verticalScrollbarPlaceholder
@@ -18771,7 +19454,8 @@ function InfiniteTableHeaderCellFn(props) {
18771
19454
  columnHeaderHeight,
18772
19455
  columnReorderDragColumnId,
18773
19456
  columnMenuVisibleForColumnId,
18774
- columnReorderInPageIndex
19457
+ columnReorderInPageIndex,
19458
+ headerFocused
18775
19459
  } = useInfiniteTableSelector((ctx) => {
18776
19460
  return {
18777
19461
  api: ctx.api,
@@ -18785,7 +19469,9 @@ function InfiniteTableHeaderCellFn(props) {
18785
19469
  columnHeaderHeight: ctx.state.columnHeaderHeight,
18786
19470
  columnReorderDragColumnId: ctx.state.columnReorderDragColumnId,
18787
19471
  columnMenuVisibleForColumnId: ctx.state.columnMenuVisibleForColumnId,
18788
- columnReorderInPageIndex: ctx.state.columnReorderInPageIndex
19472
+ columnReorderInPageIndex: ctx.state.columnReorderInPageIndex,
19473
+ // keyboard focus - see headerKeyboardNavigation
19474
+ headerFocused: ctx.state.focusedHeaderItem?.type === "column" && ctx.state.focusedHeaderItem.key === props.column.id
18789
19475
  };
18790
19476
  });
18791
19477
  const dragging = columnReorderDragColumnId === column.id;
@@ -19121,6 +19807,7 @@ function InfiniteTableHeaderCellFn(props) {
19121
19807
  domRef: ref,
19122
19808
  horizontalLayoutPageIndex: props.horizontalLayoutPageIndex,
19123
19809
  cellType: "header",
19810
+ tabIndex: -1,
19124
19811
  column,
19125
19812
  ...dataAttrs,
19126
19813
  "data-z-index": zIndex2,
@@ -19156,7 +19843,9 @@ function InfiniteTableHeaderCellFn(props) {
19156
19843
  treeNode: false,
19157
19844
  groupCell: false,
19158
19845
  groupRow: false,
19159
- rowExpanded: false
19846
+ rowExpanded: false,
19847
+ // keyboard focus - see headerKeyboardNavigation
19848
+ focused: headerFocused
19160
19849
  }
19161
19850
  ),
19162
19851
  CellCls
@@ -21038,6 +21727,15 @@ function handleKeyboardNavigation(options, event) {
21038
21727
  if (!validKeys[key]) {
21039
21728
  return false;
21040
21729
  }
21730
+ if (key === "ArrowUp" && !event.shiftKey) {
21731
+ const onFirstRow = keyboardNavigation === "row" ? activeRowIndex === 0 : keyboardNavigation === "cell" ? activeCellIndex?.[0] === 0 : false;
21732
+ if (onFirstRow && focusHeaderFromBody(
21733
+ options,
21734
+ keyboardNavigation === "cell" ? activeCellIndex[1] : null
21735
+ )) {
21736
+ return true;
21737
+ }
21738
+ }
21041
21739
  if (activeRowIndex != null && keyboardNavigation === "row") {
21042
21740
  return handleRowNavigation(options, event);
21043
21741
  }
@@ -27892,6 +28590,7 @@ function initSetupState2({
27892
28590
  cellContextMenuVisibleFor: null,
27893
28591
  contextMenuVisibleFor: null,
27894
28592
  columnMenuVisibleForColumnId: null,
28593
+ focusedHeaderItem: null,
27895
28594
  columnMenuVisibleKey: 0,
27896
28595
  filterOperatorMenuVisibleForColumnId: null,
27897
28596
  getDOMNodeForCell: (cellPosition) => {
@@ -29739,8 +30438,8 @@ function getLicenseStatus(licenseKey = "", options) {
29739
30438
  return "valid";
29740
30439
  }
29741
30440
  const result = checkLicense(licenseKey, {
29742
- publishedAt: 1796157962491,
29743
- version: "11.0.3"
30441
+ publishedAt: 1796226103312,
30442
+ version: "11.1.0"
29744
30443
  });
29745
30444
  if (result === "invalid" && !licenseKey) {
29746
30445
  return "missing";
@@ -29932,26 +30631,6 @@ function handleKeyboardSelection(context, keyboardEvent) {
29932
30631
  return false;
29933
30632
  }
29934
30633
 
29935
- // src/components/InfiniteTable/utils/getFocusableChildrenForNode.ts
29936
- var selector = [
29937
- "input",
29938
- "textarea",
29939
- "select",
29940
- "[tabindex]",
29941
- "a[href]",
29942
- "button",
29943
- "object"
29944
- ].join(", ");
29945
- var getFocusableChildrenForNode = (node) => {
29946
- const children = Array.from(node.querySelectorAll(selector));
29947
- return children.filter(
29948
- (child) => !!child.offsetParent
29949
- );
29950
- };
29951
- var getFirstFocusableChildForNode = (node) => {
29952
- return node.querySelector(selector);
29953
- };
29954
-
29955
30634
  // src/components/InfiniteTable/utils/cellFocusUtils.ts
29956
30635
  var import_binary_search6 = __toESM(require_binary_search());
29957
30636
 
@@ -30089,7 +30768,9 @@ async function focusLastFocusableCell(context) {
30089
30768
  }
30090
30769
  const first = getFirstFocusableChildForNode(cellNode);
30091
30770
  first?.focus();
30771
+ return;
30092
30772
  }
30773
+ context.getState().scrollerDOMRef.current?.focus({ preventScroll: true });
30093
30774
  }
30094
30775
  async function tryScrollToCell([rowIndex, colIndex], context) {
30095
30776
  const { api } = context;
@@ -30141,7 +30822,7 @@ function handleBrowserFocusChangeOnKeyboardNavigation(context, event) {
30141
30822
  return false;
30142
30823
  }
30143
30824
  if (scrollerFocused && direction === -1) {
30144
- return false;
30825
+ return focusLastHeaderTabStop(context);
30145
30826
  }
30146
30827
  const cell = scrollerFocused ? null : selectParent(target, CELL_SELECTOR);
30147
30828
  let rowIndex = null;
@@ -30311,6 +30992,12 @@ async function onKeyDown(context, event) {
30311
30992
  keyDownResult = { ...keyDownResult, ...result };
30312
30993
  }
30313
30994
  }
30995
+ if (isHeaderEventTarget(context, event.target)) {
30996
+ if (!keyDownResult.preventNavigation && handleHeaderKeyDown(context, event)) {
30997
+ event.preventDefault();
30998
+ }
30999
+ return;
31000
+ }
30314
31001
  if (!keyDownResult.preventSelection && handleKeyboardSelection(keyboardHandlerContext, event)) {
30315
31002
  event.preventDefault();
30316
31003
  }