@infinite-table/infinite-react 11.0.2 → 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.js CHANGED
@@ -3888,6 +3888,11 @@ function getInfiniteTableStoreContext() {
3888
3888
  }
3889
3889
 
3890
3890
  // src/components/InfiniteTable/hooks/useInfiniteTableSelector.ts
3891
+ function useInfiniteTableSingleValue(selector2) {
3892
+ const StoreContext = getInfiniteTableStoreContext();
3893
+ const store = (0, import_react12.useContext)(StoreContext);
3894
+ return useComponentStoreSingleValue(store, selector2);
3895
+ }
3891
3896
  function useInfiniteTableSelector(selector2) {
3892
3897
  const StoreContext = getInfiniteTableStoreContext();
3893
3898
  const store = (0, import_react12.useContext)(StoreContext);
@@ -4294,6 +4299,9 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
4294
4299
  ...baseClasses.map((c) => `${c}--first-row-in-horizontal-layout-page`)
4295
4300
  );
4296
4301
  }
4302
+ if (extraFlags.focused) {
4303
+ result.push(...baseClasses.map((c) => `${c}--focused`));
4304
+ }
4297
4305
  if (extraFlags.rowDisabled) {
4298
4306
  result.push(...baseClasses.map((c) => `${c}--disabled`));
4299
4307
  }
