@absreim/react-bootstrap-data-grid-pro 4.6.1 → 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/{types.d.ts → internalTypes.d.ts} +1 -1
- package/grid/focus/internalTypes.js +1 -0
- package/grid/focus/useGridFocus.d.ts +1 -1
- package/grid/main/Grid.js +32 -4
- package/grid/main/GridBody.js +60 -16
- 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 +17 -0
- package/grid/selection/SelectHeaderCell.d.ts +4 -0
- package/grid/selection/SelectHeaderCell.js +20 -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/table-pro/TablePro.js +2 -2
- package/common/pipeline/useGridSelectionFns.d.ts +0 -17
- /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
|
-
const
|
|
3
|
+
const useSelectionFns = (selectModel, rows) => {
|
|
4
4
|
const selectionExists = useMemo(() => {
|
|
5
5
|
if (!selectModel) {
|
|
6
6
|
return false;
|
|
@@ -10,7 +10,7 @@ const useGridSelectionFns = (selectModel, rows) => {
|
|
|
10
10
|
}
|
|
11
11
|
return selectModel.selected.length > 0;
|
|
12
12
|
}, [selectModel]);
|
|
13
|
-
const
|
|
13
|
+
const selectAllHandler = useCallback(() => {
|
|
14
14
|
if (!selectModel) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -26,9 +26,7 @@ const useGridSelectionFns = (selectModel, rows) => {
|
|
|
26
26
|
const allRowIndices = rows.map((_, index) => 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
|
const getSelectHandler = (index) => () => {
|
|
34
32
|
if (!selectModel) {
|
|
@@ -41,7 +39,11 @@ const useGridSelectionFns = (selectModel, rows) => {
|
|
|
41
39
|
selectModel.setSelected(selectModel.selected.concat(index));
|
|
42
40
|
};
|
|
43
41
|
const getDeselectHandler = (index) => () => {
|
|
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((num) => num !== index));
|
|
@@ -85,8 +87,8 @@ const useGridSelectionFns = (selectModel, rows) => {
|
|
|
85
87
|
}
|
|
86
88
|
const getMultiExistingSelection = (selectionExists, rows) => {
|
|
87
89
|
const rowIndices = rows.map((_, index) => 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
|
const isFullSelection = isSubset(rowIndices, selectModel.selected);
|
|
91
93
|
if (!selectionExists) {
|
|
92
94
|
return "none";
|
|
@@ -101,15 +103,20 @@ const useGridSelectionFns = (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
|
+
const getToggleHandler = (rowId) => () => {
|
|
109
|
+
if (selectedSet.has(rowId)) {
|
|
110
|
+
getDeselectHandler(rowId)();
|
|
106
111
|
return;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
getSelectHandler(rowId)();
|
|
114
|
+
};
|
|
115
|
+
const getRowSelectHandler = (rowId) => () => {
|
|
116
|
+
if (!rowsAreSelectable) {
|
|
110
117
|
return;
|
|
111
118
|
}
|
|
112
|
-
|
|
119
|
+
getToggleHandler(rowId)();
|
|
113
120
|
};
|
|
114
121
|
const getAriaSelectedValue = (id) => {
|
|
115
122
|
if (!selectModel) {
|
|
@@ -121,11 +128,12 @@ const useGridSelectionFns = (selectModel, rows) => {
|
|
|
121
128
|
selectedSet,
|
|
122
129
|
rowsAreSelectable,
|
|
123
130
|
selectionInfo,
|
|
124
|
-
|
|
131
|
+
selectAllHandler,
|
|
125
132
|
getSelectHandler,
|
|
126
133
|
getSelectInputModel,
|
|
127
|
-
getRowClickHandler,
|
|
128
134
|
getAriaSelectedValue,
|
|
135
|
+
getRowSelectHandler,
|
|
136
|
+
getToggleHandler,
|
|
129
137
|
};
|
|
130
138
|
};
|
|
131
|
-
export default
|
|
139
|
+
export default useSelectionFns;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const getSelectionCheckboxState = (selectionInfo, noRows) => {
|
|
2
|
+
const disabledState = {
|
|
3
|
+
indeterminate: false,
|
|
4
|
+
checked: false,
|
|
5
|
+
disabled: true,
|
|
6
|
+
description: "Select all (disabled)",
|
|
7
|
+
};
|
|
8
|
+
if (noRows) {
|
|
9
|
+
return disabledState;
|
|
10
|
+
}
|
|
11
|
+
const { existingSelection } = selectionInfo;
|
|
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 @@
|
|
|
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>;
|
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,12 +13,14 @@ 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
|
*
|
|
19
21
|
* @public
|
|
20
22
|
*/
|
|
21
|
-
const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, width, height, variant, stripes, hover, borders, small, divider, borderVariant, headerCellVariant, headerRowVariant, bodyCellVariant, bodyRowVariant, headerCellFocusVariant, bodyCellFocusVariant, styleOptions, }) => {
|
|
23
|
+
const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, width, height, variant, stripes, hover, borders, small, divider, borderVariant, headerCellVariant, headerRowVariant, bodyCellVariant, bodyRowVariant, headerCellFocusVariant, bodyCellFocusVariant, styleOptions, selectModel, bodySelectionCellVariant, bodySelectionCellFocusVariant, headerSelectionCellVariant, headerSelectionCellFocusVariant, }) => {
|
|
22
24
|
var _a, _b, _c;
|
|
23
25
|
const { displayRows, filterState, normalizedTableFilterModel, filteredRows, sortedRowsOutput, currentPageRowsOutput: { paginatedRows, normalizedModel }, } = useCombinedPipeline({
|
|
24
26
|
rows,
|
|
@@ -60,12 +62,14 @@ const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, wid
|
|
|
60
62
|
const heightProperties = getHeightProperties(height);
|
|
61
63
|
const vertScrollable = height !== undefined && height !== "auto";
|
|
62
64
|
const gridRef = useRef(null);
|
|
65
|
+
const ariaColIndexOffset = selectModel && selectModel.mode !== "row" ? 1 : 0;
|
|
63
66
|
const sortableColIndices = sortModel
|
|
64
67
|
? cols
|
|
65
68
|
.map((_, index) => index + 1)
|
|
66
69
|
.filter((ariaColIndex) => cols[ariaColIndex - 1].sortable)
|
|
70
|
+
.map((ariaColIndex) => ariaColIndex + ariaColIndexOffset)
|
|
67
71
|
: [];
|
|
68
|
-
const { effectiveCoords, gridClickHandler, gridKeydownHandler } = useGridFocus(gridRef, displayRows.length + 1, cols.length, sortableColIndices);
|
|
72
|
+
const { effectiveCoords, gridClickHandler, gridKeydownHandler } = useGridFocus(gridRef, displayRows.length + 1, cols.length + ariaColIndexOffset, sortableColIndices);
|
|
69
73
|
const onCopy = useCallback((event) => {
|
|
70
74
|
var _a;
|
|
71
75
|
if (!((_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))) {
|
|
@@ -78,6 +82,30 @@ const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, wid
|
|
|
78
82
|
event.preventDefault();
|
|
79
83
|
event.clipboardData.setData("text/plain", selection.focusNode.textContent);
|
|
80
84
|
}, []);
|
|
85
|
+
const { getToggleHandler, selectedSet, selectAllHandler, selectionInfo } = useSelectionFns(selectModel, rows);
|
|
86
|
+
const getRowIsSelected = useCallback((id) => selectedSet.has(id), [selectedSet]);
|
|
87
|
+
const headerSelectionInfo = useMemo(() => {
|
|
88
|
+
if (!selectModel) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
mode: selectModel.mode,
|
|
93
|
+
selectAllHandler,
|
|
94
|
+
selectCheckboxState: getSelectionCheckboxState(selectionInfo, rows.length === 0),
|
|
95
|
+
};
|
|
96
|
+
}, [rows.length, selectAllHandler, selectModel, selectionInfo]);
|
|
97
|
+
const bodySelectionInfo = useMemo(() => {
|
|
98
|
+
if (!selectModel) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
type: selectModel.type,
|
|
103
|
+
mode: selectModel.mode,
|
|
104
|
+
getRowIsSelected,
|
|
105
|
+
getToggleHandler,
|
|
106
|
+
};
|
|
107
|
+
}, [getRowIsSelected, getToggleHandler, selectModel]);
|
|
108
|
+
const gridId = useId();
|
|
81
109
|
const mainGridComponent = (_jsxs("div", { onCopy: onCopy, onClick: gridClickHandler, onKeyDown: gridKeydownHandler, ref: gridRef, style: {
|
|
82
110
|
width: widthProperty,
|
|
83
111
|
height: heightProperties.mainDiv,
|
|
@@ -93,7 +121,7 @@ const Grid = ({ rows, cols, sortModel, pagination, allowExport, filterModel, wid
|
|
|
93
121
|
"rbdg-grid-group-divider": !!divider,
|
|
94
122
|
}, "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
123
|
? effectiveCoords.ariaColIndex
|
|
96
|
-
: null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
|
|
124
|
+
: 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 })] }));
|
|
97
125
|
const getPagination = (pagination) => {
|
|
98
126
|
var _a, _b, _c, _d;
|
|
99
127
|
return (_jsx(Pagination, { containerDivClasses: [
|
package/grid/main/GridBody.js
CHANGED
|
@@ -1,27 +1,71 @@
|
|
|
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
|
-
|
|
6
|
+
import SelectBodyCell from "../selection/SelectBodyCell";
|
|
7
|
+
const GridBody = ({ augFormattedRows, cols, rowVariant, cellVariant, focusCoords, cellFocusVariant, selectionInfo, gridId, selectionCellVariant, selectionCellFocusVariant, }) => {
|
|
8
|
+
const getRowKeydownHandler = !selectionInfo
|
|
9
|
+
? null
|
|
10
|
+
: (id) => {
|
|
11
|
+
return (event) => {
|
|
12
|
+
switch (event.code) {
|
|
13
|
+
case "Space": {
|
|
14
|
+
selectionInfo.getToggleHandler(id)();
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
default:
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
function getSelectCellContent(rowId, displayRowIndex, displayRowArrayIndex, row) {
|
|
23
|
+
if (!selectionInfo || selectionInfo.mode === "row") {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const isFocused = focusCoords.ariaColIndex === 1 &&
|
|
27
|
+
focusCoords.displayRowIndex === displayRowIndex;
|
|
28
|
+
const cellVariantVal = selectionCellVariant && selectionCellVariant(row, displayRowArrayIndex);
|
|
29
|
+
const cellFocusVariantVal = selectionCellFocusVariant &&
|
|
30
|
+
selectionCellFocusVariant(row, displayRowArrayIndex);
|
|
31
|
+
const rowIsSelected = selectionInfo.getRowIsSelected(rowId);
|
|
32
|
+
const ariaRowIndex = row.prePaginationIndex + 2;
|
|
33
|
+
return (_jsx(SelectBodyCell, { handleSelect: selectionInfo && selectionInfo.mode === "column"
|
|
34
|
+
? selectionInfo.getToggleHandler(rowId)
|
|
35
|
+
: undefined, isSelected: rowIsSelected, selectType: selectionInfo.type, radioGroup: gridId, tabIndex: isFocused ? 0 : -1, className: classNames("rbdg-grid-cell", cellVariantVal && `${CSS_PREFIX}-${cellVariantVal}`, cellFocusVariantVal && `focus-ring-${cellFocusVariantVal}`, {
|
|
36
|
+
"z-2": isFocused,
|
|
37
|
+
"rbdg-focusable-cell": isFocused,
|
|
38
|
+
"rbdg-grid-active": rowIsSelected,
|
|
39
|
+
}), label: `Select row ${ariaRowIndex}` }));
|
|
40
|
+
}
|
|
7
41
|
return (_jsx("div", { role: "rowgroup", "data-testid": GRID_BODY_DATA_TEST_ID, children: augFormattedRows.map((row, displayRowArrayIndex) => {
|
|
8
42
|
const ariaRowIndex = row.prePaginationIndex + 2;
|
|
9
43
|
const displayRowIndex = displayRowArrayIndex + 2;
|
|
10
|
-
|
|
44
|
+
const rowIsSelected = selectionInfo
|
|
45
|
+
? selectionInfo.getRowIsSelected(row.id)
|
|
46
|
+
: undefined;
|
|
47
|
+
return (_jsxs("div", { role: "row", "display-rowindex": displayRowIndex, "aria-selected": rowIsSelected, "aria-rowindex": ariaRowIndex, className: classNames("d-flex", "flex-row", rowVariant &&
|
|
11
48
|
rowVariant(row, displayRowArrayIndex) &&
|
|
12
|
-
`${CSS_PREFIX}-${rowVariant(row, displayRowArrayIndex)}`),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
`${CSS_PREFIX}-${rowVariant(row, displayRowArrayIndex)}`), onClick: !selectionInfo || selectionInfo.mode === "column"
|
|
50
|
+
? undefined
|
|
51
|
+
: selectionInfo.getToggleHandler(row.id), onKeyDown: !selectionInfo || selectionInfo.mode === "column"
|
|
52
|
+
? undefined
|
|
53
|
+
: getRowKeydownHandler(row.id), children: [getSelectCellContent(row.id, displayRowIndex, displayRowArrayIndex, row), row.contents.map(({ formattedValue, width }, index) => {
|
|
54
|
+
const ariaColIndex = index +
|
|
55
|
+
1 +
|
|
56
|
+
(selectionInfo && selectionInfo.mode !== "row" ? 1 : 0);
|
|
57
|
+
const isFocused = focusCoords.ariaColIndex === ariaColIndex &&
|
|
58
|
+
focusCoords.displayRowIndex === displayRowIndex;
|
|
59
|
+
const cellVariantVal = cellVariant &&
|
|
60
|
+
cellVariant(row.contents[index], row, index, displayRowArrayIndex);
|
|
61
|
+
const cellFocusVariantVal = cellFocusVariant &&
|
|
62
|
+
cellFocusVariant(row.contents[index], row, index, displayRowArrayIndex);
|
|
63
|
+
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}`, {
|
|
64
|
+
"z-2": isFocused,
|
|
65
|
+
"rbdg-focusable-cell": isFocused,
|
|
66
|
+
"rbdg-grid-active": rowIsSelected,
|
|
67
|
+
}), "aria-colindex": ariaColIndex, children: formattedValue }, cols[index].name));
|
|
68
|
+
})] }, row.id));
|
|
25
69
|
}) }));
|
|
26
70
|
};
|
|
27
71
|
export default GridBody;
|
package/grid/main/GridHeader.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
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
|
-
|
|
8
|
+
import SelectHeaderCell from "../selection/SelectHeaderCell";
|
|
9
|
+
const GridHeader = ({ cols, vertScrollable, rowVariant, cellVariant, focusColIndex, cellFocusVariant, sortInfo, selectionInfo, selectionCellVariant, selectionCellFocusVariant, }) => {
|
|
10
|
+
const onKeyDown = selectionInfo === undefined
|
|
11
|
+
? undefined
|
|
12
|
+
: (event) => {
|
|
13
|
+
switch (event.code) {
|
|
14
|
+
case "Space": {
|
|
15
|
+
selectionInfo.selectAllHandler();
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
default:
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
9
22
|
const { sortingEnabled, sortColDef, setSortColDef } = sortInfo;
|
|
10
23
|
const getSortButtonListener = (colName) => () => {
|
|
11
24
|
if ((sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) !== colName) {
|
|
@@ -24,19 +37,23 @@ const GridHeader = ({ cols, vertScrollable, rowVariant, cellVariant, focusColInd
|
|
|
24
37
|
}
|
|
25
38
|
setSortColDef(null);
|
|
26
39
|
};
|
|
27
|
-
return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
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 && `${CSS_PREFIX}-${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 && `${CSS_PREFIX}-${selectionCellVariant}`, selectionCellFocusVariant &&
|
|
41
|
+
`focus-ring-${selectionCellFocusVariant}`, {
|
|
42
|
+
"rbdg-focusable-cell": focusColIndex === 1,
|
|
43
|
+
"z-2": focusColIndex === 1,
|
|
44
|
+
}) })), cols.map((col, index) => {
|
|
45
|
+
const ariaColIndex = index + 1 + (selectionInfo && selectionInfo.mode !== "row" ? 1 : 0);
|
|
46
|
+
const isFocused = focusColIndex === ariaColIndex;
|
|
47
|
+
const cellVariantVal = cellVariant && cellVariant(col, index);
|
|
48
|
+
const cellFocusVariantVal = cellFocusVariant && cellFocusVariant(col, index);
|
|
49
|
+
const currentColSortingEnabled = sortingEnabled && col.sortable;
|
|
50
|
+
return (_jsx("div", { tabIndex: isFocused && !currentColSortingEnabled ? 0 : -1, className: classNames("rbdg-grid-cell", "fw-bold", cellVariantVal && `${CSS_PREFIX}-${cellVariantVal}`, cellFocusVariantVal && `focus-ring-${cellFocusVariantVal}`, {
|
|
51
|
+
"z-2": isFocused,
|
|
52
|
+
"rbdg-focusable-cell": isFocused && !currentColSortingEnabled,
|
|
53
|
+
"rbdg-sortable-header-cell": currentColSortingEnabled,
|
|
54
|
+
}), role: "columnheader", "aria-colindex": ariaColIndex, "aria-sort": currentColSortingEnabled && (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === col.name
|
|
55
|
+
? sortOrderToAriaSort(sortColDef.order)
|
|
56
|
+
: 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));
|
|
57
|
+
})] }) }));
|
|
41
58
|
};
|
|
42
59
|
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,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const SelectBodyCell = ({ selectType, isSelected, handleSelect, className, tabIndex, radioGroup, label, }) => {
|
|
3
|
+
const onKeyDown = handleSelect === undefined
|
|
4
|
+
? undefined
|
|
5
|
+
: (event) => {
|
|
6
|
+
switch (event.code) {
|
|
7
|
+
case "Space": {
|
|
8
|
+
handleSelect();
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
default:
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
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 }) }));
|
|
16
|
+
};
|
|
17
|
+
export default SelectBodyCell;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
const SelectHeaderCell = ({ handleSelectAll, checkboxState: { indeterminate, checked, disabled, description }, className, tabIndex, }) => {
|
|
4
|
+
const inputRef = useRef(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
inputRef.current.indeterminate = indeterminate;
|
|
7
|
+
}, [indeterminate]);
|
|
8
|
+
const onKeyDown = (event) => {
|
|
9
|
+
switch (event.code) {
|
|
10
|
+
case "Space": {
|
|
11
|
+
handleSelectAll();
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
default:
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
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 }) }));
|
|
19
|
+
};
|
|
20
|
+
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-pro",
|
|
3
3
|
"description": "Pro Version of data grid UI component for use with web apps using React and Bootstrap",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"license": "Commercial. See LICENSE file.",
|
|
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
|
@@ -33,11 +33,11 @@ const InternalTable = ({ tableProps: { rows, cols, pagination, filterModel, sele
|
|
|
33
33
|
}
|
|
34
34
|
: undefined,
|
|
35
35
|
});
|
|
36
|
-
const { rowsAreSelectable, selectionInfo,
|
|
36
|
+
const { rowsAreSelectable, selectionInfo, selectAllHandler } = selectFns;
|
|
37
37
|
const mainTable = (_jsxs("table", { className: classNames({
|
|
38
38
|
"table-hover": rowsAreSelectable,
|
|
39
39
|
"d-block": displayMode === "block",
|
|
40
|
-
}, ((_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _a === void 0 ? void 0 : _a.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.caption), children: caption })), _jsx("thead", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.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:
|
|
40
|
+
}, ((_a = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _a === void 0 ? void 0 : _a.table) || "table"), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.caption), children: caption })), _jsx("thead", { className: classNames((_c = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _c === void 0 ? void 0 : _c.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames((_d = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _d === void 0 ? void 0 : _d.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: (_e = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _e === void 0 ? void 0 : _e.rowSelectColTh, colIndexOffset: prefixHeader ? 1 : 0 })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames((_f = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _f === void 0 ? void 0 : _f.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(classNames((_g = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _g === void 0 ? void 0 : _g.tbody)), children: bodyRows })] }));
|
|
41
41
|
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames((_h = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _h === void 0 ? void 0 : _h.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((_j = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _j === void 0 ? void 0 : _j.tableAndPaginationDiv), children: [_jsx("div", { "data-testid": "rbdg-table-div", className: classNames(((_k = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _k === void 0 ? void 0 : _k.tableDiv) ||
|
|
42
42
|
"table-responsive"), children: mainTable }), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: (_l = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _l === void 0 ? void 0 : _l.paginationUiDiv }))] })] }));
|
|
43
43
|
};
|
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 @@ const Table = (props) => {
|
|
|
24
24
|
selectModel,
|
|
25
25
|
});
|
|
26
26
|
const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, } = combinedPipelineOutput;
|
|
27
|
-
const gridSelectionFns =
|
|
27
|
+
const gridSelectionFns = useSelectionFns(selectModel, rows);
|
|
28
28
|
const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
29
29
|
const colNameToWidth = useColNameToWidth(cols);
|
|
30
30
|
const 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
|
@@ -3,8 +3,8 @@ import EditableRow from "../editing/EditableRow";
|
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import getWidthStyle from "../../common/util/getWidthStyle";
|
|
5
5
|
import SelectionInput from "../selection/SelectionInput";
|
|
6
|
-
const BodyRows = ({ augFormattedRows, gridSelectionFns: { selectedSet, getSelectInputModel, getSelectHandler,
|
|
7
|
-
return (_jsxs(EditableRow, { onClick:
|
|
6
|
+
const BodyRows = ({ augFormattedRows, gridSelectionFns: { selectedSet, getSelectInputModel, getSelectHandler, getRowSelectHandler, getAriaSelectedValue, }, tableStyleModel, combinedPipelineOutput: { showSelectCol, ariaColIndexOffset }, selectModel, editModel, getInputStrSubmitCallback, additionalColIndexOffset, renderPrefixCells, additionalRowStyles, }) => augFormattedRows.map((row, index) => {
|
|
7
|
+
return (_jsxs(EditableRow, { onClick: getRowSelectHandler(row.id), className: classNames({
|
|
8
8
|
"table-active": selectedSet.has(row.id),
|
|
9
9
|
}, (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: (colIndex) => (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd)
|
|
10
10
|
? tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd(row.id, index, colIndex)
|
|
@@ -2,51 +2,14 @@
|
|
|
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
|
-
const disabledState = {
|
|
7
|
-
indeterminate: false,
|
|
8
|
-
checked: false,
|
|
9
|
-
disabled: true,
|
|
10
|
-
description: "Select all (disabled)",
|
|
11
|
-
};
|
|
12
|
-
if (noRows) {
|
|
13
|
-
return disabledState;
|
|
14
|
-
}
|
|
15
|
-
const { existingSelection } = selectionInfo;
|
|
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
|
const SelectAllHeaderCell = ({ onClick, selectionInfo, totalRows, customClasses, style, colIndexOffset, }) => {
|
|
44
7
|
const noRows = totalRows === 0;
|
|
45
|
-
const { indeterminate, checked, disabled, description } =
|
|
8
|
+
const { indeterminate, checked, disabled, description } = getSelectionCheckboxState(selectionInfo, noRows);
|
|
46
9
|
const ref = useRef(null);
|
|
47
10
|
useEffect(() => {
|
|
48
11
|
ref.current.indeterminate = indeterminate;
|
|
49
12
|
}, [indeterminate]);
|
|
50
|
-
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 }) }));
|
|
13
|
+
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 }) }));
|
|
51
14
|
};
|
|
52
15
|
export default SelectAllHeaderCell;
|
|
@@ -14,7 +14,7 @@ const SelectionInput = ({ selectionInputModel, selected, selectCallback, additio
|
|
|
14
14
|
selectCallback();
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
return (_jsx("input", { tabIndex: 0, className: classNames(additionalClasses || []), "aria-label": `Select row with index ${index}`, onClick: (event) => {
|
|
17
|
+
return (_jsx("input", { tabIndex: 0, className: classNames(additionalClasses || ["form-check-input"]), "aria-label": `Select row with index ${index}`, onClick: (event) => {
|
|
18
18
|
event.stopPropagation();
|
|
19
19
|
}, type: type, checked: selected, onChange: onChange, name: selectionInputModel.name }));
|
|
20
20
|
};
|
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.
|
package/table-pro/TablePro.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo } from "react";
|
|
|
4
4
|
import useCombinedPipeline from "../common/pipeline/useCombinedPipeline";
|
|
5
5
|
import InternalTable from "../table/InternalTable";
|
|
6
6
|
import ColHeaderCellPro from "./ColHeaderCellPro";
|
|
7
|
-
import
|
|
7
|
+
import useSelectionFns from "../common/pipeline/useSelectionFns";
|
|
8
8
|
import useGetInputStrSubmitCallback from "../common/pipeline/useGetInputStrSubmitCallback";
|
|
9
9
|
import useAugFormattedRows from "../common/pipeline/useAugFormattedRows";
|
|
10
10
|
import useResizeModel from "./resize/useResizeModel";
|
|
@@ -30,7 +30,7 @@ const TablePro = (props) => {
|
|
|
30
30
|
selectModel,
|
|
31
31
|
});
|
|
32
32
|
const { sortedRowsOutput: { sortColDef, setSortColDef, sortingEnabled }, showSelectCol, displayRows, filterState, } = combinedPipelineOutput;
|
|
33
|
-
const gridSelectionFns =
|
|
33
|
+
const gridSelectionFns = useSelectionFns(selectModel, rows);
|
|
34
34
|
const getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
35
35
|
const resizeModel = useResizeModel(cols, displayMode);
|
|
36
36
|
const colNameToWidth = useMemo(() => Object.keys(resizeModel).reduce((prev, fieldName) => {
|
|
@@ -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;
|
|
File without changes
|