@absreim/react-bootstrap-data-grid-pro 4.6.0 → 4.6.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.
@@ -5,9 +5,11 @@
5
5
  */
6
6
  export interface FocusCoordinates {
7
7
  /**
8
- * The ARIA row index.
8
+ * An index like ARIA row index, except that it is based on the actual
9
+ * position of the row. When pagination is enabled, this value can differ from
10
+ * the ARIA row index.
9
11
  */
10
- ariaRowIndex: number;
12
+ displayRowIndex: number;
11
13
  /**
12
14
  * The ARIA column index.
13
15
  */
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useMemo, useState, } from "react";
2
2
  const startingCoordinates = {
3
3
  ariaColIndex: 1,
4
- ariaRowIndex: 1,
4
+ displayRowIndex: 1,
5
5
  };
6
6
  const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
7
7
  const [coords, setCoords] = useState(startingCoordinates);
@@ -9,14 +9,14 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
9
9
  // be a prop here to update effective coordinates at the appropriate times.
10
10
  const effectiveCoords = useMemo(() => ({
11
11
  ariaColIndex: Math.min(coords.ariaColIndex, numCols),
12
- ariaRowIndex: Math.min(coords.ariaRowIndex, numRows),
13
- }), [coords.ariaColIndex, coords.ariaRowIndex, numCols, numRows]);
12
+ displayRowIndex: Math.min(coords.displayRowIndex, numRows),
13
+ }), [coords.ariaColIndex, coords.displayRowIndex, numCols, numRows]);
14
14
  const currentCellIsSortableHeader = useMemo(() => {
15
- if (coords.ariaRowIndex !== 1) {
15
+ if (coords.displayRowIndex !== 1) {
16
16
  return false;
17
17
  }
18
18
  return sortableColIndices.includes(coords.ariaColIndex);
19
- }, [coords.ariaColIndex, coords.ariaRowIndex, sortableColIndices]);
19
+ }, [coords.ariaColIndex, coords.displayRowIndex, sortableColIndices]);
20
20
  const gridClickHandler = useCallback((event) => {
21
21
  let cursor = event.target;
22
22
  while (cursor !== event.currentTarget &&
@@ -30,26 +30,26 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
30
30
  }
31
31
  const row = cursor.parentElement;
32
32
  setCoords({
33
- ariaColIndex: Number(cursor.getAttribute("aria-colIndex")),
34
- ariaRowIndex: Number(row.getAttribute("aria-rowIndex")),
33
+ ariaColIndex: Number(cursor.getAttribute("aria-colindex")),
34
+ displayRowIndex: Number(row.getAttribute("display-rowindex")),
35
35
  });
36
36
  }, []);