@@ -5709,36 +5717,790 @@ function reorderColumnsOnDrag(params) {
5709
5717
  if (idx < 0) {
5710
5718
  idx = ~idx;
5711
5719
  }
5712
- if (!breakpoints.length) {
5713
- if (computedVisibleColumns.length > 1) {
5714
- console.error("No breakpoints available, something is wrong!");
5715
- }
5716
- idx = 0;
5717
- } else {
5718
- idx = breakpoints[idx] ? breakpoints[idx].columnIndex : breakpoints[breakpoints.length - 1].columnIndex + 1;
5720
+ if (!breakpoints.length) {
5721
+ if (computedVisibleColumns.length > 1) {
5722
+ console.error("No breakpoints available, something is wrong!");
5723
+ }
5724
+ idx = 0;
5725
+ } else {
5726
+ idx = breakpoints[idx] ? breakpoints[idx].columnIndex : breakpoints[breakpoints.length - 1].columnIndex + 1;
5727
+ }
5728
+ if (idx === dragColumnIndex + 1) {
5729
+ idx = dragColumnIndex;
5730
+ }
5731
+ updateDropIndex(idx);
5732
+ const columnPinning = {};
5733
+ computedPinnedEndColumns.forEach((col) => {
5734
+ columnPinning[col.id] = "end";
5735
+ });
5736
+ for (let i = 0; i < currentPinnedStartCount; i++) {
5737
+ const colIndex = currentIndexes[i];
5738
+ const col = computedVisibleColumns[colIndex];
5739
+ columnPinning[col.id] = "start";
5740
+ }
5741
+ const columnOrder = currentIndexes.map((colIndex) => {
5742
+ return computedVisibleColumns[colIndex].id;
5743
+ });
5744
+ return {
5745
+ columnPinning,
5746
+ columnOrder
5747
+ };
5748
+ }
5749
+ };
5750
+ }
5751
+
5752
+ // src/components/InfiniteTable/components/InfiniteTableHeader/headerClassName.ts
5753
+ var InfiniteTableHeaderCellClassName = `${rootClassName}HeaderCell`;
5754
+ var InfiniteTableHeaderWrapperClassName = `${rootClassName}HeaderWrapper`;
5755
+ var getHeaderWrapperNodes = (root) => {
5756
+ return Array.from(
5757
+ root.querySelectorAll(`.${InfiniteTableHeaderWrapperClassName}`)
5758
+ );
5759
+ };
5760
+
5761
+ // src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts
5762
+ function buildColumnAndGroupTree(columns, columnGroups, columnGroupsDepthsMap, columnGroupsMaxDepth) {
5763
+ const map2 = /* @__PURE__ */ new Map();
5764
+ const temporaryMap = /* @__PURE__ */ new Map();
5765
+ const mapOfAllParentGroupsForColumns = /* @__PURE__ */ new Map();
5766
+ columns.forEach((col, index) => {
5767
+ const colId = col.id;
5768
+ const previousColumn = columns[index - 1];
5769
+ const previousColumnId = previousColumn?.id ?? "";
5770
+ const parentGroups = /* @__PURE__ */ new Set();
5771
+ const parentGroupsOfPreviousColumn = previousColumn?.computedPinned !== col.computedPinned ? /* @__PURE__ */ new Set() : mapOfAllParentGroupsForColumns.get(previousColumnId) ?? /* @__PURE__ */ new Set();
5772
+ mapOfAllParentGroupsForColumns.set(colId, parentGroups);
5773
+ const colItem = {
5774
+ type: "column",
5775
+ id: colId,
5776
+ ref: col,
5777
+ groupOffset: 0,
5778
+ computedPinned: col.computedPinned,
5779
+ computedWidth: col.computedWidth,
5780
+ depth: col.columnGroup ? (columnGroupsDepthsMap.get(col.columnGroup) ?? 0) + 1 : 0
5781
+ };
5782
+ map2.set([colId], colItem);
5783
+ let groupId = col.columnGroup;
5784
+ let colGroupItem;
5785
+ let prevGroupItem = colItem;
5786
+ while (groupId) {
5787
+ const colGroup = columnGroups[groupId];
5788
+ if (colGroup) {
5789
+ parentGroups.add(groupId);
5790
+ const groupAbsoluteId = [colId, ...parentGroups];
5791
+ colGroupItem = parentGroupsOfPreviousColumn.has(groupId) ? temporaryMap.get(groupId) : void 0;
5792
+ if (!colGroupItem) {
5793
+ colGroupItem = {
5794
+ id: groupId,
5795
+ type: "group",
5796
+ ref: colGroup,
5797
+ columnItems: [],
5798
+ children: [],
5799
+ groupOffset: 0,
5800
+ uniqueGroupId: [groupId],
5801
+ computedWidth: 0,
5802
+ computedPinned: colItem.computedPinned,
5803
+ depth: columnGroupsDepthsMap.get(groupId) ?? 0
5804
+ };
5805
+ map2.set(groupAbsoluteId, colGroupItem);
5806
+ temporaryMap.set(groupId, colGroupItem);
5807
+ }
5808
+ colGroupItem.columnItems.push(colItem);
5809
+ colGroupItem.uniqueGroupId.push(colItem.id);
5810
+ if (prevGroupItem && !parentGroupsOfPreviousColumn.has(prevGroupItem.id)) {
5811
+ colGroupItem.children.push(prevGroupItem);
5812
+ }
5813
+ prevGroupItem = colGroupItem;
5814
+ groupId = colGroup.columnGroup;
5815
+ } else {
5816
+ break;
5817
+ }
5818
+ }
5819
+ });
5820
+ const result = [];
5821
+ const pathsToCells = new DeepMap();
5822
+ let groupOffset = 0;
5823
+ map2.forEach((item) => {
5824
+ if (!item.ref.columnGroup) {
5825
+ const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce(
5826
+ (sum2, col) => sum2 + col.ref.computedWidth,
5827
+ 0
5828
+ );
5829
+ item.groupOffset = groupOffset;
5830
+ item.computedWidth = itemWidth;
5831
+ if (item.type === "group") {
5832
+ assignGroupOffsetsAndComputedWidths(item.children);
5833
+ }
5834
+ result.push(item);
5835
+ groupOffset += itemWidth;
5836
+ }
5837
+ if (item.type === "group") {
5838
+ item.columnItems.forEach((colItem) => {
5839
+ pathsToCells.set([item.depth, colItem.ref.computedVisibleIndex], item);
5840
+ });
5841
+ } else {
5842
+ for (let i = item.depth; i <= columnGroupsMaxDepth + 1; i++) {
5843
+ pathsToCells.set([i, item.ref.computedVisibleIndex], item);
5844
+ }
5845
+ }
5846
+ });
5847
+ map2.clear();
5848
+ temporaryMap.clear();
5849
+ return { tree: result, pathsToCells };
5850
+ }
5851
+ function assignGroupOffsetsAndComputedWidths(items, groupOffset = 0) {
5852
+ items.forEach((item) => {
5853
+ const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce((sum2, col) => sum2 + col.ref.computedWidth, 0);
5854
+ item.computedWidth = itemWidth;
5855
+ item.groupOffset = groupOffset;
5856
+ if (item.type === "group") {
5857
+ assignGroupOffsetsAndComputedWidths(item.children);
5858
+ }
5859
+ groupOffset += itemWidth;
5860
+ });
5861
+ }
5862
+
5863
+ // src/components/InfiniteTable/utils/getFocusableChildrenForNode.ts
5864
+ var selector = [
5865
+ "input",
5866
+ "textarea",
5867
+ "select",
5868
+ "[tabindex]",
5869
+ "a[href]",
5870
+ "button",
5871
+ "object"
5872
+ ].join(", ");
5873
+ var getFocusableChildrenForNode = (node) => {
5874
+ const children = Array.from(node.querySelectorAll(selector));
5875
+ return children.filter(
5876
+ (child) => !!child.offsetParent
5877
+ );
5878
+ };
5879
+ var getFirstFocusableChildForNode = (node) => {
5880
+ return node.querySelector(selector);
5881
+ };
5882
+
5883
+ // src/components/InfiniteTable/eventHandlers/headerKeyboardNavigation.ts
5884
+ var HEADER_GROUP_CLASS_NAME = `${rootClassName}HeaderGroup`;
5885
+ var FILTER_SELECTOR = `.${InfiniteTableColumnHeaderFilterClassName}`;
5886
+ var TABBABLE_SELECTOR = [
5887
+ "input",
5888
+ "select",
5889
+ "textarea",
5890
+ "button",
5891
+ "a[href]",
5892
+ "[tabindex]"
5893
+ ].join(", ");
5894
+ var WRAPPER_SELECTOR = `.${InfiniteTableHeaderWrapperClassName}`;
5895
+ var ROOT_SELECTOR = `.${rootClassName}`;
5896
+ var lastPositions = /* @__PURE__ */ new WeakMap();
5897
+ function getRoot(context) {
5898
+ return context.getState().domRef.current;
5899
+ }
5900
+ function getOwnHeaderWrapper(context) {
5901
+ const root = getRoot(context);
5902
+ if (!root) {
5903
+ return null;
5904
+ }
5905
+ const wrappers = Array.from(
5906
+ root.querySelectorAll(WRAPPER_SELECTOR)
5907
+ );
5908
+ return wrappers.find((wrapper) => wrapper.closest(ROOT_SELECTOR) === root) ?? null;
5909
+ }
5910
+ function isHeaderEventTarget(context, target) {
5911
+ if (!(target instanceof Element)) {
5912
+ return false;
5913
+ }
5914
+ const wrapper = target.closest(WRAPPER_SELECTOR);
5915
+ return !!wrapper && wrapper.closest(ROOT_SELECTOR) === getRoot(context);
5916
+ }
5917
+ function getHeaderGrid(context) {
5918
+ const state = context.getState();
5919
+ const { computedVisibleColumns } = context.getComputed();
5920
+ const hasGroups = !!state.computedColumnGroups && Object.keys(state.computedColumnGroups).length > 0;
5921
+ const rowCount = hasGroups ? state.columnGroupsMaxDepth + 2 : 1;
5922
+ const colCount = computedVisibleColumns.length;
5923
+ const tree2 = hasGroups ? buildColumnAndGroupTree(
5924
+ computedVisibleColumns,
5925
+ state.computedColumnGroups,
5926
+ state.columnGroupsDepthsMap,
5927
+ state.columnGroupsMaxDepth
5928
+ ) : null;
5929
+ const toItem = (treeItem) => {
5930
+ if (treeItem.type === "column") {
5931
+ const index = treeItem.ref.computedVisibleIndex;
5932
+ return {
5933
+ type: "column",
5934
+ key: treeItem.ref.id,
5935
+ columnId: treeItem.ref.id,
5936
+ firstCol: index,
5937
+ lastCol: index
5938
+ };
5939
+ }
5940
+ const indexes = treeItem.columnItems.map(
5941
+ (colItem) => colItem.ref.computedVisibleIndex
5942
+ );
5943
+ return {
5944
+ type: "group",
5945
+ key: treeItem.uniqueGroupId.join(","),
5946
+ firstCol: Math.min(...indexes),
5947
+ lastCol: Math.max(...indexes)
5948
+ };
5949
+ };
5950
+ const itemAt = ({ row, col }) => {
5951
+ if (row < 0 || row >= rowCount || col < 0 || col >= colCount) {
5952
+ return null;
5953
+ }
5954
+ if (!tree2) {
5955
+ const column = computedVisibleColumns[col];
5956
+ return column ? {
5957
+ type: "column",
5958
+ key: column.id,
5959
+ columnId: column.id,
5960
+ firstCol: col,
5961
+ lastCol: col
5962
+ } : null;
5963
+ }
5964
+ const treeItem = tree2.pathsToCells.get([row, col]);
5965
+ return treeItem ? toItem(treeItem) : null;
5966
+ };
5967
+ return { rowCount, colCount, itemAt };
5968
+ }
5969
+ function getItemElement(context, item) {
5970
+ const wrapper = getOwnHeaderWrapper(context);
5971
+ if (!wrapper) {
5972
+ return null;
5973
+ }
5974
+ const selector2 = item.type === "column" ? `.${InfiniteTableHeaderCellClassName}[data-column-id="${CSS.escape(
5975
+ item.columnId
5976
+ )}"]` : `.${HEADER_GROUP_CLASS_NAME}[data-group-id="${CSS.escape(item.key)}"]`;
5977
+ const nodes = Array.from(wrapper.querySelectorAll(selector2));
5978
+ return nodes.find(
5979
+ (node) => node.closest(ROOT_SELECTOR) === getRoot(context) && node.offsetParent !== null
5980
+ ) ?? null;
5981
+ }
5982
+ function getCurrentPosition(context, grid, element) {
5983
+ const root = getRoot(context);
5984
+ const remembered = root ? lastPositions.get(root) : void 0;
5985
+ const columnId = element.getAttribute("data-column-id");
5986
+ const groupId = element.classList.contains(HEADER_GROUP_CLASS_NAME) ? element.getAttribute("data-group-id") : null;
5987
+ const key = groupId ?? columnId;
5988
+ if (key == null) {
5989
+ return null;
5990
+ }
5991
+ if (remembered && grid.itemAt(remembered)?.key === key) {
5992
+ return remembered;
5993
+ }
5994
+ if (columnId != null && groupId == null) {
5995
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
5996
+ if (!column) {
5997
+ return null;
5998
+ }
5999
+ return { row: grid.rowCount - 1, col: column.computedVisibleIndex };
6000
+ }
6001
+ for (let row = 0; row < grid.rowCount; row++) {
6002
+ for (let col = 0; col < grid.colCount; col++) {
6003
+ if (grid.itemAt({ row, col })?.key === key) {
6004
+ return { row, col };
6005
+ }
6006
+ }
6007
+ }
6008
+ return null;
6009
+ }
6010
+ function nextFrame() {
6011
+ return new Promise((resolve) => requestAnimationFrame(() => resolve()));
6012
+ }
6013
+ async function focusHeaderPosition(context, position2, grid = getHeaderGrid(context)) {
6014
+ const item = grid.itemAt(position2);
6015
+ if (!item) {
6016
+ return false;
6017
+ }
6018
+ if (item.type === "column") {
6019
+ position2 = { row: grid.rowCount - 1, col: item.firstCol };
6020
+ }
6021
+ const root = getRoot(context);
6022
+ if (root) {
6023
+ lastPositions.set(root, position2);
6024
+ }
6025
+ const element = await revealHeaderItem(
6026
+ context,
6027
+ item,
6028
+ Math.min(Math.max(position2.col, item.firstCol), item.lastCol)
6029
+ );
6030
+ if (!element) {
6031
+ return false;
6032
+ }
6033
+ element.focus({ preventScroll: true });
6034
+ return true;
6035
+ }
6036
+ async function revealHeaderItem(context, item, colIndex) {
6037
+ const column = context.getComputed().computedVisibleColumns[colIndex];
6038
+ if (column && column.computedPinned === false) {
6039
+ context.api.scrollColumnIntoView(column.id);
6040
+ }
6041
+ const focusedBefore = document.activeElement;
6042
+ let element = getItemElement(context, item);
6043
+ for (let i = 0; i < 20 && (!element || !isInView(context, element)); i++) {
6044
+ await nextFrame();
6045
+ const active = document.activeElement;
6046
+ if (active !== focusedBefore && active && active !== document.body) {
6047
+ return null;
6048
+ }
6049
+ element = getItemElement(context, item);
6050
+ }
6051
+ return element;
6052
+ }
6053
+ function columnItem(context, colIndex) {
6054
+ const column = context.getComputed().computedVisibleColumns[colIndex];
6055
+ return column ? {
6056
+ type: "column",
6057
+ key: column.id,
6058
+ columnId: column.id,
6059
+ firstCol: colIndex,
6060
+ lastCol: colIndex
6061
+ } : null;
6062
+ }
6063
+ function columnHasFilter(context, colIndex) {
6064
+ const column = context.getComputed().computedVisibleColumns[colIndex];
6065
+ return !!context.getState().showColumnFilters && !!column?.computedFilterable;
6066
+ }
6067
+ function getTabbables(node) {
6068
+ if (!node) {
6069
+ return [];
6070
+ }
6071
+ return Array.from(node.querySelectorAll(TABBABLE_SELECTOR)).filter(
6072
+ (el) => el.tabIndex >= 0 && !el.disabled && el.offsetParent !== null
6073
+ );
6074
+ }
6075
+ async function focusColumnFilter(context, colIndex, grid = getHeaderGrid(context)) {
6076
+ const item = columnItem(context, colIndex);
6077
+ if (!item) {
6078
+ return false;
6079
+ }
6080
+ const root = getRoot(context);
6081
+ if (root) {
6082
+ lastPositions.set(root, { row: grid.rowCount - 1, col: colIndex });
6083
+ }
6084
+ const headerCell = await revealHeaderItem(context, item, colIndex);
6085
+ const [first] = getTabbables(
6086
+ headerCell?.querySelector(FILTER_SELECTOR) ?? null
6087
+ );
6088
+ if (!first) {
6089
+ return false;
6090
+ }
6091
+ first.focus({ preventScroll: true });
6092
+ return true;
6093
+ }
6094
+ function getNextTabStop(context, stop, direction) {
6095
+ const colCount = context.getComputed().computedVisibleColumns.length;
6096
+ if (direction === 1) {
6097
+ if (stop.part === "header" && columnHasFilter(context, stop.col)) {
6098
+ return { col: stop.col, part: "filter" };
6099
+ }
6100
+ return stop.col + 1 < colCount ? { col: stop.col + 1, part: "header" } : "after";
6101
+ }
6102
+ if (stop.part === "filter") {
6103
+ return { col: stop.col, part: "header" };
6104
+ }
6105
+ if (stop.col <= 0) {
6106
+ return "before";
6107
+ }
6108
+ return columnHasFilter(context, stop.col - 1) ? { col: stop.col - 1, part: "filter" } : { col: stop.col - 1, part: "header" };
6109
+ }
6110
+ function focusTabStop(context, stop) {
6111
+ if (stop === "before") {
6112
+ return focusBeforeHeader(context);
6113
+ }
6114
+ if (stop === "after") {
6115
+ context.getState().scrollerDOMRef.current?.focus({ preventScroll: true });
6116
+ return true;
6117
+ }
6118
+ const grid = getHeaderGrid(context);
6119
+ if (stop.part === "filter") {
6120
+ focusColumnFilter(context, stop.col, grid);
6121
+ } else {
6122
+ focusHeaderPosition(
6123
+ context,
6124
+ { row: grid.rowCount - 1, col: stop.col },
6125
+ grid
6126
+ );
6127
+ }
6128
+ return true;
6129
+ }
6130
+ function focusLastHeaderTabStop(context) {
6131
+ if (!getOwnHeaderWrapper(context)) {
6132
+ return false;
6133
+ }
6134
+ const colCount = context.getComputed().computedVisibleColumns.length;
6135
+ if (!colCount) {
6136
+ return false;
6137
+ }
6138
+ const col = colCount - 1;
6139
+ return focusTabStop(context, {
6140
+ col,
6141
+ part: columnHasFilter(context, col) ? "filter" : "header"
6142
+ });
6143
+ }
6144
+ function isInView(context, element) {
6145
+ const wrapper = getOwnHeaderWrapper(context);
6146
+ if (!wrapper) {
6147
+ return true;
6148
+ }
6149
+ if (getComputedStyle(element).visibility === "hidden") {
6150
+ return false;
6151
+ }
6152
+ const wrapperRect = wrapper.getBoundingClientRect();
6153
+ const rect = element.getBoundingClientRect();
6154
+ return rect.right > wrapperRect.left + 1 && rect.left < wrapperRect.right - 1;
6155
+ }
6156
+ function getEntryPosition(context, grid) {
6157
+ const root = getRoot(context);
6158
+ const remembered = root ? lastPositions.get(root) : void 0;
6159
+ if (remembered && grid.itemAt(remembered)) {
6160
+ return remembered;
6161
+ }
6162
+ return { row: grid.rowCount - 1, col: 0 };
6163
+ }
6164
+ function handleHeaderWrapperFocus(context, event) {
6165
+ if (event.target !== event.currentTarget) {
6166
+ setFocusedHeaderItem(context, getFocusedHeaderItem(event.target));
6167
+ if (event.currentTarget instanceof HTMLElement) {
6168
+ keepHeaderAligned(context, event.currentTarget, event.target);
6169
+ }
6170
+ return;
6171
+ }
6172
+ const grid = getHeaderGrid(context);
6173
+ if (!grid.colCount) {
6174
+ return;
6175
+ }
6176
+ focusHeaderPosition(context, getEntryPosition(context, grid), grid);
6177
+ }
6178
+ function handleHeaderWrapperBlur(context, event) {
6179
+ const wrapper = event.currentTarget;
6180
+ const next = event.relatedTarget;
6181
+ if (!(wrapper instanceof Node) || !(next instanceof Node) || !wrapper.contains(next)) {
6182
+ setFocusedHeaderItem(context, null);
6183
+ }
6184
+ }
6185
+ function getFocusedHeaderItem(target) {
6186
+ if (!(target instanceof HTMLElement)) {
6187
+ return null;
6188
+ }
6189
+ if (target.classList.contains(InfiniteTableHeaderCellClassName)) {
6190
+ const key = target.getAttribute("data-column-id");
6191
+ return key != null ? { type: "column", key } : null;
6192
+ }
6193
+ if (target.classList.contains(HEADER_GROUP_CLASS_NAME)) {
6194
+ const key = target.getAttribute("data-group-id");
6195
+ return key != null ? { type: "group", key } : null;
6196
+ }
6197
+ return null;
6198
+ }
6199
+ function setFocusedHeaderItem(context, item) {
6200
+ const current = context.getState().focusedHeaderItem;
6201
+ if (current?.type === item?.type && current?.key === item?.key) {
6202
+ return;
6203
+ }
6204
+ context.actions.focusedHeaderItem = item;
6205
+ }
6206
+ function keepHeaderFocusOnColumnReorder(context) {
6207
+ const item = context.getState().focusedHeaderItem;
6208
+ if (item?.type !== "column") {
6209
+ return () => {
6210
+ };
6211
+ }
6212
+ const columnId = item.key;
6213
+ return () => {
6214
+ void (async () => {
6215
+ await nextFrame();
6216
+ const active = document.activeElement;
6217
+ const wrapper = getOwnHeaderWrapper(context);
6218
+ if (active && active !== document.body && !(wrapper && wrapper.contains(active))) {
6219
+ return;
6220
+ }
6221
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
6222
+ if (!column) {
6223
+ return;
6224
+ }
6225
+ const grid = getHeaderGrid(context);
6226
+ await focusHeaderPosition(
6227
+ context,
6228
+ { row: grid.rowCount - 1, col: column.computedVisibleIndex },
6229
+ grid
6230
+ );
6231
+ })();
6232
+ };
6233
+ }
6234
+ function keepHeaderAligned(context, wrapper, target) {
6235
+ const headerCell = target instanceof Element ? target.closest(
6236
+ `.${InfiniteTableHeaderCellClassName}`
6237
+ ) : null;
6238
+ const columnId = headerCell?.getAttribute("data-column-id");
6239
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6240
+ const resetNativeScroll = () => {
6241
+ if (wrapper.scrollLeft || wrapper.scrollTop) {
6242
+ wrapper.scrollLeft = 0;
6243
+ wrapper.scrollTop = 0;
6244
+ }
6245
+ };
6246
+ resetNativeScroll();
6247
+ if (column && column.computedPinned === false) {
6248
+ context.api.scrollColumnIntoView(column.id);
6249
+ }
6250
+ requestAnimationFrame(resetNativeScroll);
6251
+ }
6252
+ function focusHeaderFromBody(context, colIndex) {
6253
+ if (!getOwnHeaderWrapper(context)) {
6254
+ return false;
6255
+ }
6256
+ const grid = getHeaderGrid(context);
6257
+ if (!grid.colCount) {
6258
+ return false;
6259
+ }
6260
+ const col = colIndex ?? getEntryPosition(context, grid).col;
6261
+ if (columnHasFilter(context, col)) {
6262
+ focusColumnFilter(context, col, grid).then((focused) => {
6263
+ if (!focused) {
6264
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6265
+ }
6266
+ });
6267
+ return true;
6268
+ }
6269
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6270
+ return true;
6271
+ }
6272
+ function focusBody(context, colIndex) {
6273
+ const state = context.getState();
6274
+ const { brain, keyboardNavigation } = state;
6275
+ if (brain.getRowCount() > 0) {
6276
+ const firstVisibleRow = Math.max(
6277
+ 0,
6278
+ brain.getItemAt(brain.getScrollPosition().scrollTop, "vertical")
6279
+ );
6280
+ if (keyboardNavigation === "cell") {
6281
+ context.actions.activeCellIndex = [firstVisibleRow, colIndex];
6282
+ } else if (keyboardNavigation === "row") {
6283
+ context.actions.activeRowIndex = firstVisibleRow;
6284
+ }
6285
+ }
6286
+ state.scrollerDOMRef.current?.focus({ preventScroll: true });
6287
+ }
6288
+ function focusBeforeHeader(context) {
6289
+ const wrapper = getOwnHeaderWrapper(context);
6290
+ if (!wrapper) {
6291
+ return false;
6292
+ }
6293
+ const nodes = getFocusableChildrenForNode(document.body);
6294
+ const index = nodes.indexOf(wrapper);
6295
+ const previous = index > 0 ? nodes[index - 1] : null;
6296
+ if (previous) {
6297
+ previous.focus();
6298
+ } else {
6299
+ document.activeElement?.blur();
6300
+ }
6301
+ return true;
6302
+ }
6303
+ function isTargetEditable(target) {
6304
+ if (!(target instanceof HTMLElement)) {
6305
+ return false;
6306
+ }
6307
+ const tagName = target.tagName;
6308
+ return tagName === "INPUT" || tagName === "TEXTAREA" || tagName === "SELECT" || tagName === "BUTTON" || target.isContentEditable;
6309
+ }
6310
+ function handleHeaderKeyDown(context, event) {
6311
+ const target = event.target;
6312
+ if (!(target instanceof HTMLElement)) {
6313
+ return false;
6314
+ }
6315
+ const filter = target.closest(FILTER_SELECTOR);
6316
+ if (filter) {
6317
+ return handleKeyInFilter(context, filter, target, event);
6318
+ }
6319
+ if (isTargetEditable(target)) {
6320
+ return false;
6321
+ }
6322
+ const isHeaderCell = target.classList.contains(InfiniteTableHeaderCellClassName) || target.classList.contains(HEADER_GROUP_CLASS_NAME);
6323
+ if (!isHeaderCell) {
6324
+ return false;
6325
+ }
6326
+ const grid = getHeaderGrid(context);
6327
+ const position2 = getCurrentPosition(context, grid, target);
6328
+ if (!position2) {
6329
+ return false;
6330
+ }
6331
+ const item = grid.itemAt(position2);
6332
+ if (!item) {
6333
+ return false;
6334
+ }
6335
+ if (event.key === "Tab") {
6336
+ const direction = event.shiftKey ? -1 : 1;
6337
+ if (item.type === "group" && direction === 1) {
6338
+ return focusTabStop(context, { col: item.firstCol, part: "header" });
6339
+ }
6340
+ return focusTabStop(
6341
+ context,
6342
+ getNextTabStop(
6343
+ context,
6344
+ { col: item.firstCol, part: "header" },
6345
+ direction
6346
+ )
6347
+ );
6348
+ }
6349
+ const { computedVisibleColumns } = context.getComputed();
6350
+ if (event.key === "Enter") {
6351
+ if (item.type !== "column") {
6352
+ return false;
6353
+ }
6354
+ toggleSort(context, item.columnId, event);
6355
+ return true;
6356
+ }
6357
+ if (event.key === "ArrowDown" && event.altKey) {
6358
+ if (item.type !== "column") {
6359
+ return false;
6360
+ }
6361
+ const menuIcon = target.querySelector(
6362
+ `[data-name="menu-icon"]`
6363
+ );
6364
+ context.api.getColumnApi(item.columnId)?.toggleContextMenu(menuIcon ?? target);
6365
+ restoreFocusAfterColumnMenu(context, item.columnId, position2);
6366
+ return true;
6367
+ }
6368
+ if (event.altKey || event.ctrlKey || event.metaKey) {
6369
+ return false;
6370
+ }
6371
+ const lastCol = computedVisibleColumns.length - 1;
6372
+ switch (event.key) {
6373
+ case "ArrowRight": {
6374
+ if (item.lastCol < lastCol) {
6375
+ focusHeaderPosition(
6376
+ context,
6377
+ { row: position2.row, col: item.lastCol + 1 },
6378
+ grid
6379
+ );
6380
+ }
6381
+ return true;
6382
+ }
6383
+ case "ArrowLeft": {
6384
+ if (item.firstCol > 0) {
6385
+ focusHeaderPosition(
6386
+ context,
6387
+ { row: position2.row, col: item.firstCol - 1 },
6388
+ grid
6389
+ );
5719
6390
  }
5720
- if (idx === dragColumnIndex + 1) {
5721
- idx = dragColumnIndex;
6391
+ return true;
6392
+ }
6393
+ case "Home": {
6394
+ focusHeaderPosition(context, { row: position2.row, col: 0 }, grid);
6395
+ return true;
6396
+ }
6397
+ case "End": {
6398
+ focusHeaderPosition(context, { row: position2.row, col: lastCol }, grid);
6399
+ return true;
6400
+ }
6401
+ case "ArrowUp": {
6402
+ let row = position2.row - 1;
6403
+ while (row >= 0 && grid.itemAt({ row, col: position2.col })?.key === item.key) {
6404
+ row--;
5722
6405
  }
5723
- updateDropIndex(idx);
5724
- const columnPinning = {};
5725
- computedPinnedEndColumns.forEach((col) => {
5726
- columnPinning[col.id] = "end";
5727
- });
5728
- for (let i = 0; i < currentPinnedStartCount; i++) {
5729
- const colIndex = currentIndexes[i];
5730
- const col = computedVisibleColumns[colIndex];
5731
- columnPinning[col.id] = "start";
6406
+ if (row >= 0) {
6407
+ focusHeaderPosition(context, { row, col: position2.col }, grid);
5732
6408
  }
5733
- const columnOrder = currentIndexes.map((colIndex) => {
5734
- return computedVisibleColumns[colIndex].id;
5735
- });
5736
- return {
5737
- columnPinning,
5738
- columnOrder
5739
- };
6409
+ return true;
5740
6410
  }
5741
- };
6411
+ case "ArrowDown": {
6412
+ let row = position2.row + 1;
6413
+ while (row < grid.rowCount && grid.itemAt({ row, col: position2.col })?.key === item.key) {
6414
+ row++;
6415
+ }
6416
+ if (row < grid.rowCount) {
6417
+ focusHeaderPosition(context, { row, col: position2.col }, grid);
6418
+ } else if (columnHasFilter(context, position2.col)) {
6419
+ focusColumnFilter(context, position2.col, grid).then((focused) => {
6420
+ if (!focused) {
6421
+ focusBody(context, position2.col);
6422
+ }
6423
+ });
6424
+ } else {
6425
+ focusBody(context, position2.col);
6426
+ }
6427
+ return true;
6428
+ }
6429
+ }
6430
+ return false;
6431
+ }
6432
+ function handleKeyInFilter(context, filter, target, event) {
6433
+ if (event.defaultPrevented) {
6434
+ return false;
6435
+ }
6436
+ if (event.key === "Tab") {
6437
+ return handleTabInFilter(context, filter, target, event.shiftKey);
6438
+ }
6439
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown" || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
6440
+ return false;
6441
+ }
6442
+ const columnId = filter.closest(`.${InfiniteTableHeaderCellClassName}`)?.getAttribute("data-column-id");
6443
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6444
+ if (!column) {
6445
+ return false;
6446
+ }
6447
+ const col = column.computedVisibleIndex;
6448
+ if (event.key === "ArrowUp") {
6449
+ const grid = getHeaderGrid(context);
6450
+ focusHeaderPosition(context, { row: grid.rowCount - 1, col }, grid);
6451
+ } else {
6452
+ focusBody(context, col);
6453
+ }
6454
+ return true;
6455
+ }
6456
+ function handleTabInFilter(context, filter, target, shiftKey) {
6457
+ const headerCell = filter.closest(`.${InfiniteTableHeaderCellClassName}`);
6458
+ const columnId = headerCell?.getAttribute("data-column-id");
6459
+ const column = columnId ? context.getComputed().computedVisibleColumnsMap.get(columnId) : null;
6460
+ if (!column) {
6461
+ return false;
6462
+ }
6463
+ const tabbables = getTabbables(filter);
6464
+ const index = tabbables.findIndex(
6465
+ (el) => el === target || el.contains(target)
6466
+ );
6467
+ const isFirst = index <= 0;
6468
+ const isLast = index === -1 || index === tabbables.length - 1;
6469
+ if (shiftKey ? !isFirst : !isLast) {
6470
+ return false;
6471
+ }
6472
+ return focusTabStop(
6473
+ context,
6474
+ getNextTabStop(
6475
+ context,
6476
+ { col: column.computedVisibleIndex, part: "filter" },
6477
+ shiftKey ? -1 : 1
6478
+ )
6479
+ );
6480
+ }
6481
+ async function restoreFocusAfterColumnMenu(context, columnId, position2) {
6482
+ const menuOpen = () => context.getState().columnMenuVisibleForColumnId === columnId;
6483
+ for (let i = 0; i < 10 && !menuOpen(); i++) {
6484
+ await nextFrame();
6485
+ }
6486
+ while (menuOpen()) {
6487
+ await nextFrame();
6488
+ }
6489
+ await nextFrame();
6490
+ const active = document.activeElement;
6491
+ if (!active || active === document.body) {
6492
+ focusHeaderPosition(context, position2);
6493
+ }
6494
+ }
6495
+ function toggleSort(context, columnId, event) {
6496
+ const column = context.getComputed().computedVisibleColumnsMap.get(columnId);
6497
+ if (!column || !column.computedSortable) {
6498
+ return;
6499
+ }
6500
+ const { multiSortBehavior } = context.getState();
6501
+ context.api.toggleSortingForColumn(columnId, {
6502
+ multiSortBehavior: multiSortBehavior === "replace" && (event.ctrlKey || event.metaKey) ? "append" : multiSortBehavior
6503
+ });
5742
6504
  }
