@absreim/react-bootstrap-data-grid 4.6.0 → 4.7.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/common/pipeline/internalTypes.d.ts +15 -0
- package/common/pipeline/useCombinedPipeline/index.d.ts +2 -19
- package/common/pipeline/useCombinedPipeline/internalTypes.d.ts +18 -0
- package/common/pipeline/useSelectionFns.d.ts +5 -0
- package/common/pipeline/{useGridSelectionFns.js → useSelectionFns.js} +24 -16
- package/common/selection/getSelectionCheckboxState.d.ts +3 -0
- package/common/selection/getSelectionCheckboxState.js +39 -0
- package/common/selection/internalTypes.d.ts +13 -0
- package/common/selection/types.d.ts +4 -0
- package/common/types.d.ts +6 -0
- package/grid/focus/internalTypes.d.ts +17 -0
- package/grid/focus/internalTypes.js +1 -0
- package/grid/focus/useGridFocus.d.ts +1 -1
- package/grid/focus/useGridFocus.js +20 -20
- package/grid/main/Grid.js +33 -5
- package/grid/main/GridBody.js +64 -19
- package/grid/main/GridHeader.js +33 -16
- package/grid/main/internalTypes.d.ts +29 -1
- package/grid/main/types.d.ts +44 -1
- package/grid/selection/SelectBodyCell.d.ts +4 -0
- package/grid/selection/SelectBodyCell.js +18 -0
- package/grid/selection/SelectHeaderCell.d.ts +4 -0
- package/grid/selection/SelectHeaderCell.js +21 -0
- package/grid/selection/internalTypes.d.ts +13 -0
- package/grid/selection/internalTypes.js +1 -0
- package/grid.css +1 -1
- package/grid.scss +1 -1
- package/package.json +1 -1
- package/table/InternalTable.d.ts +4 -4
- package/table/InternalTable.js +2 -2
- package/table/Table.js +2 -2
- package/table/main/BodyRows.d.ts +4 -4
- package/table/main/BodyRows.js +2 -2
- package/table/selection/SelectAllHeaderCell.js +3 -40
- package/table/selection/SelectionInput.js +1 -1
- package/table/types.d.ts +1 -6
- package/common/pipeline/useGridSelectionFns.d.ts +0 -17
- package/grid/focus/types.d.ts +0 -15
- /package/{grid/focus/types.js → common/pipeline/useCombinedPipeline/internalTypes.js} +0 -0
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { RowId } from "../types";
|
|
2
|
+
import { SelectionInfo } from "../selection/internalTypes";
|
|
3
|
+
import { SelectModel } from "../selection/types";
|
|
4
|
+
import { SelectionInputModel } from "../../table/selection/SelectionInput";
|
|
1
5
|
/**
|
|
2
6
|
* A hash map that associates column name to a width setting.
|
|
3
7
|
*
|
|
4
8
|
* @internal
|
|
5
9
|
*/
|
|
6
10
|
export type ColNameToWidth<ColName extends string = string> = Record<ColName, number | undefined>;
|
|
11
|
+
export interface SelectionFns {
|
|
12
|
+
selectedSet: Set<RowId>;
|
|
13
|
+
rowsAreSelectable: boolean | undefined;
|
|
14
|
+
selectionInfo: SelectionInfo | null;
|
|
15
|
+
selectAllHandler: () => void;
|
|
16
|
+
getSelectHandler: (index: RowId) => () => void;
|
|
17
|
+
getSelectInputModel: (id: RowId, selectModel: SelectModel) => SelectionInputModel;
|
|
18
|
+
getAriaSelectedValue: (id: RowId) => "true" | "false" | undefined;
|
|
19
|
+
getRowSelectHandler: (index: RowId) => () => void;
|
|
20
|
+
getToggleHandler: (index: RowId) => () => void;
|
|
21
|
+
}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { NormalizedTableFilterModel, FilterState } from "../../filtering/internalTypes";
|
|
4
|
-
import { ColDefBase, FormattedRow, RowDef } from "../../types";
|
|
5
|
-
import { TableProps } from "../../../table";
|
|
6
|
-
export type CombinedPipelineParams = Pick<TableProps, "rows" | "filterModel" | "sortModel" | "pagination" | "selectModel"> & {
|
|
7
|
-
cols: ColDefBase[];
|
|
8
|
-
};
|
|
9
|
-
export interface UseCombinedPipelineHook {
|
|
10
|
-
normalizedTableFilterModel: NormalizedTableFilterModel | null;
|
|
11
|
-
filteredRows: RowDef[];
|
|
12
|
-
filterState: FilterState | null;
|
|
13
|
-
sortedRowsOutput: SortedRowsOutput;
|
|
14
|
-
currentPageRowsOutput: CurrentPageRowsOutput;
|
|
15
|
-
showSelectCol: boolean;
|
|
16
|
-
ariaColIndexOffset: number;
|
|
17
|
-
displayRows: FormattedRow[];
|
|
18
|
-
}
|
|
19
|
-
declare const useCombinedPipeline: (params: CombinedPipelineParams) => UseCombinedPipelineHook;
|
|
1
|
+
import { CombinedPipelineOutput, CombinedPipelineParams } from "./internalTypes";
|
|
2
|
+
declare const useCombinedPipeline: (params: CombinedPipelineParams) => CombinedPipelineOutput;
|
|
20
3
|
export default useCombinedPipeline;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FilterState, NormalizedTableFilterModel } from "../../filtering/internalTypes";
|
|
2
|
+
import { ColDefBase, FormattedRow, RowDef } from "../../types";
|
|
3
|
+
import { SortedRowsOutput } from "./useSortedRows";
|
|
4
|
+
import { CurrentPageRowsOutput } from "./useCurrentPageRows";
|
|
5
|
+
import { TableProps } from "../../../table";
|
|
6
|
+
export type CombinedPipelineParams = Pick<TableProps, "rows" | "filterModel" | "sortModel" | "pagination" | "selectModel"> & {
|
|
7
|
+
cols: ColDefBase[];
|
|
8
|
+
};
|
|
9
|
+
export interface CombinedPipelineOutput {
|
|
10
|
+
normalizedTableFilterModel: NormalizedTableFilterModel | null;
|
|
11
|
+
filteredRows: RowDef[];
|
|
12
|
+
filterState: FilterState | null;
|
|
13
|
+
sortedRowsOutput: SortedRowsOutput;
|
|
14
|
+
currentPageRowsOutput: CurrentPageRowsOutput;
|
|
15
|
+
showSelectCol: boolean;
|
|
16
|
+
ariaColIndexOffset: number;
|
|
17
|
+
displayRows: FormattedRow[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SelectModel } from "../selection/types";
|
|
2
|
+
import { RowDef } from "../types";
|
|
3
|
+
import { SelectionFns } from "./internalTypes";
|
|
4
|
+
declare const useSelectionFns: (selectModel: SelectModel | undefined, rows: RowDef[]) => SelectionFns;
|
|
5
|
+
export default useSelectionFns;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useId, useMemo } from "react";
|
|
2
2
|
import isSubset from "../util/isSubset";
|
|
3
|
-
var
|
|
3
|
+
var useSelectionFns = function (selectModel, rows) {
|
|
4
4
|
var selectionExists = useMemo(function () {
|
|
5
5
|
if (!selectModel) {
|
|
6
6
|
return false;
|
|
@@ -10,7 +10,7 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
10
10
|
}
|
|
11
11
|
return selectModel.selected.length > 0;
|
|
12
12
|
}, [selectModel]);
|
|
13
|
-
var
|
|
13
|
+
var selectAllHandler = useCallback(function () {
|
|
14
14
|
if (!selectModel) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -26,9 +26,7 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
26
26
|
var allRowIndices = rows.map(function (_, index) { return index; });
|
|
27
27
|
selectModel.setSelected(allRowIndices);
|
|
28
28
|
}
|
|
29
|
-
//
|
|
30
|
-
// selectModel.type === "single", so function execution should never get
|
|
31
|
-
// to this point.
|
|
29
|
+
// In case of !selectionExists && selectModel.type === "single", do nothing.
|
|
32
30
|
}, [rows, selectModel, selectionExists]);
|
|
33
31
|
var getSelectHandler = function (index) { return function () {
|
|
34
32
|
if (!selectModel) {
|
|
@@ -41,7 +39,11 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
41
39
|
selectModel.setSelected(selectModel.selected.concat(index));
|
|
42
40
|
}; };
|
|
43
41
|
var getDeselectHandler = function (index) { return function () {
|
|
44
|
-
if (!selectModel
|
|
42
|
+
if (!selectModel) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (selectModel.type === "single") {
|
|
46
|
+
selectModel.setSelected(null);
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
selectModel.setSelected(selectModel.selected.filter(function (num) { return num !== index; }));
|
|
@@ -85,8 +87,8 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
85
87
|
}
|
|
86
88
|
var getMultiExistingSelection = function (selectionExists, rows) {
|
|
87
89
|
var rowIndices = rows.map(function (_, index) { return index; });
|
|
88
|
-
// Note that isFullSelection is true if there are no rows at all. In that
|
|
89
|
-
// should be "none", not "full".
|
|
90
|
+
// Note that isFullSelection is true if there are no rows at all. In that
|
|
91
|
+
// case, the return value of this function should be "none", not "full".
|
|
90
92
|
var isFullSelection = isSubset(rowIndices, selectModel.selected);
|
|
91
93
|
if (!selectionExists) {
|
|
92
94
|
return "none";
|
|
@@ -101,15 +103,20 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
101
103
|
existingSelection: getMultiExistingSelection(selectionExists, rows),
|
|
102
104
|
};
|
|
103
105
|
}, [selectModel, selectionExists, rows]);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
// Like getRowSelectHandler, but also works when the mode is `"column"`.
|
|
107
|
+
// Useful if column selection is enforced externally.
|
|
108
|
+
var getToggleHandler = function (rowId) { return function () {
|
|
109
|
+
if (selectedSet.has(rowId)) {
|
|
110
|
+
getDeselectHandler(rowId)();
|
|
106
111
|
return;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
getSelectHandler(rowId)();
|
|
114
|
+
}; };
|
|
115
|
+
var getRowSelectHandler = function (rowId) { return function () {
|
|
116
|
+
if (!rowsAreSelectable) {
|
|
110
117
|
return;
|
|
111
118
|
}
|
|
112
|
-
|
|
119
|
+
getToggleHandler(rowId)();
|
|
113
120
|
}; };
|
|
114
121
|
var getAriaSelectedValue = function (id) {
|
|
115
122
|
if (!selectModel) {
|
|
@@ -121,11 +128,12 @@ var useGridSelectionFns = function (selectModel, rows) {
|
|
|
121
128
|
selectedSet: selectedSet,
|
|
122
129
|
rowsAreSelectable: rowsAreSelectable,
|
|
123
130
|
selectionInfo: selectionInfo,
|
|
124
|
-
|
|
131
|
+
selectAllHandler: selectAllHandler,
|
|
125
132
|
getSelectHandler: getSelectHandler,
|
|
126
133
|
getSelectInputModel: getSelectInputModel,
|
|
127
|
-
getRowClickHandler: getRowClickHandler,
|
|
128
134
|
getAriaSelectedValue: getAriaSelectedValue,
|
|
135
|
+
getRowSelectHandler: getRowSelectHandler,
|
|
136
|
+
getToggleHandler: getToggleHandler,
|
|
129
137
|
};
|
|
130
138
|
};
|
|
131
|
-
export default
|
|
139
|
+
export default useSelectionFns;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var getSelectionCheckboxState = function (selectionInfo, noRows) {
|
|
2
|
+
var disabledState = {
|
|
3
|
+
indeterminate: false,
|
|
4
|
+
checked: false,
|
|
5
|
+
disabled: true,
|
|
6
|
+
description: "Select all (disabled)",
|
|
7
|
+
};
|
|
8
|
+
if (noRows) {
|
|
9
|
+
return disabledState;
|
|
10
|
+
}
|
|
11
|
+
var existingSelection = selectionInfo.existingSelection;
|
|
12
|
+
if (existingSelection === "full") {
|
|
13
|
+
return {
|
|
14
|
+
indeterminate: false,
|
|
15
|
+
checked: true,
|
|
16
|
+
disabled: false,
|
|
17
|
+
description: "Deselect all rows",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (existingSelection === true || existingSelection === "partial") {
|
|
21
|
+
return {
|
|
22
|
+
indeterminate: true,
|
|
23
|
+
checked: true,
|
|
24
|
+
disabled: false,
|
|
25
|
+
description: "Deselect all rows",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (existingSelection === "none") {
|
|
29
|
+
return {
|
|
30
|
+
indeterminate: false,
|
|
31
|
+
checked: false,
|
|
32
|
+
disabled: false,
|
|
33
|
+
description: "Select all rows",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// single select mode and none selected
|
|
37
|
+
return disabledState;
|
|
38
|
+
};
|
|
39
|
+
export default getSelectionCheckboxState;
|
|
@@ -32,3 +32,16 @@ export interface MultiSelectionInfo {
|
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
34
|
export type SelectionInfo = SingleSelectionInfo | MultiSelectionInfo;
|
|
35
|
+
/**
|
|
36
|
+
* Describes the state of a checkbox can be set to be indeterminate in addition
|
|
37
|
+
* to the being disabled. Useful for the select all header cell checkbox common
|
|
38
|
+
* to both the table and grid.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export interface CheckboxState {
|
|
43
|
+
indeterminate: boolean;
|
|
44
|
+
checked: boolean;
|
|
45
|
+
disabled: boolean;
|
|
46
|
+
description: string;
|
|
47
|
+
}
|
|
@@ -86,6 +86,10 @@ export interface SingleSelectState {
|
|
|
86
86
|
* can be used to generate an ID.
|
|
87
87
|
*
|
|
88
88
|
* @defaultValue `undefined` - an id generated by the useId hook will be used
|
|
89
|
+
*
|
|
90
|
+
* @deprecated explicitly specifying the group name seems to serve no real
|
|
91
|
+
* purpose. This field may be removed in a future major release to rely on
|
|
92
|
+
* {@link https://react.dev/reference/react/useId | useId} instead.
|
|
89
93
|
*/
|
|
90
94
|
groupName?: string;
|
|
91
95
|
}
|
package/common/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SortModel } from "./sorting/types";
|
|
2
2
|
import { FilterModel } from "./filtering/types";
|
|
3
|
+
import { SelectModel } from "./selection/types";
|
|
3
4
|
/**
|
|
4
5
|
* Union of all possible column data types.
|
|
5
6
|
*
|
|
@@ -151,6 +152,11 @@ export interface MainComponentSharedProps {
|
|
|
151
152
|
* @defaultValue `undefined` - Filtering will not be enabled.
|
|
152
153
|
*/
|
|
153
154
|
filterModel?: FilterModel;
|
|
155
|
+
/**
|
|
156
|
+
* The select model of the table. Passing a truthy value enables the
|
|
157
|
+
* selection feature of the component.
|
|
158
|
+
*/
|
|
159
|
+
selectModel?: SelectModel;
|
|
154
160
|
}
|
|
155
161
|
/**
|
|
156
162
|
* {@link RowDef} object that additionally contains the index of the row in the
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid cell coordinates based on ARIA row index and column index.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export interface FocusCoordinates {
|
|
7
|
+
/**
|
|
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.
|
|
11
|
+
*/
|
|
12
|
+
displayRowIndex: number;
|
|
13
|
+
/**
|
|
14
|
+
* The ARIA column index.
|
|
15
|
+
*/
|
|
16
|
+
ariaColIndex: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyboardEventHandler, PointerEventHandler, RefObject } from "react";
|
|
2
|
-
import { FocusCoordinates } from "./
|
|
2
|
+
import { FocusCoordinates } from "./internalTypes";
|
|
3
3
|
export interface GridFocusOutput {
|
|
4
4
|
effectiveCoords: FocusCoordinates;
|
|
5
5
|
gridClickHandler: PointerEventHandler<HTMLDivElement>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState, } from "react";
|
|
2
2
|
var startingCoordinates = {
|
|
3
3
|
ariaColIndex: 1,
|
|
4
|
-
|
|
4
|
+
displayRowIndex: 1,
|
|
5
5
|
};
|
|
6
6
|
var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
7
7
|
var _a = useState(startingCoordinates), coords = _a[0], setCoords = _a[1];
|
|
@@ -9,14 +9,14 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
9
9
|
// be a prop here to update effective coordinates at the appropriate times.
|
|
10
10
|
var effectiveCoords = useMemo(function () { return ({
|
|
11
11
|
ariaColIndex: Math.min(coords.ariaColIndex, numCols),
|
|
12
|
-
|
|
13
|
-
}); }, [coords.ariaColIndex, coords.
|
|
12
|
+
displayRowIndex: Math.min(coords.displayRowIndex, numRows),
|
|
13
|
+
}); }, [coords.ariaColIndex, coords.displayRowIndex, numCols, numRows]);
|
|
14
14
|
var currentCellIsSortableHeader = useMemo(function () {
|
|
15
|
-
if (coords.
|
|
15
|
+
if (coords.displayRowIndex !== 1) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
return sortableColIndices.includes(coords.ariaColIndex);
|
|
19
|
-
}, [coords.ariaColIndex, coords.
|
|
19
|
+
}, [coords.ariaColIndex, coords.displayRowIndex, sortableColIndices]);
|
|
20
20
|
var gridClickHandler = useCallback(function (event) {
|
|
21
21
|
var cursor = event.target;
|
|
22
22
|
while (cursor !== event.currentTarget &&
|
|
@@ -30,26 +30,26 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
30
30
|
}
|
|
31
31
|
var row = cursor.parentElement;
|
|
32
32
|
setCoords({
|
|
33
|
-
ariaColIndex: Number(cursor.getAttribute("aria-
|
|
34
|
-
|
|
33
|
+
ariaColIndex: Number(cursor.getAttribute("aria-colindex")),
|
|
34
|
+
displayRowIndex: Number(row.getAttribute("display-rowindex")),
|
|
35
35
|
});
|
|
36
36
|
}, []);
|
|
37
37
|
var gridKeydownHandler = useCallback(function (event) {
|
|
38
38
|
switch (event.code) {
|
|
39
39
|
case "ArrowDown": {
|
|
40
|
-
if (effectiveCoords.
|
|
40
|
+
if (effectiveCoords.displayRowIndex !== numRows) {
|
|
41
41
|
setCoords({
|
|
42
42
|
ariaColIndex: effectiveCoords.ariaColIndex,
|
|
43
|
-
|
|
43
|
+
displayRowIndex: effectiveCoords.displayRowIndex + 1,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
case "ArrowUp": {
|
|
49
|
-
if (effectiveCoords.
|
|
49
|
+
if (effectiveCoords.displayRowIndex !== 1) {
|
|
50
50
|
setCoords({
|
|
51
51
|
ariaColIndex: effectiveCoords.ariaColIndex,
|
|
52
|
-
|
|
52
|
+
displayRowIndex: effectiveCoords.displayRowIndex - 1,
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
break;
|
|
@@ -58,7 +58,7 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
58
58
|
if (effectiveCoords.ariaColIndex !== 1) {
|
|
59
59
|
setCoords({
|
|
60
60
|
ariaColIndex: effectiveCoords.ariaColIndex - 1,
|
|
61
|
-
|
|
61
|
+
displayRowIndex: effectiveCoords.displayRowIndex,
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
break;
|
|
@@ -67,7 +67,7 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
67
67
|
if (effectiveCoords.ariaColIndex !== numCols) {
|
|
68
68
|
setCoords({
|
|
69
69
|
ariaColIndex: effectiveCoords.ariaColIndex + 1,
|
|
70
|
-
|
|
70
|
+
displayRowIndex: effectiveCoords.displayRowIndex,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
break;
|
|
@@ -76,13 +76,13 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
76
76
|
if (event.ctrlKey || event.metaKey) {
|
|
77
77
|
setCoords({
|
|
78
78
|
ariaColIndex: 1,
|
|
79
|
-
|
|
79
|
+
displayRowIndex: 1,
|
|
80
80
|
});
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
setCoords({
|
|
84
84
|
ariaColIndex: 1,
|
|
85
|
-
|
|
85
|
+
displayRowIndex: effectiveCoords.displayRowIndex,
|
|
86
86
|
});
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
@@ -90,13 +90,13 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
90
90
|
if (event.ctrlKey || event.metaKey) {
|
|
91
91
|
setCoords({
|
|
92
92
|
ariaColIndex: numCols,
|
|
93
|
-
|
|
93
|
+
displayRowIndex: numRows,
|
|
94
94
|
});
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
setCoords({
|
|
98
98
|
ariaColIndex: numCols,
|
|
99
|
-
|
|
99
|
+
displayRowIndex: effectiveCoords.displayRowIndex,
|
|
100
100
|
});
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
@@ -109,7 +109,7 @@ var useGridFocus = function (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.
|
|
112
|
+
effectiveCoords.displayRowIndex,
|
|
113
113
|
numCols,
|
|
114
114
|
numRows,
|
|
115
115
|
]);
|
|
@@ -123,7 +123,7 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
123
123
|
if (!gridRef.current.contains(document.activeElement)) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
var cellSelector = ":scope > div > div[
|
|
126
|
+
var cellSelector = ":scope > div > div[display-rowindex=\"".concat(effectiveCoords.displayRowIndex, "\"] > div[aria-colindex=\"").concat(effectiveCoords.ariaColIndex, "\"]");
|
|
127
127
|
var elToFocus = gridRef.current.querySelector(currentCellIsSortableHeader
|
|
128
128
|
? cellSelector + " .rbdg-grid-header-button"
|
|
129
129
|
: cellSelector);
|
|
@@ -132,7 +132,7 @@ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
|
|
|
132
132
|
}
|
|
133
133
|
}, [
|
|
134
134
|
effectiveCoords.ariaColIndex,
|
|
135
|
-
effectiveCoords.
|
|
135
|
+
effectiveCoords.displayRowIndex,
|
|
136
136
|
gridRef,
|
|
137
137
|
currentCellIsSortableHeader,
|
|
138
138
|
]);
|
package/grid/main/Grid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useRef, } from "react";
|
|
3
|
+
import { useCallback, useId, useMemo, useRef, } from "react";
|
|
4
4
|
import useCombinedPipeline from "../../common/pipeline/useCombinedPipeline";
|
|
5
5
|
import useAugFormattedRows from "../../common/pipeline/useAugFormattedRows";
|
|
6
6
|
import useColNameToWidth from "../../common/pipeline/useColNameToWidth";
|
|
@@ -13,6 +13,8 @@ import Pagination from "../../common/pagination/Pagination";
|
|
|
13
13
|
import useExportFn from "../../common/export/useExportFn";
|
|
14
14
|
import useInterfaces from "../../common/toolbar/useInterfaces";
|
|
15
15
|
import ToolbarContainer from "../../common/toolbar/ToolbarContainer";
|
|
16
|
+
import useSelectionFns from "../../common/pipeline/useSelectionFns";
|
|
17
|
+
import getSelectionCheckboxState from "../../common/selection/getSelectionCheckboxState";
|
|
16
18
|
/**
|
|
17
19
|
* The main component for the grid feature of react-bootstrap-data-grid.
|
|
18
20
|
*
|
|
@@ -20,7 +22,7 @@ import ToolbarContainer from "../../common/toolbar/ToolbarContainer";
|
|
|
20
22
|
*/
|
|
21
23
|
var Grid = function (_a) {
|
|
22
24
|
var _b, _c, _d;
|
|
23
|
-
var rows = _a.rows, cols = _a.cols, sortModel = _a.sortModel, pagination = _a.pagination, allowExport = _a.allowExport, filterModel = _a.filterModel, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant, styleOptions = _a.styleOptions;
|
|
25
|
+
var rows = _a.rows, cols = _a.cols, sortModel = _a.sortModel, pagination = _a.pagination, allowExport = _a.allowExport, filterModel = _a.filterModel, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant, styleOptions = _a.styleOptions, selectModel = _a.selectModel, bodySelectionCellVariant = _a.bodySelectionCellVariant, bodySelectionCellFocusVariant = _a.bodySelectionCellFocusVariant, headerSelectionCellVariant = _a.headerSelectionCellVariant, headerSelectionCellFocusVariant = _a.headerSelectionCellFocusVariant;
|
|
24
26
|
var _e = useCombinedPipeline({
|
|
25
27
|
rows: rows,
|
|
26
28
|
cols: cols,
|
|
@@ -61,12 +63,14 @@ var Grid = function (_a) {
|
|
|
61
63
|
var heightProperties = getHeightProperties(height);
|
|
62
64
|
var vertScrollable = height !== undefined && height !== "auto";
|
|
63
65
|
var gridRef = useRef(null);
|
|
66
|
+
var ariaColIndexOffset = selectModel && selectModel.mode !== "row" ? 1 : 0;
|
|
64
67
|
var sortableColIndices = sortModel
|
|
65
68
|
? cols
|
|
66
69
|
.map(function (_, index) { return index + 1; })
|
|
67
70
|
.filter(function (ariaColIndex) { return cols[ariaColIndex - 1].sortable; })
|
|
71
|
+
.map(function (ariaColIndex) { return ariaColIndex + ariaColIndexOffset; })
|
|
68
72
|
: [];
|
|
69
|
-
var _g = useGridFocus(gridRef, displayRows.length + 1, cols.length, sortableColIndices), effectiveCoords = _g.effectiveCoords, gridClickHandler = _g.gridClickHandler, gridKeydownHandler = _g.gridKeydownHandler;
|
|
73
|
+
var _g = useGridFocus(gridRef, displayRows.length + 1, cols.length + ariaColIndexOffset, sortableColIndices), effectiveCoords = _g.effectiveCoords, gridClickHandler = _g.gridClickHandler, gridKeydownHandler = _g.gridKeydownHandler;
|
|
70
74
|
var onCopy = useCallback(function (event) {
|
|
71
75
|
var _a;
|
|
72
76
|
if (!((_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))) {
|
|
@@ -79,6 +83,30 @@ var Grid = function (_a) {
|
|
|
79
83
|
event.preventDefault();
|
|
80
84
|
event.clipboardData.setData("text/plain", selection.focusNode.textContent);
|
|
81
85
|
}, []);
|
|
86
|
+
var _h = useSelectionFns(selectModel, rows), getToggleHandler = _h.getToggleHandler, selectedSet = _h.selectedSet, selectAllHandler = _h.selectAllHandler, selectionInfo = _h.selectionInfo;
|
|
87
|
+
var getRowIsSelected = useCallback(function (id) { return selectedSet.has(id); }, [selectedSet]);
|
|
88
|
+
var headerSelectionInfo = useMemo(function () {
|
|
89
|
+
if (!selectModel) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
mode: selectModel.mode,
|
|
94
|
+
selectAllHandler: selectAllHandler,
|
|
95
|
+
selectCheckboxState: getSelectionCheckboxState(selectionInfo, rows.length === 0),
|
|
96
|
+
};
|
|
97
|
+
}, [rows.length, selectAllHandler, selectModel, selectionInfo]);
|
|
98
|
+
var bodySelectionInfo = useMemo(function () {
|
|
99
|
+
if (!selectModel) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
type: selectModel.type,
|
|
104
|
+
mode: selectModel.mode,
|
|
105
|
+
getRowIsSelected: getRowIsSelected,
|
|
106
|
+
getToggleHandler: getToggleHandler,
|
|
107
|
+
};
|
|
108
|
+
}, [getRowIsSelected, getToggleHandler, selectModel]);
|
|
109
|
+
var gridId = useId();
|
|
82
110
|
var mainGridComponent = (_jsxs("div", { onCopy: onCopy, onClick: gridClickHandler, onKeyDown: gridKeydownHandler, ref: gridRef, style: {
|
|
83
111
|
width: widthProperty,
|
|
84
112
|
height: heightProperties.mainDiv,
|
|
@@ -92,9 +120,9 @@ var Grid = function (_a) {
|
|
|
92
120
|
"rbdg-grid-borderless": borders === "none",
|
|
93
121
|
"rbdg-grid-sm": !!small,
|
|
94
122
|
"rbdg-grid-group-divider": !!divider,
|
|
95
|
-
}, "rbdg-grid", variant && "".concat(CSS_PREFIX, "-").concat(variant), borderVariant && "border-".concat(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.
|
|
123
|
+
}, "rbdg-grid", variant && "".concat(CSS_PREFIX, "-").concat(variant), borderVariant && "border-".concat(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
|
|
96
124
|
? effectiveCoords.ariaColIndex
|
|
97
|
-
: null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
|
|
125
|
+
: null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput, selectionInfo: headerSelectionInfo, selectionCellVariant: headerSelectionCellVariant, selectionCellFocusVariant: headerSelectionCellFocusVariant }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant, selectionInfo: bodySelectionInfo, gridId: gridId, selectionCellVariant: bodySelectionCellVariant, selectionCellFocusVariant: bodySelectionCellFocusVariant })] }));
|
|
98
126
|
var getPagination = function (pagination) {
|
|
99
127
|
var _a, _b, _c, _d;
|
|
100
128
|
return (_jsx(Pagination, { containerDivClasses: [
|
package/grid/main/GridBody.js
CHANGED
|
@@ -1,28 +1,73 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import getWidthStyles from "./getWidthStyles";
|
|
3
3
|
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
|
+
import SelectBodyCell from "../selection/SelectBodyCell";
|
|
6
7
|
var GridBody = function (_a) {
|
|
7
|
-
var augFormattedRows = _a.augFormattedRows, cols = _a.cols, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusCoords = _a.focusCoords, cellFocusVariant = _a.cellFocusVariant;
|
|
8
|
-
|
|
8
|
+
var augFormattedRows = _a.augFormattedRows, cols = _a.cols, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusCoords = _a.focusCoords, cellFocusVariant = _a.cellFocusVariant, selectionInfo = _a.selectionInfo, gridId = _a.gridId, selectionCellVariant = _a.selectionCellVariant, selectionCellFocusVariant = _a.selectionCellFocusVariant;
|
|
9
|
+
var getRowKeydownHandler = !selectionInfo
|
|
10
|
+
? null
|
|
11
|
+
: function (id) {
|
|
12
|
+
return function (event) {
|
|
13
|
+
switch (event.code) {
|
|
14
|
+
case "Space": {
|
|
15
|
+
selectionInfo.getToggleHandler(id)();
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
default:
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
function getSelectCellContent(rowId, displayRowIndex, displayRowArrayIndex, row) {
|
|
24
|
+
if (!selectionInfo || selectionInfo.mode === "row") {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var isFocused = focusCoords.ariaColIndex === 1 &&
|
|
28
|
+
focusCoords.displayRowIndex === displayRowIndex;
|
|
29
|
+
var cellVariantVal = selectionCellVariant && selectionCellVariant(row, displayRowArrayIndex);
|
|
30
|
+
var cellFocusVariantVal = selectionCellFocusVariant &&
|
|
31
|
+
selectionCellFocusVariant(row, displayRowArrayIndex);
|
|
32
|
+
var rowIsSelected = selectionInfo.getRowIsSelected(rowId);
|
|
33
|
+
var ariaRowIndex = row.prePaginationIndex + 2;
|
|
34
|
+
return (_jsx(SelectBodyCell, { handleSelect: selectionInfo && selectionInfo.mode === "column"
|
|
35
|
+
? selectionInfo.getToggleHandler(rowId)
|
|
36
|
+
: undefined, isSelected: rowIsSelected, selectType: selectionInfo.type, radioGroup: gridId, tabIndex: isFocused ? 0 : -1, className: classNames("rbdg-grid-cell", cellVariantVal && "".concat(CSS_PREFIX, "-").concat(cellVariantVal), cellFocusVariantVal && "focus-ring-".concat(cellFocusVariantVal), {
|
|
37
|
+
"z-2": isFocused,
|
|
38
|
+
"rbdg-focusable-cell": isFocused,
|
|
39
|
+
"rbdg-grid-active": rowIsSelected,
|
|
40
|
+
}), label: "Select row ".concat(ariaRowIndex) }));
|
|
41
|
+
}
|
|
42
|
+
return (_jsx("div", { role: "rowgroup", "data-testid": GRID_BODY_DATA_TEST_ID, children: augFormattedRows.map(function (row, displayRowArrayIndex) {
|
|
9
43
|
var ariaRowIndex = row.prePaginationIndex + 2;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
var displayRowIndex = displayRowArrayIndex + 2;
|
|
45
|
+
var rowIsSelected = selectionInfo
|
|
46
|
+
? selectionInfo.getRowIsSelected(row.id)
|
|
47
|
+
: undefined;
|
|
48
|
+
return (_jsxs("div", { role: "row", "display-rowindex": displayRowIndex, "aria-selected": rowIsSelected, "aria-rowindex": ariaRowIndex, className: classNames("d-flex", "flex-row", rowVariant &&
|
|
49
|
+
rowVariant(row, displayRowArrayIndex) &&
|
|
50
|
+
"".concat(CSS_PREFIX, "-").concat(rowVariant(row, displayRowArrayIndex))), onClick: !selectionInfo || selectionInfo.mode === "column"
|
|
51
|
+
? undefined
|
|
52
|
+
: selectionInfo.getToggleHandler(row.id), onKeyDown: !selectionInfo || selectionInfo.mode === "column"
|
|
53
|
+
? undefined
|
|
54
|
+
: getRowKeydownHandler(row.id), children: [getSelectCellContent(row.id, displayRowIndex, displayRowArrayIndex, row), row.contents.map(function (_a, index) {
|
|
55
|
+
var formattedValue = _a.formattedValue, width = _a.width;
|
|
56
|
+
var ariaColIndex = index +
|
|
57
|
+
1 +
|
|
58
|
+
(selectionInfo && selectionInfo.mode !== "row" ? 1 : 0);
|
|
59
|
+
var isFocused = focusCoords.ariaColIndex === ariaColIndex &&
|
|
60
|
+
focusCoords.displayRowIndex === displayRowIndex;
|
|
61
|
+
var cellVariantVal = cellVariant &&
|
|
62
|
+
cellVariant(row.contents[index], row, index, displayRowArrayIndex);
|
|
63
|
+
var cellFocusVariantVal = cellFocusVariant &&
|
|
64
|
+
cellFocusVariant(row.contents[index], row, index, displayRowArrayIndex);
|
|
65
|
+
return (_jsx("div", { tabIndex: isFocused ? 0 : -1, style: getWidthStyles(width || DEFAULT_COL_WIDTH), role: "gridcell", className: classNames("rbdg-grid-cell", cellVariantVal && "".concat(CSS_PREFIX, "-").concat(cellVariantVal), cellFocusVariantVal && "focus-ring-".concat(cellFocusVariantVal), {
|
|
66
|
+
"z-2": isFocused,
|
|
67
|
+
"rbdg-focusable-cell": isFocused,
|
|
68
|
+
"rbdg-grid-active": rowIsSelected,
|
|
69
|
+
}), "aria-colindex": ariaColIndex, children: formattedValue }, cols[index].name));
|
|
70
|
+
})] }, row.id));
|
|
26
71
|
}) }));
|
|
27
72
|
};
|
|
28
73
|
export default GridBody;
|
package/grid/main/GridHeader.js
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import getWidthStyles from "./getWidthStyles";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { CSS_PREFIX, DEFAULT_COL_WIDTH } from "../../common/constants";
|
|
5
5
|
import { GRID_HEADER_DATA_TEST_ID } from "../constants";
|
|
6
6
|
import HeaderToggleButton from "../sort/HeaderToggleButton";
|
|
7
7
|
import sortOrderToAriaSort from "../../common/sorting/sortOrderToAriaSort";
|
|
8
|
+
import SelectHeaderCell from "../selection/SelectHeaderCell";
|
|
8
9
|
var GridHeader = function (_a) {
|
|
9
|
-
var cols = _a.cols, vertScrollable = _a.vertScrollable, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusColIndex = _a.focusColIndex, cellFocusVariant = _a.cellFocusVariant, sortInfo = _a.sortInfo;
|
|
10
|
+
var cols = _a.cols, vertScrollable = _a.vertScrollable, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusColIndex = _a.focusColIndex, cellFocusVariant = _a.cellFocusVariant, sortInfo = _a.sortInfo, selectionInfo = _a.selectionInfo, selectionCellVariant = _a.selectionCellVariant, selectionCellFocusVariant = _a.selectionCellFocusVariant;
|
|
11
|
+
var onKeyDown = selectionInfo === undefined
|
|
12
|
+
? undefined
|
|
13
|
+
: function (event) {
|
|
14
|
+
switch (event.code) {
|
|
15
|
+
case "Space": {
|
|
16
|
+
selectionInfo.selectAllHandler();
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
10
23
|
var sortingEnabled = sortInfo.sortingEnabled, sortColDef = sortInfo.sortColDef, setSortColDef = sortInfo.setSortColDef;
|
|
11
24
|
var getSortButtonListener = function (colName) { return function () {
|
|
12
25
|
if ((sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) !== colName) {
|
|
@@ -25,19 +38,23 @@ var GridHeader = function (_a) {
|
|
|
25
38
|
}
|
|
26
39
|
setSortColDef(null);
|
|
27
40
|
}; };
|
|
28
|
-
return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), onKeyDown: selectionInfo && selectionInfo.mode !== "column" ? onKeyDown : undefined, children: _jsxs("div", { role: "row", className: classNames("d-flex", "flex-row", rowVariant && "".concat(CSS_PREFIX, "-").concat(rowVariant)), "display-rowindex": 1, "aria-rowindex": 1, children: [selectionInfo && selectionInfo.mode !== "row" && (_jsx(SelectHeaderCell, { handleSelectAll: selectionInfo.selectAllHandler, checkboxState: selectionInfo.selectCheckboxState, tabIndex: focusColIndex === 1 ? 0 : -1, className: classNames("rbdg-grid-cell", selectionCellVariant && "".concat(CSS_PREFIX, "-").concat(selectionCellVariant), selectionCellFocusVariant &&
|
|
42
|
+
"focus-ring-".concat(selectionCellFocusVariant), {
|
|
43
|
+
"rbdg-focusable-cell": focusColIndex === 1,
|
|
44
|
+
"z-2": focusColIndex === 1,
|
|
45
|
+
}) })), cols.map(function (col, index) {
|
|
46
|
+
var ariaColIndex = index + 1 + (selectionInfo && selectionInfo.mode !== "row" ? 1 : 0);
|
|
47
|
+
var isFocused = focusColIndex === ariaColIndex;
|
|
48
|
+
var cellVariantVal = cellVariant && cellVariant(col, index);
|
|
49
|
+
var cellFocusVariantVal = cellFocusVariant && cellFocusVariant(col, index);
|
|
50
|
+
var currentColSortingEnabled = sortingEnabled && col.sortable;
|
|
51
|
+
return (_jsx("div", { tabIndex: isFocused && !currentColSortingEnabled ? 0 : -1, className: classNames("rbdg-grid-cell", "fw-bold", cellVariantVal && "".concat(CSS_PREFIX, "-").concat(cellVariantVal), cellFocusVariantVal && "focus-ring-".concat(cellFocusVariantVal), {
|
|
52
|
+
"z-2": isFocused,
|
|
53
|
+
"rbdg-focusable-cell": isFocused && !currentColSortingEnabled,
|
|
54
|
+
"rbdg-sortable-header-cell": currentColSortingEnabled,
|
|
55
|
+
}), role: "columnheader", "aria-colindex": ariaColIndex, "aria-sort": currentColSortingEnabled && (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === col.name
|
|
56
|
+
? sortOrderToAriaSort(sortColDef.order)
|
|
57
|
+
: undefined, style: getWidthStyles(col.width || DEFAULT_COL_WIDTH), children: currentColSortingEnabled ? (_jsx(HeaderToggleButton, { tabIndex: isFocused ? 0 : -1, colLabel: col.label, sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === col.name ? sortColDef.order : null, onClick: getSortButtonListener(col.name) })) : (col.label) }, col.name));
|
|
58
|
+
})] }) }));
|
|
42
59
|
};
|
|
43
60
|
export default GridHeader;
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { AugFormattedRow } from "../../common/internalTypes";
|
|
2
|
-
import { FocusCoordinates } from "../focus/
|
|
2
|
+
import { FocusCoordinates } from "../focus/internalTypes";
|
|
3
3
|
import { GridProps } from "./types";
|
|
4
4
|
import { SortedRowsOutput } from "../../common/pipeline/useCombinedPipeline/useSortedRows";
|
|
5
|
+
import { RowId, SelectMode } from "../../common";
|
|
6
|
+
import { CheckboxState } from "../../common/selection/internalTypes";
|
|
7
|
+
export interface GridHeaderSelectionInfo {
|
|
8
|
+
mode: SelectMode;
|
|
9
|
+
selectAllHandler: () => void;
|
|
10
|
+
selectCheckboxState: CheckboxState;
|
|
11
|
+
}
|
|
12
|
+
export interface GridBodySelectionInfo {
|
|
13
|
+
type: "single" | "multi";
|
|
14
|
+
mode: SelectMode;
|
|
15
|
+
getRowIsSelected: (id: RowId) => boolean;
|
|
16
|
+
getToggleHandler: (id: RowId) => () => void;
|
|
17
|
+
}
|
|
5
18
|
/**
|
|
6
19
|
* Props interface for the GridHeader component
|
|
7
20
|
*
|
|
@@ -15,6 +28,13 @@ export interface GridHeaderProps {
|
|
|
15
28
|
focusColIndex: number | null;
|
|
16
29
|
cellFocusVariant?: GridProps["headerCellFocusVariant"];
|
|
17
30
|
sortInfo: Omit<SortedRowsOutput, "sortedRows">;
|
|
31
|
+
selectionCellVariant?: GridProps["headerSelectionCellVariant"];
|
|
32
|
+
selectionCellFocusVariant?: GridProps["headerSelectionCellFocusVariant"];
|
|
33
|
+
/**
|
|
34
|
+
* `undefined` value for ths prop means that selection is disabled for the
|
|
35
|
+
* grid.
|
|
36
|
+
*/
|
|
37
|
+
selectionInfo?: GridHeaderSelectionInfo;
|
|
18
38
|
}
|
|
19
39
|
/**
|
|
20
40
|
* Props interface for the GridBody component
|
|
@@ -28,4 +48,12 @@ export type GridBodyProps = {
|
|
|
28
48
|
cellVariant?: GridProps["bodyCellVariant"];
|
|
29
49
|
focusCoords: FocusCoordinates;
|
|
30
50
|
cellFocusVariant?: GridProps["bodyCellFocusVariant"];
|
|
51
|
+
selectionCellVariant?: GridProps["bodySelectionCellVariant"];
|
|
52
|
+
selectionCellFocusVariant?: GridProps["bodySelectionCellFocusVariant"];
|
|
53
|
+
/**
|
|
54
|
+
* `undefined` value for ths prop means that selection is disabled for the
|
|
55
|
+
* grid.
|
|
56
|
+
*/
|
|
57
|
+
selectionInfo?: GridBodySelectionInfo;
|
|
58
|
+
gridId: string;
|
|
31
59
|
};
|
package/grid/main/types.d.ts
CHANGED
|
@@ -30,6 +30,21 @@ export type BodyCellVariantFn = (cell: CellData, row: FormattedRow, colIndex: nu
|
|
|
30
30
|
* @public
|
|
31
31
|
*/
|
|
32
32
|
export type HeaderCellVariantFn = (col: ColDef, colIndex: number) => string | null;
|
|
33
|
+
/**
|
|
34
|
+
* The type of the function used to specify color variants on a grid body on a
|
|
35
|
+
* per-row level of granularity.
|
|
36
|
+
*
|
|
37
|
+
* @param row - details about the row
|
|
38
|
+
* @param displayIndex - the zero-based index of the row that the cell is in.
|
|
39
|
+
* The index is based on how the cell is actually displayed after pagination,
|
|
40
|
+
* filtering, and sorting are applied.
|
|
41
|
+
*
|
|
42
|
+
* @returns - a string that is name of the color variant or null for no color
|
|
43
|
+
* variant
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export type BodyRowVariantFn = (row: FormattedRow, displayIndex: number) => string | null;
|
|
33
48
|
/**
|
|
34
49
|
* The type of the props passed to the {@link Grid} component.
|
|
35
50
|
*
|
|
@@ -116,7 +131,7 @@ export interface GridSpecificProps {
|
|
|
116
131
|
*
|
|
117
132
|
* @defaultValue `undefined` - no variant will be specified.
|
|
118
133
|
*/
|
|
119
|
-
bodyRowVariant?:
|
|
134
|
+
bodyRowVariant?: BodyRowVariantFn;
|
|
120
135
|
/**
|
|
121
136
|
* Function to set the color variant of body cells on a per-cell basis.
|
|
122
137
|
* Overrides the row-wide setting when this function returns a non-null value.
|
|
@@ -136,6 +151,34 @@ export interface GridSpecificProps {
|
|
|
136
151
|
* @defaultValue `undefined` - no variant will be specified.
|
|
137
152
|
*/
|
|
138
153
|
bodyCellFocusVariant?: BodyCellVariantFn;
|
|
154
|
+
/**
|
|
155
|
+
* The variant of the cell in the grid header row that contains the checkbox
|
|
156
|
+
* to toggle the selection of the entire grid
|
|
157
|
+
*
|
|
158
|
+
* @defaultValue `undefined` - no variant will be specified.
|
|
159
|
+
*/
|
|
160
|
+
headerSelectionCellVariant?: string;
|
|
161
|
+
/**
|
|
162
|
+
* The variant of the focus ring of the cell in the grid header row that
|
|
163
|
+
* contains the checkbox to toggle the selection of the entire grid
|
|
164
|
+
*
|
|
165
|
+
* @defaultValue `undefined` - no variant will be specified.
|
|
166
|
+
*/
|
|
167
|
+
headerSelectionCellFocusVariant?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The variant of the cells in the grid body that contain the checkboxes or
|
|
170
|
+
* radio buttons to toggle the selection of a row.
|
|
171
|
+
*
|
|
172
|
+
* @defaultValue `undefined` - no variant will be specified.
|
|
173
|
+
*/
|
|
174
|
+
bodySelectionCellVariant?: BodyRowVariantFn;
|
|
175
|
+
/**
|
|
176
|
+
* The variant of the focus rings of the cells in the grid body that contain
|
|
177
|
+
* the checkboxes or radio buttons to toggle the selection of a row.
|
|
178
|
+
*
|
|
179
|
+
* @defaultValue `undefined` - no variant will be specified.
|
|
180
|
+
*/
|
|
181
|
+
bodySelectionCellFocusVariant?: BodyRowVariantFn;
|
|
139
182
|
/**
|
|
140
183
|
* Enables and configures pagination for the grid
|
|
141
184
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
var SelectBodyCell = function (_a) {
|
|
3
|
+
var selectType = _a.selectType, isSelected = _a.isSelected, handleSelect = _a.handleSelect, className = _a.className, tabIndex = _a.tabIndex, radioGroup = _a.radioGroup, label = _a.label;
|
|
4
|
+
var onKeyDown = handleSelect === undefined
|
|
5
|
+
? undefined
|
|
6
|
+
: function (event) {
|
|
7
|
+
switch (event.code) {
|
|
8
|
+
case "Space": {
|
|
9
|
+
handleSelect();
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
default:
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return (_jsx("div", { role: "gridcell", className: className, tabIndex: tabIndex, onClick: handleSelect, onKeyDown: onKeyDown, "aria-colindex": 1, children: _jsx("input", { tabIndex: -1, className: "form-check-input", type: selectType === "multi" ? "checkbox" : "radio", checked: isSelected, radioGroup: radioGroup, readOnly: true, "aria-label": label }) }));
|
|
17
|
+
};
|
|
18
|
+
export default SelectBodyCell;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
var SelectHeaderCell = function (_a) {
|
|
4
|
+
var handleSelectAll = _a.handleSelectAll, _b = _a.checkboxState, indeterminate = _b.indeterminate, checked = _b.checked, disabled = _b.disabled, description = _b.description, className = _a.className, tabIndex = _a.tabIndex;
|
|
5
|
+
var inputRef = useRef(null);
|
|
6
|
+
useEffect(function () {
|
|
7
|
+
inputRef.current.indeterminate = indeterminate;
|
|
8
|
+
}, [indeterminate]);
|
|
9
|
+
var onKeyDown = function (event) {
|
|
10
|
+
switch (event.code) {
|
|
11
|
+
case "Space": {
|
|
12
|
+
handleSelectAll();
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
default:
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return (_jsx("div", { role: "columnheader", className: className, tabIndex: tabIndex, onKeyDown: onKeyDown, onClick: handleSelectAll, "aria-colindex": 1, children: _jsx("input", { tabIndex: -1, className: "form-check-input", type: "checkbox", ref: inputRef, checked: checked, disabled: disabled, "aria-label": description, title: description, readOnly: true }) }));
|
|
20
|
+
};
|
|
21
|
+
export default SelectHeaderCell;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { CheckboxState } from "../../common/selection/internalTypes";
|
|
3
|
+
export type SelectBodyCellProps = {
|
|
4
|
+
handleSelect?: () => void;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
selectType: "single" | "multi";
|
|
7
|
+
radioGroup: string;
|
|
8
|
+
label: string;
|
|
9
|
+
} & Pick<HTMLAttributes<HTMLDivElement>, "className" | "tabIndex">;
|
|
10
|
+
export type SelectHeaderCellProps = {
|
|
11
|
+
handleSelectAll: () => void;
|
|
12
|
+
checkboxState: CheckboxState;
|
|
13
|
+
} & Pick<HTMLAttributes<HTMLDivElement>, "className" | "tabIndex">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/grid.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.rbdg-grid>div,.rbdg-grid>div>div,.rbdg-grid>div>div>div{border-color:inherit;border-style:solid;border-width:0}.rbdg-grid{--rbdg-grid-color: var(--bs-emphasis-color);--rbdg-grid-bg: var(--bs-body-bg);--rbdg-grid-border-color: var(--bs-border-color);--rbdg-grid-accent-bg: transparent;--rbdg-grid-striped-color: var(--bs-emphasis-color);--rbdg-grid-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);--rbdg-grid-active-color: var(--bs-emphasis-color);--rbdg-grid-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);--rbdg-grid-hover-color: var(--bs-emphasis-color);--rbdg-grid-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);border-color:var(--rbdg-grid-border-color)}.rbdg-grid>div{width:min-content}.rbdg-grid>div>div>div{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:.5rem .5rem;color:var(--rbdg-grid-color-state, var(--rbdg-grid-color-type, var(--rbdg-grid-color)));background-color:var(--rbdg-grid-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg)))}.rbdg-grid>div>div>div.rbdg-sortable-header-cell{padding:0;overflow:visible}.rbdg-grid>div>div>div.rbdg-focusable-cell:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid>div:first-child>div>div{border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-group-divider{--rbdg-grid-divider-border-width: calc(var(--bs-border-width) * 2);--rbdg-grid-divider-border-style: solid;--rbdg-grid-divider-border-color: currentcolor}.rbdg-grid-sm>div>div>div{padding:.25rem .25rem}.rbdg-grid-bordered{border-width:var(--bs-border-width);border-style:solid}.rbdg-grid-bordered>div>div>div:not(:last-child){border-width:0 var(--bs-border-width) 0 0}.rbdg-grid-bordered>div>div>div:last-child{border-width:0}.rbdg-grid-bordered>div:first-child>div{border-top-width:0;border-right-width:0;border-left-width:0;border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-bordered>div:last-child>div:not(:last-child){border-width:0 0 var(--bs-border-width) 0}.rbdg-grid-borderless{--rbdg-grid-divider-borderless-width: 0}.rbdg-grid-borderless>div>div>div{border-bottom-width:0}.rbdg-grid-borderless>:not(:first-child){border-top-width:0}.rbdg-grid-striped>div:nth-of-type(2)>div:nth-of-type(odd)>div{--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-striped-columns>div>div>:nth-child(even){--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-active{--rbdg-grid-color-state: var(--
|
|
1
|
+
.rbdg-grid>div,.rbdg-grid>div>div,.rbdg-grid>div>div>div{border-color:inherit;border-style:solid;border-width:0}.rbdg-grid{--rbdg-grid-color: var(--bs-emphasis-color);--rbdg-grid-bg: var(--bs-body-bg);--rbdg-grid-border-color: var(--bs-border-color);--rbdg-grid-accent-bg: transparent;--rbdg-grid-striped-color: var(--bs-emphasis-color);--rbdg-grid-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);--rbdg-grid-active-color: var(--bs-emphasis-color);--rbdg-grid-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);--rbdg-grid-hover-color: var(--bs-emphasis-color);--rbdg-grid-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);border-color:var(--rbdg-grid-border-color)}.rbdg-grid>div{width:min-content}.rbdg-grid>div>div>div{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:.5rem .5rem;color:var(--rbdg-grid-color-state, var(--rbdg-grid-color-type, var(--rbdg-grid-color)));background-color:var(--rbdg-grid-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg)))}.rbdg-grid>div>div>div.rbdg-sortable-header-cell{padding:0;overflow:visible}.rbdg-grid>div>div>div.rbdg-focusable-cell:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid>div:first-child>div>div{border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-group-divider{--rbdg-grid-divider-border-width: calc(var(--bs-border-width) * 2);--rbdg-grid-divider-border-style: solid;--rbdg-grid-divider-border-color: currentcolor}.rbdg-grid-sm>div>div>div{padding:.25rem .25rem}.rbdg-grid-bordered{border-width:var(--bs-border-width);border-style:solid}.rbdg-grid-bordered>div>div>div:not(:last-child){border-width:0 var(--bs-border-width) 0 0}.rbdg-grid-bordered>div>div>div:last-child{border-width:0}.rbdg-grid-bordered>div:first-child>div{border-top-width:0;border-right-width:0;border-left-width:0;border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-bordered>div:last-child>div:not(:last-child){border-width:0 0 var(--bs-border-width) 0}.rbdg-grid-borderless{--rbdg-grid-divider-borderless-width: 0}.rbdg-grid-borderless>div>div>div{border-bottom-width:0}.rbdg-grid-borderless>:not(:first-child){border-top-width:0}.rbdg-grid-striped>div:nth-of-type(2)>div:nth-of-type(odd)>div{--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-striped-columns>div>div>:nth-child(even){--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-active{--rbdg-grid-color-state: var(--rbdg-grid-active-color);--rbdg-grid-bg-state: var(--rbdg-grid-active-bg)}.rbdg-grid-hover>div:nth-of-type(2)>div:hover>div{--rbdg-grid-color-state: var(--rbdg-grid-hover-color);--rbdg-grid-bg-state: var(--rbdg-grid-hover-bg)}.rbdg-grid-primary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 226, 254.6);--rbdg-grid-border-color: rgb(165.28, 180.8, 203.68);--rbdg-grid-striped-bg: rgb(196.27, 214.7, 241.87);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 203.4, 229.14);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 209.05, 235.505);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-secondary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(225.6, 227.4, 229);--rbdg-grid-border-color: rgb(180.48, 181.92, 183.2);--rbdg-grid-striped-bg: rgb(214.32, 216.03, 217.55);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(203.04, 204.66, 206.1);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(208.68, 210.345, 211.825);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-success{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(209, 231, 220.8);--rbdg-grid-border-color: rgb(167.2, 184.8, 176.64);--rbdg-grid-striped-bg: rgb(198.55, 219.45, 209.76);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(188.1, 207.9, 198.72);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(193.325, 213.675, 204.24);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-info{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 244.4, 252);--rbdg-grid-border-color: rgb(165.28, 195.52, 201.6);--rbdg-grid-striped-bg: rgb(196.27, 232.18, 239.4);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 219.96, 226.8);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 226.07, 233.1);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-warning{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(255, 242.6, 205.4);--rbdg-grid-border-color: rgb(204, 194.08, 164.32);--rbdg-grid-striped-bg: rgb(242.25, 230.47, 195.13);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(229.5, 218.34, 184.86);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(235.875, 224.405, 189.995);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-danger{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(248, 214.6, 217.8);--rbdg-grid-border-color: rgb(198.4, 171.68, 174.24);--rbdg-grid-striped-bg: rgb(235.6, 203.87, 206.91);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 193.14, 196.02);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 198.505, 201.465);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-light{--rbdg-grid-color: #000;--rbdg-grid-bg: #f8f9fa;--rbdg-grid-border-color: rgb(198.4, 199.2, 200);--rbdg-grid-striped-bg: rgb(235.6, 236.55, 237.5);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 224.1, 225);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 230.325, 231.25);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-dark{--rbdg-grid-color: #fff;--rbdg-grid-bg: #212529;--rbdg-grid-border-color: rgb(77.4, 80.6, 83.8);--rbdg-grid-striped-bg: rgb(44.1, 47.9, 51.7);--rbdg-grid-striped-color: #fff;--rbdg-grid-active-bg: rgb(55.2, 58.8, 62.4);--rbdg-grid-active-color: #fff;--rbdg-grid-hover-bg: rgb(49.65, 53.35, 57.05);--rbdg-grid-hover-color: #fff;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-header-button{display:flex;align-items:center;appearance:none;background:rgba(0,0,0,0);border:none;padding:.5rem .5rem;width:100%;height:100%;cursor:pointer;color:inherit;font-weight:inherit;text-align:inherit}.rbdg-grid-header-button .rbdg-grid-header-button-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex-shrink:1}.rbdg-grid-header-button .rbdg-grid-header-button-hover-only-icon{visibility:hidden}.rbdg-grid-header-button:hover{color:var(--rbdg-grid-hover-color);background:var(--rbdg-grid-hover-bg)}.rbdg-grid-header-button:hover .rbdg-grid-header-button-hover-only-icon{visibility:visible}.rbdg-grid-header-button:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid-header-button-icon{height:1em;flex-shrink:0}.rbdg-justify-content-center{justify-content:center}.rbdg-justify-content-left{justify-content:left}.rbdg-justify-content-right{justify-content:right}
|
package/grid.scss
CHANGED
|
@@ -184,7 +184,7 @@ $rbdg-prefix: "rbdg-";
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
.rbdg-grid-active {
|
|
187
|
-
--#{$rbdg-prefix}grid-color-state: var(--#{$prefix}grid-active-color);
|
|
187
|
+
--#{$rbdg-prefix}grid-color-state: var(--#{$rbdg-prefix}grid-active-color);
|
|
188
188
|
--#{$rbdg-prefix}grid-bg-state: var(--#{$rbdg-prefix}grid-active-bg);
|
|
189
189
|
}
|
|
190
190
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absreim/react-bootstrap-data-grid",
|
|
3
3
|
"description": "Data grid UI component for use with web apps using React and Bootstrap",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Brook Li",
|
|
7
7
|
"homepage": "https://react-bootstrap-data-grid.vercel.app/",
|
package/table/InternalTable.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import { UseCombinedPipelineHook } from "../common/pipeline/useCombinedPipeline";
|
|
3
|
-
import { UseGridSelectionFnsHook } from "../common/pipeline/useGridSelectionFns";
|
|
4
2
|
import { BaseTableProps } from "./internalTypes";
|
|
3
|
+
import { CombinedPipelineOutput } from "../common/pipeline/useCombinedPipeline/internalTypes";
|
|
4
|
+
import { SelectionFns } from "../common/pipeline/internalTypes";
|
|
5
5
|
export interface InternalTableProps {
|
|
6
6
|
tableProps: BaseTableProps;
|
|
7
7
|
hooks: {
|
|
8
|
-
selectFns:
|
|
9
|
-
pipelineOutput:
|
|
8
|
+
selectFns: SelectionFns;
|
|
9
|
+
pipelineOutput: CombinedPipelineOutput;
|
|
10
10
|
};
|
|
11
11
|
slots: {
|
|
12
12
|
colHeaderCells: ReactNode;
|
package/table/InternalTable.js
CHANGED
|
@@ -34,11 +34,11 @@ var InternalTable = function (_a) {
|
|
|
34
34
|
}
|
|
35
35
|
: undefined,
|
|
36
36
|
});
|
|
37
|
-
var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo,
|
|
37
|
+
var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo, selectAllHandler = selectFns.selectAllHandler;
|
|
38
38
|
var mainTable = (_jsxs("table", { className: classNames({
|
|
39
39
|
"table-hover": rowsAreSelectable,
|
|
40
40
|
"d-block": displayMode === "block",
|
|
41
|
-
}, ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.caption), children: caption })), _jsx("thead", { className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_e = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _e === void 0 ? void 0 : _e.theadTr, (classes === null || classes === void 0 ? void 0 : classes.headerRow) || []), children: [prefixHeader, showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick:
|
|
41
|
+
}, ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.caption), children: caption })), _jsx("thead", { className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_e = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _e === void 0 ? void 0 : _e.theadTr, (classes === null || classes === void 0 ? void 0 : classes.headerRow) || []), children: [prefixHeader, showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick: selectAllHandler, totalRows: rows.length, customClasses: (_f = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _f === void 0 ? void 0 : _f.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames((_g = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _g === void 0 ? void 0 : _g.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(classNames((_h = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _h === void 0 ? void 0 : _h.tbody)), children: bodyRows })] }));
|
|
42
42
|
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames((_j = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _j === void 0 ? void 0 : _j.topLevelDiv), children: [showToolbar && (_jsx(ToolbarContainer, { interfaceGen: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames((_k = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _k === void 0 ? void 0 : _k.tableAndPaginationDiv), children: [_jsx("div", { "data-testid": "rbdg-table-div", className: classNames(((_l = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _l === void 0 ? void 0 : _l.tableDiv) ||
|
|
43
43
|
"table-responsive"), children: mainTable }), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: (_m = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _m === void 0 ? void 0 : _m.paginationUiDiv }))] })] }));
|
|
44
44
|
};
|
package/table/Table.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import InternalTable from "./InternalTable";
|
|
4
4
|
import ColHeaderCell from "./main/ColHeaderCell";
|
|
5
5
|
import useCombinedPipeline from "../common/pipeline/useCombinedPipeline";
|
|
6
|
-
import
|
|
6
|
+
import useSelectionFns from "../common/pipeline/useSelectionFns";
|
|
7
7
|
import useGetInputStrSubmitCallback from "../common/pipeline/useGetInputStrSubmitCallback";
|
|
8
8
|
import useAugFormattedRows from "../common/pipeline/useAugFormattedRows";
|
|
9
9
|
import BodyRows from "./main/BodyRows";
|
|
@@ -24,7 +24,7 @@ var Table = function (props) {
|
|
|
24
24
|
selectModel: selectModel,
|
|
25
25
|
});
|
|
26
26
|
var _a = combinedPipelineOutput.sortedRowsOutput, sortColDef = _a.sortColDef, setSortColDef = _a.setSortColDef, sortingEnabled = _a.sortingEnabled, showSelectCol = combinedPipelineOutput.showSelectCol, displayRows = combinedPipelineOutput.displayRows;
|
|
27
|
-
var gridSelectionFns =
|
|
27
|
+
var gridSelectionFns = useSelectionFns(selectModel, rows);
|
|
28
28
|
var getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
29
29
|
var colNameToWidth = useColNameToWidth(cols);
|
|
30
30
|
var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
|
package/table/main/BodyRows.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import { UseGridSelectionFnsHook } from "../../common/pipeline/useGridSelectionFns";
|
|
3
|
-
import { UseCombinedPipelineHook } from "../../common/pipeline/useCombinedPipeline";
|
|
4
2
|
import { SelectModel } from "../../common";
|
|
5
3
|
import { UseGetInputStrSubmitCallbackHook } from "../../common/pipeline/useGetInputStrSubmitCallback";
|
|
6
4
|
import { TableStyleModel } from "../styling/types";
|
|
7
5
|
import { FormattedRow, RowId } from "../../common";
|
|
8
6
|
import { AugFormattedRow } from "../../common/internalTypes";
|
|
9
7
|
import { EditModel } from "../../common";
|
|
8
|
+
import { CombinedPipelineOutput } from "../../common/pipeline/useCombinedPipeline/internalTypes";
|
|
9
|
+
import { SelectionFns } from "../../common/pipeline/internalTypes";
|
|
10
10
|
interface BodyRowsProps {
|
|
11
11
|
augFormattedRows: AugFormattedRow[];
|
|
12
|
-
gridSelectionFns:
|
|
12
|
+
gridSelectionFns: SelectionFns;
|
|
13
13
|
tableStyleModel: TableStyleModel | undefined;
|
|
14
|
-
combinedPipelineOutput:
|
|
14
|
+
combinedPipelineOutput: CombinedPipelineOutput;
|
|
15
15
|
selectModel: SelectModel | undefined;
|
|
16
16
|
editModel: EditModel | undefined;
|
|
17
17
|
getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
|
package/table/main/BodyRows.js
CHANGED
|
@@ -4,9 +4,9 @@ import classNames from "classnames";
|
|
|
4
4
|
import getWidthStyle from "../../common/util/getWidthStyle";
|
|
5
5
|
import SelectionInput from "../selection/SelectionInput";
|
|
6
6
|
var BodyRows = function (_a) {
|
|
7
|
-
var augFormattedRows = _a.augFormattedRows, _b = _a.gridSelectionFns, selectedSet = _b.selectedSet, getSelectInputModel = _b.getSelectInputModel, getSelectHandler = _b.getSelectHandler,
|
|
7
|
+
var augFormattedRows = _a.augFormattedRows, _b = _a.gridSelectionFns, selectedSet = _b.selectedSet, getSelectInputModel = _b.getSelectInputModel, getSelectHandler = _b.getSelectHandler, getRowSelectHandler = _b.getRowSelectHandler, getAriaSelectedValue = _b.getAriaSelectedValue, tableStyleModel = _a.tableStyleModel, _c = _a.combinedPipelineOutput, showSelectCol = _c.showSelectCol, ariaColIndexOffset = _c.ariaColIndexOffset, selectModel = _a.selectModel, editModel = _a.editModel, getInputStrSubmitCallback = _a.getInputStrSubmitCallback, additionalColIndexOffset = _a.additionalColIndexOffset, renderPrefixCells = _a.renderPrefixCells, additionalRowStyles = _a.additionalRowStyles;
|
|
8
8
|
return augFormattedRows.map(function (row, index) {
|
|
9
|
-
return (_jsxs(EditableRow, { onClick:
|
|
9
|
+
return (_jsxs(EditableRow, { onClick: getRowSelectHandler(row.id), className: classNames({
|
|
10
10
|
"table-active": selectedSet.has(row.id),
|
|
11
11
|
}, (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr) && (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr(row.id, index)), additionalRowStyles ? additionalRowStyles(row.id, index) : []), "aria-rowindex": row.prePaginationIndex + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset + (additionalColIndexOffset || 0), cellData: row.contents, updateCallback: getInputStrSubmitCallback && getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) && editModel.getDeleteCallback(row.id), dataCellClasses: function (colIndex) {
|
|
12
12
|
return (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd)
|
|
@@ -2,52 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
|
|
6
|
-
var disabledState = {
|
|
7
|
-
indeterminate: false,
|
|
8
|
-
checked: false,
|
|
9
|
-
disabled: true,
|
|
10
|
-
description: "Select all (disabled)",
|
|
11
|
-
};
|
|
12
|
-
if (noRows) {
|
|
13
|
-
return disabledState;
|
|
14
|
-
}
|
|
15
|
-
var existingSelection = selectionInfo.existingSelection;
|
|
16
|
-
if (existingSelection === "full") {
|
|
17
|
-
return {
|
|
18
|
-
indeterminate: false,
|
|
19
|
-
checked: true,
|
|
20
|
-
disabled: false,
|
|
21
|
-
description: "Deselect all rows",
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (existingSelection === true || existingSelection === "partial") {
|
|
25
|
-
return {
|
|
26
|
-
indeterminate: true,
|
|
27
|
-
checked: true,
|
|
28
|
-
disabled: false,
|
|
29
|
-
description: "Deselect all rows",
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if (existingSelection === "none") {
|
|
33
|
-
return {
|
|
34
|
-
indeterminate: false,
|
|
35
|
-
checked: false,
|
|
36
|
-
disabled: false,
|
|
37
|
-
description: "Select all rows",
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// single select mode and none selected
|
|
41
|
-
return disabledState;
|
|
42
|
-
};
|
|
5
|
+
import getSelectionCheckboxState from "../../common/selection/getSelectionCheckboxState";
|
|
43
6
|
var SelectAllHeaderCell = function (_a) {
|
|
44
7
|
var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows, customClasses = _a.customClasses, style = _a.style, colIndexOffset = _a.colIndexOffset;
|
|
45
8
|
var noRows = totalRows === 0;
|
|
46
|
-
var _b =
|
|
9
|
+
var _b = getSelectionCheckboxState(selectionInfo, noRows), indeterminate = _b.indeterminate, checked = _b.checked, disabled = _b.disabled, description = _b.description;
|
|
47
10
|
var ref = useRef(null);
|
|
48
11
|
useEffect(function () {
|
|
49
12
|
ref.current.indeterminate = indeterminate;
|
|
50
13
|
}, [indeterminate]);
|
|
51
|
-
return (_jsx("th", { style: style, "aria-colindex": 1 + (colIndexOffset || 0), title: description, "aria-description": description, className: classNames(customClasses || "btn-primary"), children: _jsx("input", { tabIndex: 0, type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
14
|
+
return (_jsx("th", { style: style, "aria-colindex": 1 + (colIndexOffset || 0), title: description, "aria-description": description, className: classNames(customClasses || "btn-primary"), children: _jsx("input", { className: "form-check-input", tabIndex: 0, type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
52
15
|
};
|
|
53
16
|
export default SelectAllHeaderCell;
|
|
@@ -16,7 +16,7 @@ var SelectionInput = function (_a) {
|
|
|
16
16
|
selectCallback();
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
return (_jsx("input", { tabIndex: 0, className: classNames(additionalClasses || []), "aria-label": "Select row with index ".concat(index), onClick: function (event) {
|
|
19
|
+
return (_jsx("input", { tabIndex: 0, className: classNames(additionalClasses || ["form-check-input"]), "aria-label": "Select row with index ".concat(index), onClick: function (event) {
|
|
20
20
|
event.stopPropagation();
|
|
21
21
|
}, type: type, checked: selected, onChange: onChange, name: selectionInputModel.name }));
|
|
22
22
|
};
|
package/table/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditModel, MainComponentSharedProps, PaginationModel,
|
|
1
|
+
import { EditModel, MainComponentSharedProps, PaginationModel, StyleModel } from "../common";
|
|
2
2
|
/**
|
|
3
3
|
* Available options for the displayMode prop of {@link TableSpecificProps}.
|
|
4
4
|
*
|
|
@@ -12,11 +12,6 @@ export type DisplayMode = "table" | "block";
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export interface TableSpecificProps {
|
|
15
|
-
/**
|
|
16
|
-
* The select model of the table. Passing a truthy value enables the
|
|
17
|
-
* selection feature of the component.
|
|
18
|
-
*/
|
|
19
|
-
selectModel?: SelectModel;
|
|
20
15
|
/**
|
|
21
16
|
* The edit model of the table. Passing a truthy value enables the
|
|
22
17
|
* editing feature of the component.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MouseEventHandler } from "react";
|
|
2
|
-
import { SelectModel } from "../selection/types";
|
|
3
|
-
import { SelectionInputModel } from "../../table/selection/SelectionInput";
|
|
4
|
-
import { RowDef, RowId } from "../types";
|
|
5
|
-
import { SelectionInfo } from "../selection/internalTypes";
|
|
6
|
-
export interface UseGridSelectionFnsHook {
|
|
7
|
-
selectedSet: Set<RowId>;
|
|
8
|
-
rowsAreSelectable: boolean | undefined;
|
|
9
|
-
selectionInfo: SelectionInfo | null;
|
|
10
|
-
selectAllOnClick: () => void;
|
|
11
|
-
getSelectHandler: (index: RowId) => () => void;
|
|
12
|
-
getSelectInputModel: (id: RowId, selectModel: SelectModel) => SelectionInputModel;
|
|
13
|
-
getRowClickHandler: (index: RowId) => MouseEventHandler<HTMLTableRowElement>;
|
|
14
|
-
getAriaSelectedValue: (id: RowId) => "true" | "false" | undefined;
|
|
15
|
-
}
|
|
16
|
-
declare const useGridSelectionFns: (selectModel: SelectModel | undefined, rows: RowDef[]) => UseGridSelectionFnsHook;
|
|
17
|
-
export default useGridSelectionFns;
|
package/grid/focus/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Grid cell coordinates based on ARIA row index and column index.
|
|
3
|
-
*
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface FocusCoordinates {
|
|
7
|
-
/**
|
|
8
|
-
* The ARIA row index.
|
|
9
|
-
*/
|
|
10
|
-
ariaRowIndex: number;
|
|
11
|
-
/**
|
|
12
|
-
* The ARIA column index.
|
|
13
|
-
*/
|
|
14
|
-
ariaColIndex: number;
|
|
15
|
-
}
|
|
File without changes
|