37
37
  const gridKeydownHandler = useCallback((event) => {
38
38
  switch (event.code) {
39
39
  case "ArrowDown": {
40
- if (effectiveCoords.ariaRowIndex !== numRows) {
40
+ if (effectiveCoords.displayRowIndex !== numRows) {
41
41
  setCoords({
42
42
  ariaColIndex: effectiveCoords.ariaColIndex,
43
- ariaRowIndex: effectiveCoords.ariaRowIndex + 1,
43
+ displayRowIndex: effectiveCoords.displayRowIndex + 1,
44
44
  });
45
45
  }
46
46
  break;
47
47
  }
48
48
  case "ArrowUp": {
49
- if (effectiveCoords.ariaRowIndex !== 1) {
49
+ if (effectiveCoords.displayRowIndex !== 1) {
50
50
  setCoords({
51
51
  ariaColIndex: effectiveCoords.ariaColIndex,
52
- ariaRowIndex: effectiveCoords.ariaRowIndex - 1,
52
+ displayRowIndex: effectiveCoords.displayRowIndex - 1,
53
53
  });
54
54
  }
55
55
  break;
@@ -58,7 +58,7 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
58
58
  if (effectiveCoords.ariaColIndex !== 1) {
59
59
  setCoords({
60
60
  ariaColIndex: effectiveCoords.ariaColIndex - 1,
61
- ariaRowIndex: effectiveCoords.ariaRowIndex,
61
+ displayRowIndex: effectiveCoords.displayRowIndex,
62
62
  });
63
63
  }
64
64
  break;
@@ -67,7 +67,7 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
67
67
  if (effectiveCoords.ariaColIndex !== numCols) {
68
68
  setCoords({
69
69
  ariaColIndex: effectiveCoords.ariaColIndex + 1,
70
- ariaRowIndex: effectiveCoords.ariaRowIndex,
70
+ displayRowIndex: effectiveCoords.displayRowIndex,
71
71
  });
72
72
  }
73
73
  break;
@@ -76,13 +76,13 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
76
76
  if (event.ctrlKey || event.metaKey) {
77
77
  setCoords({
78
78
  ariaColIndex: 1,
79
- ariaRowIndex: 1,
79
+ displayRowIndex: 1,
80
80
  });
81
81
  break;
82
82
  }
83
83
  setCoords({
84
84
  ariaColIndex: 1,
85
- ariaRowIndex: effectiveCoords.ariaRowIndex,
85
+ displayRowIndex: effectiveCoords.displayRowIndex,
86
86
  });
87
87
  break;
88
88
  }
@@ -90,13 +90,13 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
90
90
  if (event.ctrlKey || event.metaKey) {
91
91
  setCoords({
92
92
  ariaColIndex: numCols,
93
- ariaRowIndex: numRows,
93
+ displayRowIndex: numRows,
94
94
  });
95
95
  break;
96
96
  }
97
97
  setCoords({
98
98
  ariaColIndex: numCols,
99
- ariaRowIndex: effectiveCoords.ariaRowIndex,
99
+ displayRowIndex: effectiveCoords.displayRowIndex,
100
100
  });
101
101
  break;
102
102
  }
@@ -109,7 +109,7 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
109
109
  // makes in terms of performance vs relying on the useEffect hook.
110
110
  }, [
111
111
  effectiveCoords.ariaColIndex,
112
- effectiveCoords.ariaRowIndex,
112
+ effectiveCoords.displayRowIndex,
113
113
  numCols,
114
114
  numRows,
115
115
  ]);
@@ -123,7 +123,7 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
123
123
  if (!gridRef.current.contains(document.activeElement)) {
124
124
  return;
125
125
  }
126
- const cellSelector = `:scope > div > div[aria-rowindex="${effectiveCoords.ariaRowIndex}"] > div[aria-colindex="${effectiveCoords.ariaColIndex}"]`;
126
+ const cellSelector = `:scope > div > div[display-rowindex="${effectiveCoords.displayRowIndex}"] > div[aria-colindex="${effectiveCoords.ariaColIndex}"]`;
127
127
  const elToFocus = gridRef.current.querySelector(currentCellIsSortableHeader
128
128
  ? cellSelector + " .rbdg-grid-header-button"
129
129
  : cellSelector);
@@ -132,7 +132,7 @@ const useGridFocus = (gridRef, numRows, numCols, sortableColIndices) => {
132
132
  }
133
133
  }, [
134
134
  effectiveCoords.ariaColIndex,
135
- effectiveCoords.ariaRowIndex,
135
+ effectiveCoords.displayRowIndex,
136
136
  gridRef,
137
137
  currentCellIsSortableHeader,
138
138
  ]);
package/grid/main/Grid.js CHANGED
@@ -91,7 +91,7 @@ const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, wid
91
91
  "rbdg-grid-borderless": borders === "none",
92
92
  "rbdg-grid-sm": !!small,
93
93
  "rbdg-grid-group-divider": !!divider,