5743
6505
 
5744
6506
  // src/components/InfiniteTable/hooks/adjustColumnOrderForAllColumns.ts
@@ -6374,15 +7136,6 @@ var getBodyNode = (root) => {
6374
7136
  return root.querySelector(`.${InfiniteTableBodyClassName}`);
6375
7137
  };
6376
7138
 
6377
- // src/components/InfiniteTable/components/InfiniteTableHeader/headerClassName.ts
6378
- var InfiniteTableHeaderCellClassName = `${rootClassName}HeaderCell`;
6379
- var InfiniteTableHeaderWrapperClassName = `${rootClassName}HeaderWrapper`;
6380
- var getHeaderWrapperNodes = (root) => {
6381
- return Array.from(
6382
- root.querySelectorAll(`.${InfiniteTableHeaderWrapperClassName}`)
6383
- );
6384
- };
6385
-
6386
7139
  // src/utils/isTargetInput.ts
6387
7140
  function isTargetInput(target) {
6388
7141
  if (!target) {
@@ -6595,6 +7348,12 @@ var useColumnPointerEvents = ({
6595
7348
  multiSortBehavior: multiSortBehavior === "replace" && (e2.ctrlKey || e2.metaKey) ? "append" : multiSortBehavior
6596
7349
  });
6597
7350
  }
7351
+ const restoreHeaderFocus = reorderDragResult ? keepHeaderFocusOnColumnReorder({
7352
+ getState,
7353
+ getComputed,
7354
+ api,
7355
+ actions
7356
+ }) : null;
6598
7357
  (0, import_react_dom.flushSync)(() => {
6599
7358
  if (reorderDragResult) {
6600
7359
  persistColumnOrder(reorderDragResult);
@@ -6608,6 +7367,7 @@ var useColumnPointerEvents = ({
6608
7367
  actions.columnReorderInPageIndex = null;
6609
7368
  }
6610
7369
  });
7370
+ restoreHeaderFocus?.();
6611
7371
  computedVisibleColumns.forEach((col) => {
6612
7372
  clearInfiniteColumnReorderDuration(
6613
7373
  col.computedVisibleIndex,
@@ -17982,108 +18742,6 @@ function HeadlessTable(props) {
17982
18742
  );
17983
18743
  }
17984
18744
 
17985
- // src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts
17986
- function buildColumnAndGroupTree(columns, columnGroups, columnGroupsDepthsMap, columnGroupsMaxDepth) {
17987
- const map2 = /* @__PURE__ */ new Map();
17988
- const temporaryMap = /* @__PURE__ */ new Map();
17989
- const mapOfAllParentGroupsForColumns = /* @__PURE__ */ new Map();
17990
- columns.forEach((col, index) => {
17991
- const colId = col.id;
17992
- const previousColumn = columns[index - 1];
17993
- const previousColumnId = previousColumn?.id ?? "";
17994
- const parentGroups = /* @__PURE__ */ new Set();
17995
- const parentGroupsOfPreviousColumn = previousColumn?.computedPinned !== col.computedPinned ? /* @__PURE__ */ new Set() : mapOfAllParentGroupsForColumns.get(previousColumnId) ?? /* @__PURE__ */ new Set();
17996
- mapOfAllParentGroupsForColumns.set(colId, parentGroups);
17997
- const colItem = {
17998
- type: "column",
17999
- id: colId,
18000
- ref: col,
18001
- groupOffset: 0,
18002
- computedPinned: col.computedPinned,
18003
- computedWidth: col.computedWidth,
18004
- depth: col.columnGroup ? (columnGroupsDepthsMap.get(col.columnGroup) ?? 0) + 1 : 0
18005
- };
18006
- map2.set([colId], colItem);
18007
- let groupId = col.columnGroup;
18008
- let colGroupItem;
18009
- let prevGroupItem = colItem;
18010
- while (groupId) {
18011
- const colGroup = columnGroups[groupId];
18012
- if (colGroup) {
18013
- parentGroups.add(groupId);
18014
- const groupAbsoluteId = [colId, ...parentGroups];
18015
- colGroupItem = parentGroupsOfPreviousColumn.has(groupId) ? temporaryMap.get(groupId) : void 0;
18016
- if (!colGroupItem) {
18017
- colGroupItem = {
18018
- id: groupId,
18019
- type: "group",
18020
- ref: colGroup,
18021
- columnItems: [],
18022
- children: [],
18023
- groupOffset: 0,
18024
- uniqueGroupId: [groupId],
18025
- computedWidth: 0,
18026
- computedPinned: colItem.computedPinned,
18027
- depth: columnGroupsDepthsMap.get(groupId) ?? 0
18028
- };
18029
- map2.set(groupAbsoluteId, colGroupItem);
18030
- temporaryMap.set(groupId, colGroupItem);
18031
- }
18032
- colGroupItem.columnItems.push(colItem);
18033
- colGroupItem.uniqueGroupId.push(colItem.id);
18034
- if (prevGroupItem && !parentGroupsOfPreviousColumn.has(prevGroupItem.id)) {
18035
- colGroupItem.children.push(prevGroupItem);
18036
- }
18037
- prevGroupItem = colGroupItem;
18038
- groupId = colGroup.columnGroup;
18039
- } else {
18040
- break;
18041
- }
18042
- }
18043
- });
18044
- const result = [];
18045
- const pathsToCells = new DeepMap();
18046
- let groupOffset = 0;
18047
- map2.forEach((item) => {
18048
- if (!item.ref.columnGroup) {
18049
- const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce(
18050
- (sum2, col) => sum2 + col.ref.computedWidth,
18051
- 0
18052
- );
18053
- item.groupOffset = groupOffset;
18054
- item.computedWidth = itemWidth;
18055
- if (item.type === "group") {
18056
- assignGroupOffsetsAndComputedWidths(item.children);
18057
- }
18058
- result.push(item);
18059
- groupOffset += itemWidth;
18060
- }
18061
- if (item.type === "group") {
18062
- item.columnItems.forEach((colItem) => {
18063
- pathsToCells.set([item.depth, colItem.ref.computedVisibleIndex], item);
18064
- });
18065
- } else {
18066
- for (let i = item.depth; i <= columnGroupsMaxDepth + 1; i++) {
18067
- pathsToCells.set([i, item.ref.computedVisibleIndex], item);
18068
- }
18069
- }
18070
- });
18071
- map2.clear();
18072
- temporaryMap.clear();
18073
- return { tree: result, pathsToCells };
18074
- }
18075
- function assignGroupOffsetsAndComputedWidths(items, groupOffset = 0) {
18076
- items.forEach((item) => {
18077
- const itemWidth = item.type === "column" ? item.ref.computedWidth : item.columnItems.reduce((sum2, col) => sum2 + col.ref.computedWidth, 0);
18078
- item.computedWidth = itemWidth;
18079
- item.groupOffset = groupOffset;
18080
- if (item.type === "group") {
18081
- assignGroupOffsetsAndComputedWidths(item.children);
18082
- }
18083
- groupOffset += itemWidth;
18084
- });
18085
- }
18086
-
18087
18745
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx
18088
18746
  var React46 = __toESM(require("react"));
18089
18747
  var import_react36 = require("react");
@@ -18288,6 +18946,10 @@ function InfiniteTableHeaderGroup(props) {
18288
18946
  horizontalLayoutPageIndex: props.horizontalLayoutPageIndex
18289
18947
  });
18290
18948
  }
18949
+ const groupKey = columnGroup.uniqueGroupId.join(",");
18950
+ const focused = useInfiniteTableSingleValue(
18951
+ (ctx) => ctx.state.focusedHeaderItem?.type === "group" && ctx.state.focusedHeaderItem.key === groupKey
18952
+ );
18291
18953
  const handle = useColumnGroupResizeHandle(columns, {
18292
18954
  bodyBrain,
18293
18955
  groupHeight: height2,
@@ -18311,7 +18973,12 @@ function InfiniteTableHeaderGroup(props) {
18311
18973
  {
18312
18974
  ref: props.domRef,
18313
18975
  "data-group-id": columnGroup.uniqueGroupId,
18314
- className: join(HeaderGroupCls, TableHeaderGroupClassName),
18976
+ tabIndex: -1,
18977
+ className: join(
18978
+ HeaderGroupCls,
18979
+ TableHeaderGroupClassName,
18980
+ focused ? `${TableHeaderGroupClassName}--focused` : ""
18981
+ ),
18315
18982
  style: style2,
18316
18983
  "data-z-index": zIndex2
18317
18984
  },
@@ -18716,13 +19383,29 @@ function TableHeaderWrapper(props) {
18716
19383
  }
18717
19384
  }
18718
19385
  ) : null;
19386
+ const stableContext = useInfiniteTableStableContext();
19387
+ const onFocus = React47.useCallback(
19388
+ (event) => {
19389
+ handleHeaderWrapperFocus(stableContext, event);
19390
+ },
19391
+ []
19392
+ );
19393
+ const onBlur = React47.useCallback(
19394
+ (event) => {
19395
+ handleHeaderWrapperBlur(stableContext, event);
19396
+ },
19397
+ []
19398
+ );
18719
19399
  return /* @__PURE__ */ React47.createElement(
18720
19400
  "div",
18721
19401
  {
18722
19402
  className: `${InfiniteTableHeaderWrapperClassName} ${HeaderWrapperCls}`,
18723
19403
  style: {
18724
19404
  height: height2
18725
- }
19405
+ },
19406
+ tabIndex: 0,
19407
+ onFocus,
19408
+ onBlur
18726
19409
  },
18727
19410
  header,
18728
19411
  verticalScrollbarPlaceholder
@@ -18833,7 +19516,8 @@ function InfiniteTableHeaderCellFn(props) {
18833
19516
  columnHeaderHeight,
18834
19517
  columnReorderDragColumnId,
18835
19518
  columnMenuVisibleForColumnId,
18836
- columnReorderInPageIndex
19519
+ columnReorderInPageIndex,
19520
+ headerFocused
18837
19521
  } = useInfiniteTableSelector((ctx) => {
18838
19522
  return {
18839
19523
  api: ctx.api,
@@ -18847,7 +19531,9 @@ function InfiniteTableHeaderCellFn(props) {
18847
19531
  columnHeaderHeight: ctx.state.columnHeaderHeight,
18848
19532
  columnReorderDragColumnId: ctx.state.columnReorderDragColumnId,
18849
19533
  columnMenuVisibleForColumnId: ctx.state.columnMenuVisibleForColumnId,
18850
- columnReorderInPageIndex: ctx.state.columnReorderInPageIndex
19534
+ columnReorderInPageIndex: ctx.state.columnReorderInPageIndex,
19535
+ // keyboard focus - see headerKeyboardNavigation
19536
+ headerFocused: ctx.state.focusedHeaderItem?.type === "column" && ctx.state.focusedHeaderItem.key === props.column.id
18851
19537
  };
18852
19538
  });
18853
19539
  const dragging = columnReorderDragColumnId === column.id;
@@ -19183,6 +19869,7 @@ function InfiniteTableHeaderCellFn(props) {
19183
19869
  domRef: ref,
19184
19870
  horizontalLayoutPageIndex: props.horizontalLayoutPageIndex,
19185
19871
  cellType: "header",
19872
+ tabIndex: -1,
19186
19873
  column,
19187
19874
  ...dataAttrs,
19188
19875
  "data-z-index": zIndex2,
@@ -19218,7 +19905,9 @@ function InfiniteTableHeaderCellFn(props) {
19218
19905
  treeNode: false,
19219
19906
  groupCell: false,
19220
19907
  groupRow: false,
19221
- rowExpanded: false
19908
+ rowExpanded: false,
19909
+ // keyboard focus - see headerKeyboardNavigation
19910
+ focused: headerFocused
19222
19911
  }
19223
19912
  ),
19224
19913
  CellCls
@@ -21100,6 +21789,15 @@ function handleKeyboardNavigation(options, event) {
21100
21789
  if (!validKeys[key]) {
21101
21790
  return false;
21102
21791
  }
21792
+ if (key === "ArrowUp" && !event.shiftKey) {
21793
+ const onFirstRow = keyboardNavigation === "row" ? activeRowIndex === 0 : keyboardNavigation === "cell" ? activeCellIndex?.[0] === 0 : false;
21794
+ if (onFirstRow && focusHeaderFromBody(
21795
+ options,
21796
+ keyboardNavigation === "cell" ? activeCellIndex[1] : null
21797
+ )) {
21798
+ return true;
21799
+ }
21800
+ }
21103
21801
  if (activeRowIndex != null && keyboardNavigation === "row") {
21104
21802
  return handleRowNavigation(options, event);
21105
21803
  }
@@ -27949,6 +28647,7 @@ function initSetupState2({
27949
28647
  cellContextMenuVisibleFor: null,
27950
28648
  contextMenuVisibleFor: null,
27951
28649
  columnMenuVisibleForColumnId: null,
28650
+ focusedHeaderItem: null,
27952
28651
  columnMenuVisibleKey: 0,
27953
28652
  filterOperatorMenuVisibleForColumnId: null,
27954
28653
  getDOMNodeForCell: (cellPosition) => {
@@ -29686,6 +30385,10 @@ var fieldsToLicenseDetails = (fields) => {
29686
30385
  };
29687
30386
  return details;
29688
30387
  };
30388
+ var FREE_USAGE_MESSAGE = `Thank you for using the Infinite Table free version! Make sure the "Powered by Infinite Table" footer link is visible in your app.
30389
+
30390
+ If you want to remove the footer link, please visit infinite-table.com to purchase a license.`;
30391
+ var freeUsageNoteLogged = false;
29689
30392
  var logLicenseError = (lines, fn = console.error.bind(console)) => {
29690
30393
  lines = ["* * * infinite-table.com * * *", ...lines];
29691
30394
  const max = Math.max(Math.max(...lines.map((l) => l.length)) + 4 * 2, 60);
@@ -29707,6 +30410,15 @@ var checkLicense = (licenseKey = "", packageInfo, fn) => {
29707
30410
  try {
29708
30411
  details = decode(licenseKey);
29709
30412
  } catch (ex) {
30413
+ if (!licenseKey) {
30414
+ if (fn) {
30415
+ fn(FREE_USAGE_MESSAGE);
30416
+ } else if (!freeUsageNoteLogged) {
30417
+ freeUsageNoteLogged = true;
30418
+ console.info(FREE_USAGE_MESSAGE);
30419
+ }
30420
+ return "invalid";
30421
+ }
29710
30422
  logLicenseError(
29711
30423
  [
29712
30424
  `You don't have a valid Infinite Table license`,
@@ -29783,8 +30495,8 @@ function getLicenseStatus(licenseKey = "", options) {
29783
30495
  return "valid";
29784
30496
  }
29785
30497
  const result = checkLicense(licenseKey, {
29786
- publishedAt: 1796056580800,
29787
- version: "11.0.2"
30498
+ publishedAt: 1796226103312,
30499
+ version: "11.1.0"
29788
30500
  });
29789
30501
  if (result === "invalid" && !licenseKey) {
29790
30502
  return "missing";
@@ -29976,26 +30688,6 @@ function handleKeyboardSelection(context, keyboardEvent) {
29976
30688
  return false;
29977
30689
  }
29978
30690
 
29979
- // src/components/InfiniteTable/utils/getFocusableChildrenForNode.ts
29980
- var selector = [
29981
- "input",
29982
- "textarea",
29983
- "select",
29984
- "[tabindex]",
29985
- "a[href]",
29986
- "button",
29987
- "object"
29988
- ].join(", ");
29989
- var getFocusableChildrenForNode = (node) => {
29990
- const children = Array.from(node.querySelectorAll(selector));
29991
- return children.filter(
29992
- (child) => !!child.offsetParent
29993
- );
29994
- };
29995
- var getFirstFocusableChildForNode = (node) => {
29996
- return node.querySelector(selector);
29997
- };
29998
-
29999
30691
  // src/components/InfiniteTable/utils/cellFocusUtils.ts
30000
30692
  var import_binary_search6 = __toESM(require_binary_search());
30001
30693
 
@@ -30133,7 +30825,9 @@ async function focusLastFocusableCell(context) {
30133
30825
  }
30134
30826
  const first = getFirstFocusableChildForNode(cellNode);
30135
30827
  first?.focus();
30828
+ return;
30136
30829
  }
30830
+ context.getState().scrollerDOMRef.current?.focus({ preventScroll: true });
30137
30831
  }
30138
30832
  async function tryScrollToCell([rowIndex, colIndex], context) {
30139
30833
  const { api } = context;
@@ -30185,7 +30879,7 @@ function handleBrowserFocusChangeOnKeyboardNavigation(context, event) {
30185
30879
  return false;
30186
30880
  }
30187
30881
  if (scrollerFocused && direction === -1) {
30188
- return false;
30882
+ return focusLastHeaderTabStop(context);
30189
30883
  }
30190
30884
  const cell = scrollerFocused ? null : selectParent(target, CELL_SELECTOR);
30191
30885
  let rowIndex = null;
@@ -30355,6 +31049,12 @@ async function onKeyDown(context, event) {
30355
31049
  keyDownResult = { ...keyDownResult, ...result };
30356
31050
  }
30357
31051
  }
31052
+ if (isHeaderEventTarget(context, event.target)) {
31053
+ if (!keyDownResult.preventNavigation && handleHeaderKeyDown(context, event)) {
31054
+ event.preventDefault();
31055
+ }
31056
+ return;
31057
+ }
30358
31058
  if (!keyDownResult.preventSelection && handleKeyboardSelection(keyboardHandlerContext, event)) {
30359
31059
  event.preventDefault();
30360
31060
  }