94
- }, "rbdg-grid", variant && `${CSS_PREFIX}-${variant}`, borderVariant && `border-${borderVariant}`), role: "grid", "aria-colcount": cols.length, "aria-rowcount": filteredRows.length + 1, "data-testid": "rbdg-grid", children: [_jsx(GridHeader, { cols: cols, rowVariant: headerRowVariant, cellVariant: headerCellVariant, vertScrollable: vertScrollable, focusColIndex: effectiveCoords.ariaRowIndex === 1
94
+ }, "rbdg-grid", variant && `${CSS_PREFIX}-${variant}`, borderVariant && `border-${borderVariant}`), role: "grid", "aria-colcount": cols.length, "aria-rowcount": filteredRows.length + 1, "data-testid": "rbdg-grid", children: [_jsx(GridHeader, { cols: cols, rowVariant: headerRowVariant, cellVariant: headerCellVariant, vertScrollable: vertScrollable, focusColIndex: effectiveCoords.displayRowIndex === 1
95
95
  ? effectiveCoords.ariaColIndex
96
96
  : null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
97
97
  const getPagination = (pagination) => {
@@ -4,18 +4,19 @@ import classNames from "classnames";
4
4
  import { CSS_PREFIX, DEFAULT_COL_WIDTH } from "../../common/constants";
5
5
  import { GRID_BODY_DATA_TEST_ID } from "../constants";
6
6
  const GridBody = ({ augFormattedRows, cols, rowVariant, cellVariant, focusCoords, cellFocusVariant, }) => {
7
- return (_jsx("div", { role: "rowgroup", "data-testid": GRID_BODY_DATA_TEST_ID, children: augFormattedRows.map((row, rowDisplayIndex) => {
7
+ return (_jsx("div", { role: "rowgroup", "data-testid": GRID_BODY_DATA_TEST_ID, children: augFormattedRows.map((row, displayRowArrayIndex) => {
8
8
  const ariaRowIndex = row.prePaginationIndex + 2;
9
- return (_jsx("div", { role: "row", "aria-rowindex": ariaRowIndex, className: classNames("d-flex", "flex-row", rowVariant &&
10
- rowVariant(row, rowDisplayIndex) &&
11
- `${CSS_PREFIX}-${rowVariant(row, rowDisplayIndex)}`), children: row.contents.map(({ formattedValue, width }, index) => {
9
+ const displayRowIndex = displayRowArrayIndex + 2;
10
+ return (_jsx("div", { role: "row", "display-rowindex": displayRowIndex, "aria-rowindex": ariaRowIndex, className: classNames("d-flex", "flex-row", rowVariant &&
11
+ rowVariant(row, displayRowArrayIndex) &&
12
+ `${CSS_PREFIX}-${rowVariant(row, displayRowArrayIndex)}`), children: row.contents.map(({ formattedValue, width }, index) => {
12
13
  const ariaColIndex = index + 1;
13
14
  const isFocused = focusCoords.ariaColIndex === ariaColIndex &&
14
- focusCoords.ariaRowIndex === ariaRowIndex;
15
+ focusCoords.displayRowIndex === displayRowIndex;
15
16
  const cellVariantVal = cellVariant &&
16
- cellVariant(row.contents[index], row, index, rowDisplayIndex);
17
+ cellVariant(row.contents[index], row, index, displayRowArrayIndex);
17
18
  const cellFocusVariantVal = cellFocusVariant &&
18
- cellFocusVariant(row.contents[index], row, index, rowDisplayIndex);
19
+ cellFocusVariant(row.contents[index], row, index, displayRowArrayIndex);
19
20
  return (_jsx("div", { tabIndex: isFocused ? 0 : -1, style: getWidthStyles(width || DEFAULT_COL_WIDTH), role: "gridcell", className: classNames("rbdg-grid-cell", cellVariantVal && `${CSS_PREFIX}-${cellVariantVal}`, cellFocusVariantVal && `focus-ring-${cellFocusVariantVal}`, {
20
21
  "z-2": isFocused,
21
22
  "rbdg-focusable-cell": isFocused,
@@ -24,7 +24,7 @@ const GridHeader = ({ cols, vertScrollable, rowVariant, cellVariant, focusColInd
24
24
  }
25
25
  setSortColDef(null);
26
26
  };
27
- return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children: _jsx("div", { role: "row", className: classNames("d-flex", "flex-row", rowVariant && `${CSS_PREFIX}-${rowVariant}`), "aria-rowindex": 1, children: cols.map((col, index) => {
27
+ return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children: _jsx("div", { role: "row", className: classNames("d-flex", "flex-row", rowVariant && `${CSS_PREFIX}-${rowVariant}`), "display-rowindex": 1, "aria-rowindex": 1, children: cols.map((col, index) => {
28
28
  const ariaColIndex = index + 1;
29
29
  const isFocused = focusColIndex === ariaColIndex;
30
30
  const cellVariantVal = cellVariant && cellVariant(col, index);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@absreim/react-bootstrap-data-grid-pro",
3
3
  "description": "Pro Version of data grid UI component for use with web apps using React and Bootstrap",
4
- "version": "4.6.0",
4
+ "version": "4.6.1",
5
5
  "license": "Commercial. See LICENSE file.",
6
6
  "author": "Brook Li",
7
7
  "homepage": "https://react-bootstrap-data-grid.vercel.app/",