@absreim/react-bootstrap-data-grid 2.3.0 → 2.4.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/Grid.d.ts +2 -20
- package/Grid.js +48 -211
- package/InternalGrid.d.ts +19 -0
- package/InternalGrid.js +57 -0
- package/LICENSE +21 -0
- package/editing/EditControlsCell.d.ts +2 -1
- package/editing/EditableRow.d.ts +2 -1
- package/editing/EditableRow.js +5 -4
- package/editing/inputStrsToRowData.d.ts +2 -2
- package/editing/types.d.ts +2 -0
- package/filtering/FilterOptionsTable.js +2 -2
- package/filtering/useFilterFormState.d.ts +3 -0
- package/filtering/{useFormStateFromTableFilterState.js → useFilterFormState.js} +2 -2
- package/main/BodyRows.d.ts +19 -0
- package/main/BodyRows.js +18 -0
- package/main/ColHeaderCell/index.d.ts +4 -0
- package/main/ColHeaderCell/index.js +16 -0
- package/main/ColHeaderCell/useSortHeaderStates.d.ts +9 -0
- package/main/ColHeaderCell/useSortHeaderStates.js +54 -0
- package/package.json +2 -2
- package/pipeline/types.d.ts +1 -0
- package/pipeline/types.js +1 -0
- package/pipeline/useAugFormattedRows.d.ts +4 -0
- package/pipeline/useAugFormattedRows.js +22 -0
- package/pipeline/useCombinedPipeline/index.d.ts +19 -0
- package/pipeline/useCombinedPipeline/index.js +31 -0
- package/pipeline/{useCurrentPageRows.d.ts → useCombinedPipeline/useCurrentPageRows.d.ts} +5 -4
- package/pipeline/{useDisplayRows.d.ts → useCombinedPipeline/useDisplayRows.d.ts} +1 -1
- package/pipeline/{useDisplayRows.js → useCombinedPipeline/useDisplayRows.js} +1 -1
- package/pipeline/{useEditableFromFilterState.d.ts → useCombinedPipeline/useEditableFromFilterState.d.ts} +1 -1
- package/pipeline/{useFilter.d.ts → useCombinedPipeline/useFilter.d.ts} +2 -2
- package/pipeline/{useFilterStateFromEditable.d.ts → useCombinedPipeline/useFilterStateFromEditable.d.ts} +2 -2
- package/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +4 -0
- package/pipeline/useCombinedPipeline/useSortedRows.d.ts +10 -0
- package/pipeline/useGetInputStrSubmitCallback.d.ts +5 -0
- package/pipeline/useGetInputStrSubmitCallback.js +13 -0
- package/pipeline/useGridSelectionFns.d.ts +16 -0
- package/pipeline/useGridSelectionFns.js +131 -0
- package/pipeline/useUnwrappedGridStyles.d.ts +7 -0
- package/pipeline/useUnwrappedGridStyles.js +17 -0
- package/selection/SelectAllHeaderCell.d.ts +2 -1
- package/selection/SelectAllHeaderCell.js +2 -2
- package/selection/types.d.ts +8 -5
- package/sorting/arrowPlaceholder.js +2 -2
- package/style.css +1 -1
- package/style.scss +1 -1
- package/types.d.ts +41 -2
- package/util/getWidthStyle.d.ts +3 -0
- package/util/getWidthStyle.js +9 -0
- package/ColHeaderCell.d.ts +0 -10
- package/ColHeaderCell.js +0 -55
- package/filtering/useFormStateFromTableFilterState.d.ts +0 -3
- package/pipeline/useFilterStateStore.d.ts +0 -4
- package/pipeline/useSortedRows.d.ts +0 -9
- /package/{ToggleButton.d.ts → main/ToggleButton.d.ts} +0 -0
- /package/{ToggleButton.js → main/ToggleButton.js} +0 -0
- /package/pipeline/{useCurrentPageRows.js → useCombinedPipeline/useCurrentPageRows.js} +0 -0
- /package/pipeline/{useEditableFromFilterState.js → useCombinedPipeline/useEditableFromFilterState.js} +0 -0
- /package/pipeline/{useFilter.js → useCombinedPipeline/useFilter.js} +0 -0
- /package/pipeline/{useFilterStateFromEditable.js → useCombinedPipeline/useFilterStateFromEditable.js} +0 -0
- /package/pipeline/{useFilterStateStore.js → useCombinedPipeline/useFilterStateStore.js} +0 -0
- /package/pipeline/{useSortedRows.js → useCombinedPipeline/useSortedRows.js} +0 -0
package/Grid.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { StyleModel } from "./styling/types";
|
|
4
|
-
import { EditModel } from "./editing/types";
|
|
5
|
-
import { SelectModel } from "./selection/types";
|
|
6
|
-
import { FilterModel } from "./filtering/types";
|
|
7
|
-
import { TableSortModel } from "./sorting/types";
|
|
8
|
-
import { GridPaginationState } from "./pagination/types";
|
|
9
|
-
export interface GridProps {
|
|
10
|
-
rows: RowDef[];
|
|
11
|
-
cols: ColDef[];
|
|
12
|
-
pagination?: GridPaginationState;
|
|
13
|
-
sortModel?: TableSortModel;
|
|
14
|
-
filterModel?: FilterModel;
|
|
15
|
-
selectModel?: SelectModel;
|
|
16
|
-
editModel?: EditModel;
|
|
17
|
-
caption?: string;
|
|
18
|
-
styleModel?: StyleModel;
|
|
19
|
-
useToolbar?: boolean;
|
|
20
|
-
responsive?: boolean;
|
|
21
|
-
}
|
|
2
|
+
import { GridProps } from "./types";
|
|
22
3
|
declare const Grid: FC<GridProps>;
|
|
23
4
|
export default Grid;
|
|
5
|
+
export type { GridProps } from "./types";
|
package/Grid.js
CHANGED
|
@@ -1,219 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import EditableRow from "./editing/EditableRow";
|
|
16
|
-
import inputStrsToRowData from "./editing/inputStrsToRowData";
|
|
17
|
-
import { unwrapAdditionalComponentsStyleModel, unwrapTableStyleModel, } from "./styling/styleModelUnwrappers";
|
|
18
|
-
import useCurrentPageRows from "./pipeline/useCurrentPageRows";
|
|
19
|
-
import isSubset from "./util/isSubset";
|
|
20
|
-
import useFilterStateStore from "./pipeline/useFilterStateStore";
|
|
21
|
-
import useInterfaces from "./toolbar/useInterfaces";
|
|
22
|
-
import ToolbarContainer from "./toolbar/ToolbarContainer";
|
|
23
|
-
import useExportFn from "./export/useExportFn";
|
|
24
|
-
var Grid = function (_a) {
|
|
25
|
-
var _b;
|
|
26
|
-
var rows = _a.rows, cols = _a.cols, pagination = _a.pagination, sortModel = _a.sortModel, filterModel = _a.filterModel, selectModel = _a.selectModel, editModel = _a.editModel, caption = _a.caption, styleModel = _a.styleModel, useToolbar = _a.useToolbar, responsive = _a.responsive;
|
|
27
|
-
var normalizedTableFilterModel = useFilterStateStore(filterModel, cols);
|
|
28
|
-
var editableFilterState = (normalizedTableFilterModel === null || normalizedTableFilterModel === void 0 ? void 0 : normalizedTableFilterModel.tableFilterState) || null;
|
|
29
|
-
var filteredRows = useFilter(rows, editableFilterState);
|
|
30
|
-
var filterState = useFilterStateFromEditable(cols, editableFilterState);
|
|
31
|
-
var _c = useSortedRows(filteredRows, cols, sortModel), sortedRows = _c.sortedRows, sortingEnabled = _c.sortingEnabled, sortColDef = _c.sortColDef, setSortColDef = _c.setSortColDef;
|
|
32
|
-
var _d = useCurrentPageRows(sortedRows, pagination), paginatedRows = _d.paginatedRows, normalizedModel = _d.normalizedModel;
|
|
33
|
-
var showSelectCol = selectModel && selectModel.mode !== "row";
|
|
34
|
-
var ariaColIndexOffset = showSelectCol ? 1 : 0;
|
|
35
|
-
var displayRows = useDisplayRows(paginatedRows, cols, ariaColIndexOffset);
|
|
36
|
-
var _e = useState(false), filterOptionsVisible = _e[0], setFilterOptionsVisible = _e[1];
|
|
37
|
-
var exportFnInfo = useExportFn({
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import InternalGrid from "./InternalGrid";
|
|
5
|
+
import ColHeaderCell from "./main/ColHeaderCell";
|
|
6
|
+
import useCombinedPipeline from "./pipeline/useCombinedPipeline";
|
|
7
|
+
import useGridSelectionFns from "./pipeline/useGridSelectionFns";
|
|
8
|
+
import useUnwrappedGridStyles from "./pipeline/useUnwrappedGridStyles";
|
|
9
|
+
import useGetInputStrSubmitCallback from "./pipeline/useGetInputStrSubmitCallback";
|
|
10
|
+
import useAugFormattedRows from "./pipeline/useAugFormattedRows";
|
|
11
|
+
import BodyRows from "./main/BodyRows";
|
|
12
|
+
var Grid = function (props) {
|
|
13
|
+
var rows = props.rows, cols = props.cols, filterModel = props.filterModel, sortModel = props.sortModel, pagination = props.pagination, selectModel = props.selectModel, styleModel = props.styleModel, editModel = props.editModel;
|
|
14
|
+
var combinedPipelineOutput = useCombinedPipeline({
|
|
38
15
|
rows: rows,
|
|
39
16
|
cols: cols,
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
filterModel: filterModel,
|
|
18
|
+
sortModel: sortModel,
|
|
19
|
+
pagination: pagination,
|
|
20
|
+
selectModel: selectModel,
|
|
42
21
|
});
|
|
43
|
-
var
|
|
44
|
-
|
|
22
|
+
var _a = combinedPipelineOutput.sortedRowsOutput, sortColDef = _a.sortColDef, setSortColDef = _a.setSortColDef, sortingEnabled = _a.sortingEnabled, showSelectCol = combinedPipelineOutput.showSelectCol, displayRows = combinedPipelineOutput.displayRows;
|
|
23
|
+
var gridSelectionFns = useGridSelectionFns(selectModel, rows);
|
|
24
|
+
var unwrappedStyles = useUnwrappedGridStyles(styleModel);
|
|
25
|
+
var getInputStrSubmitCallback = useGetInputStrSubmitCallback(editModel, cols);
|
|
26
|
+
var colNameToWidth = useMemo(function () {
|
|
27
|
+
var map = {};
|
|
28
|
+
cols.forEach(function (_a) {
|
|
29
|
+
var name = _a.name, width = _a.width;
|
|
30
|
+
return (map[name] = width);
|
|
31
|
+
});
|
|
32
|
+
return map;
|
|
33
|
+
}, [cols]);
|
|
34
|
+
var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
|
|
35
|
+
var colHeaderCells = cols.map(function (_a, index) {
|
|
36
|
+
var _b;
|
|
37
|
+
var name = _a.name, label = _a.label, sortable = _a.sortable, width = _a.width;
|
|
38
|
+
var colSortModel = sortingEnabled && sortable
|
|
45
39
|
? {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
: undefined,
|
|
52
|
-
exporting: useToolbar
|
|
53
|
-
? { exportFnInfo: exportFnInfo, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel }
|
|
54
|
-
: undefined,
|
|
55
|
-
}); }, [
|
|
56
|
-
exportFnInfo,
|
|
57
|
-
filterModel,
|
|
58
|
-
filterState,
|
|
59
|
-
normalizedTableFilterModel,
|
|
60
|
-
styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
61
|
-
styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
62
|
-
useToolbar,
|
|
63
|
-
]);
|
|
64
|
-
var toolbarInterfaces = useInterfaces(toolbarInterfaceParams);
|
|
65
|
-
var handleToggleFilterOptions = function () {
|
|
66
|
-
setFilterOptionsVisible(!filterOptionsVisible);
|
|
67
|
-
};
|
|
68
|
-
var getSelectionExists = function () {
|
|
69
|
-
if (!selectModel) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
if (selectModel.type === "single") {
|
|
73
|
-
return selectModel.selected !== null;
|
|
74
|
-
}
|
|
75
|
-
return selectModel.selected.length > 0;
|
|
76
|
-
};
|
|
77
|
-
var selectionExists = getSelectionExists();
|
|
78
|
-
var selectAllOnClick = function () {
|
|
79
|
-
if (!selectModel) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (selectionExists && selectModel.type === "single") {
|
|
83
|
-
selectModel.setSelected(null);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (selectionExists && selectModel.type === "multi") {
|
|
87
|
-
selectModel.setSelected([]);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (!selectionExists && selectModel.type === "multi") {
|
|
91
|
-
var allRowIndices = rows.map(function (_, index) { return index; });
|
|
92
|
-
selectModel.setSelected(allRowIndices);
|
|
93
|
-
}
|
|
94
|
-
// Button should be disabled in the case of selectionExists &&
|
|
95
|
-
// selectModel.type === "single", so function execution should never get
|
|
96
|
-
// to this point.
|
|
97
|
-
};
|
|
98
|
-
var getSelectHandler = function (index) { return function () {
|
|
99
|
-
if (!selectModel) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (selectModel.type === "single") {
|
|
103
|
-
selectModel.setSelected(index);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
selectModel.setSelected(selectModel.selected.concat(index));
|
|
107
|
-
}; };
|
|
108
|
-
var getDeselectHandler = function (index) { return function () {
|
|
109
|
-
if (!selectModel || selectModel.type === "single") {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
selectModel.setSelected(selectModel.selected.filter(function (num) { return num !== index; }));
|
|
113
|
-
}; };
|
|
114
|
-
// used to group radio buttons for selection
|
|
115
|
-
var gridId = useId();
|
|
116
|
-
var getSelectInputModel = function (id, selectModel) {
|
|
117
|
-
if (selectModel.type === "single") {
|
|
118
|
-
return {
|
|
119
|
-
type: "radio",
|
|
120
|
-
name: selectModel.groupName || gridId,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
type: "checkbox",
|
|
125
|
-
deselectCallback: getDeselectHandler(id),
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
var selectedSet = new Set();
|
|
129
|
-
if (selectModel && selectModel.type === "multi") {
|
|
130
|
-
selectModel.selected.forEach(function (value) { return selectedSet.add(value); });
|
|
131
|
-
}
|
|
132
|
-
if (selectModel &&
|
|
133
|
-
selectModel.type === "single" &&
|
|
134
|
-
selectModel.selected !== null) {
|
|
135
|
-
selectedSet.add(selectModel.selected);
|
|
136
|
-
}
|
|
137
|
-
var rowsAreSelectable = !!(selectModel && selectModel.mode !== "column");
|
|
138
|
-
var selectionInfo = useMemo(function () {
|
|
139
|
-
if (!selectModel) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
if (selectModel.type === "single") {
|
|
143
|
-
return {
|
|
144
|
-
selectType: "single",
|
|
145
|
-
existingSelection: selectionExists,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
var getMultiExistingSelection = function (selectionExists, rows) {
|
|
149
|
-
var rowIndices = rows.map(function (_, index) { return index; });
|
|
150
|
-
// Note that isFullSelection is true if there are no rows at all. In that case, the return value of this function
|
|
151
|
-
// should be "none", not "full".
|
|
152
|
-
var isFullSelection = isSubset(rowIndices, selectModel.selected);
|
|
153
|
-
if (!selectionExists) {
|
|
154
|
-
return "none";
|
|
155
|
-
}
|
|
156
|
-
if (isFullSelection) {
|
|
157
|
-
return "full";
|
|
40
|
+
sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === name ? sortColDef.order : null,
|
|
41
|
+
setSortOrder: function (order) {
|
|
42
|
+
setSortColDef && setSortColDef(order && { name: name, order: order });
|
|
43
|
+
},
|
|
158
44
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
if (selectedSet.has(index)) {
|
|
171
|
-
getDeselectHandler(index)();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
getSelectHandler(index)();
|
|
175
|
-
}; };
|
|
176
|
-
var getAriaSelectedValue = function (id) {
|
|
177
|
-
if (!selectModel) {
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
return String(selectedSet.has(id));
|
|
181
|
-
};
|
|
182
|
-
var getInputStrSubmitCallback = editModel &&
|
|
183
|
-
(function (id) {
|
|
184
|
-
var idSpecificCallback = editModel.getUpdateCallback(id);
|
|
185
|
-
return function (inputStrs) {
|
|
186
|
-
var rowData = inputStrsToRowData(cols, inputStrs);
|
|
187
|
-
idSpecificCallback(rowData);
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
var unwrappedTableModel = useMemo(function () { return unwrapTableStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel); }, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel]);
|
|
191
|
-
var unwrappedAdditionalStyleModel = useMemo(function () {
|
|
192
|
-
return unwrapAdditionalComponentsStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel);
|
|
193
|
-
}, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel]);
|
|
194
|
-
var mainTable = (_jsxs("table", { className: classNames("table", {
|
|
195
|
-
"table-hover": rowsAreSelectable,
|
|
196
|
-
}, unwrappedTableModel.table), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames(unwrappedTableModel.caption), children: caption })), _jsx("thead", { className: classNames(unwrappedTableModel.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames(unwrappedTableModel.theadTr), children: [showSelectCol && (_jsx(SelectAllHeaderCell, { selectionInfo: selectionInfo, onClick: selectAllOnClick, totalRows: rows.length, additionalClasses: unwrappedTableModel.rowSelectColTh })), cols.map(function (_a, index) {
|
|
197
|
-
var name = _a.name, label = _a.label, sortable = _a.sortable;
|
|
198
|
-
var colSortModel = sortingEnabled && sortable
|
|
199
|
-
? {
|
|
200
|
-
sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === name ? sortColDef.order : null,
|
|
201
|
-
setSortOrder: function (order) {
|
|
202
|
-
setSortColDef && setSortColDef(order && { name: name, order: order });
|
|
203
|
-
},
|
|
204
|
-
}
|
|
205
|
-
: undefined;
|
|
206
|
-
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: unwrappedTableModel.theadTh(index) }, name));
|
|
207
|
-
}), editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: displayRows.map(function (row, index) {
|
|
208
|
-
return (_jsx(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
209
|
-
"table-active": selectedSet.has(row.id),
|
|
210
|
-
}, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": index + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset, cellData: row.contents, updateCallback: getInputStrSubmitCallback && getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) &&
|
|
211
|
-
editModel.getDeleteCallback(row.id), dataCellClasses: function (colIndex) {
|
|
212
|
-
return unwrappedTableModel.tbodyTd(row.id, index, colIndex);
|
|
213
|
-
}, dataCellInputClasses: function (colIndex) {
|
|
214
|
-
return unwrappedTableModel.tbodyTdInput(row.id, index, colIndex);
|
|
215
|
-
}, editCellClasses: unwrappedTableModel.editColTd(row.id, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.id, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.id, index), startButtonClasses: unwrappedTableModel.editStartButton(row.id, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.id, index), children: showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.id, index)), "aria-colindex": 1, children: _jsx(SelectionInput, { selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: unwrappedTableModel.rowSelectInput(row.id, index) }) })) }, row.id));
|
|
216
|
-
}) })] }));
|
|
217
|
-
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && !useToolbar && (_jsxs("div", { "data-testid": "rbdg-filter-inputs-div", className: classNames(unwrappedAdditionalStyleModel.filterInputsDiv), children: [_jsx(ToggleButton, { isActive: filterOptionsVisible, label: "".concat(filterOptionsVisible ? "Hide" : "Show ", " Filter Options"), onClick: handleToggleFilterOptions, classes: (_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _b === void 0 ? void 0 : _b.filterUiToggleButton }), filterOptionsVisible && (_jsx(FilterOptionsTable, { caption: filterModel.filterTableCaption, filterState: filterState, setFilterState: normalizedTableFilterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), useToolbar && (_jsx(ToolbarContainer, { interfaces: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [responsive ? (_jsx("div", { "data-testid": "rbdg-table-div", className: "table-responsive", children: mainTable })) : (_jsx(_Fragment, { children: mainTable })), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: unwrappedAdditionalStyleModel.paginationUiDiv }))] })] }));
|
|
45
|
+
: undefined;
|
|
46
|
+
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: ((_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel) === null || _b === void 0 ? void 0 : _b.theadTh) &&
|
|
47
|
+
styleModel.mainTableStyleModel.theadTh(index), width: width }, name));
|
|
48
|
+
});
|
|
49
|
+
var bodyRows = (_jsx(BodyRows, { augFormattedRows: augFormattedRows, gridSelectionFns: gridSelectionFns, selectModel: selectModel, unwrappedStyles: unwrappedStyles, combinedPipelineOutput: combinedPipelineOutput, editModel: editModel, getInputStrSubmitCallback: getInputStrSubmitCallback }));
|
|
50
|
+
return (_jsx(InternalGrid, { gridProps: props, hooks: {
|
|
51
|
+
pipelineOutput: combinedPipelineOutput,
|
|
52
|
+
selectFns: gridSelectionFns,
|
|
53
|
+
unwrappedStyles: unwrappedStyles,
|
|
54
|
+
}, slots: { colHeaderCells: colHeaderCells, bodyRows: bodyRows } }));
|
|
218
55
|
};
|
|
219
56
|
export default Grid;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { BaseGridProps } from "./types";
|
|
3
|
+
import { UseCombinedPipelineHook } from "./pipeline/useCombinedPipeline";
|
|
4
|
+
import { UseGridSelectionFnsHook } from "./pipeline/useGridSelectionFns";
|
|
5
|
+
import { UseUnwrappedGridStylesHook } from "./pipeline/useUnwrappedGridStyles";
|
|
6
|
+
export interface InternalGridProps {
|
|
7
|
+
gridProps: BaseGridProps;
|
|
8
|
+
hooks: {
|
|
9
|
+
selectFns: UseGridSelectionFnsHook;
|
|
10
|
+
pipelineOutput: UseCombinedPipelineHook;
|
|
11
|
+
unwrappedStyles: UseUnwrappedGridStylesHook;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
colHeaderCells: ReactNode;
|
|
15
|
+
bodyRows: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
declare const InternalGrid: FC<InternalGridProps>;
|
|
19
|
+
export default InternalGrid;
|
package/InternalGrid.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import ToggleButton from "./main/ToggleButton";
|
|
5
|
+
import FilterOptionsTable from "./filtering/FilterOptionsTable";
|
|
6
|
+
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
7
|
+
import Pagination from "./pagination/Pagination";
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import useInterfaces from "./toolbar/useInterfaces";
|
|
10
|
+
import ToolbarContainer from "./toolbar/ToolbarContainer";
|
|
11
|
+
import useExportFn from "./export/useExportFn";
|
|
12
|
+
import getWidthStyle from "./util/getWidthStyle";
|
|
13
|
+
var InternalGrid = function (_a) {
|
|
14
|
+
var _b;
|
|
15
|
+
var _c = _a.gridProps, rows = _c.rows, cols = _c.cols, pagination = _c.pagination, filterModel = _c.filterModel, selectModel = _c.selectModel, editModel = _c.editModel, caption = _c.caption, styleModel = _c.styleModel, useToolbar = _c.useToolbar, responsive = _c.responsive, displayMode = _c.displayMode, _d = _a.hooks, pipelineOutput = _d.pipelineOutput, selectFns = _d.selectFns, unwrappedStyles = _d.unwrappedStyles, _e = _a.slots, colHeaderCells = _e.colHeaderCells, bodyRows = _e.bodyRows;
|
|
16
|
+
var normalizedTableFilterModel = pipelineOutput.normalizedTableFilterModel, filteredRows = pipelineOutput.filteredRows, filterState = pipelineOutput.filterState, sortedRows = pipelineOutput.sortedRowsOutput.sortedRows, _f = pipelineOutput.currentPageRowsOutput, paginatedRows = _f.paginatedRows, normalizedModel = _f.normalizedModel, showSelectCol = pipelineOutput.showSelectCol;
|
|
17
|
+
var _g = useState(false), filterOptionsVisible = _g[0], setFilterOptionsVisible = _g[1];
|
|
18
|
+
var exportFnInfo = useExportFn({
|
|
19
|
+
rows: rows,
|
|
20
|
+
cols: cols,
|
|
21
|
+
filteredRows: filterModel && filteredRows,
|
|
22
|
+
currentPageRows: pagination && paginatedRows,
|
|
23
|
+
});
|
|
24
|
+
var toolbarInterfaceParams = useMemo(function () { return ({
|
|
25
|
+
filtering: useToolbar && filterState && filterModel && normalizedTableFilterModel
|
|
26
|
+
? {
|
|
27
|
+
filterState: filterState,
|
|
28
|
+
setFilterState: normalizedTableFilterModel.setTableFilterState,
|
|
29
|
+
caption: filterModel.filterTableCaption,
|
|
30
|
+
styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
31
|
+
}
|
|
32
|
+
: undefined,
|
|
33
|
+
exporting: useToolbar
|
|
34
|
+
? { exportFnInfo: exportFnInfo, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel }
|
|
35
|
+
: undefined,
|
|
36
|
+
}); }, [
|
|
37
|
+
exportFnInfo,
|
|
38
|
+
filterModel,
|
|
39
|
+
filterState,
|
|
40
|
+
normalizedTableFilterModel,
|
|
41
|
+
styleModel === null || styleModel === void 0 ? void 0 : styleModel.exportFormStyleModel,
|
|
42
|
+
styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel,
|
|
43
|
+
useToolbar,
|
|
44
|
+
]);
|
|
45
|
+
var toolbarInterfaces = useInterfaces(toolbarInterfaceParams);
|
|
46
|
+
var handleToggleFilterOptions = function () {
|
|
47
|
+
setFilterOptionsVisible(!filterOptionsVisible);
|
|
48
|
+
};
|
|
49
|
+
var rowsAreSelectable = selectFns.rowsAreSelectable, selectionInfo = selectFns.selectionInfo, selectAllOnClick = selectFns.selectAllOnClick;
|
|
50
|
+
var unwrappedTableModel = unwrappedStyles.unwrappedTableModel, unwrappedAdditionalStyleModel = unwrappedStyles.unwrappedAdditionalStyleModel;
|
|
51
|
+
var mainTable = (_jsxs("table", { className: classNames("table", {
|
|
52
|
+
"table-hover": rowsAreSelectable,
|
|
53
|
+
"d-block": displayMode === "block",
|
|
54
|
+
}, unwrappedTableModel.table), "aria-rowcount": filteredRows.length + 1, children: [caption !== undefined && (_jsx("caption", { className: classNames(unwrappedTableModel.caption), children: caption })), _jsx("thead", { className: classNames(unwrappedTableModel.thead), children: _jsxs("tr", { "aria-rowindex": 1, className: classNames(unwrappedTableModel.theadTr), children: [showSelectCol && (_jsx(SelectAllHeaderCell, { style: getWidthStyle(selectModel === null || selectModel === void 0 ? void 0 : selectModel.selectColWidth), selectionInfo: selectionInfo, onClick: selectAllOnClick, totalRows: rows.length, additionalClasses: unwrappedTableModel.rowSelectColTh })), colHeaderCells, editModel && (_jsx("th", { "aria-colindex": cols.length + 1 + (showSelectCol ? 1 : 0), className: classNames(unwrappedTableModel.editColTh), style: getWidthStyle(editModel === null || editModel === void 0 ? void 0 : editModel.editColWidth), children: "Edit Controls" }))] }) }), _jsx("tbody", { className: classNames(unwrappedTableModel.tbody), children: bodyRows })] }));
|
|
55
|
+
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && !useToolbar && (_jsxs("div", { "data-testid": "rbdg-filter-inputs-div", className: classNames(unwrappedAdditionalStyleModel.filterInputsDiv), children: [_jsx(ToggleButton, { isActive: filterOptionsVisible, label: "".concat(filterOptionsVisible ? "Hide" : "Show ", " Filter Options"), onClick: handleToggleFilterOptions, classes: (_b = styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel) === null || _b === void 0 ? void 0 : _b.filterUiToggleButton }), filterOptionsVisible && (_jsx(FilterOptionsTable, { caption: filterModel.filterTableCaption, filterState: filterState, setFilterState: normalizedTableFilterModel.setTableFilterState, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputTableStyleModel }))] })), useToolbar && (_jsx(ToolbarContainer, { interfaces: toolbarInterfaces, styleModel: styleModel === null || styleModel === void 0 ? void 0 : styleModel.toolbarStyleModel })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [responsive ? (_jsx("div", { "data-testid": "rbdg-table-div", className: "table-responsive", children: mainTable })) : (_jsx(_Fragment, { children: mainTable })), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length, containerDivClasses: unwrappedAdditionalStyleModel.paginationUiDiv }))] })] }));
|
|
56
|
+
};
|
|
57
|
+
export default InternalGrid;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brook Li
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
1
|
+
import { CSSProperties, FC } from "react";
|
|
2
2
|
export interface EditControlsCellProps {
|
|
3
3
|
ariaColIndex: number;
|
|
4
4
|
beginEditingCallback: () => void;
|
|
@@ -11,6 +11,7 @@ export interface EditControlsCellProps {
|
|
|
11
11
|
deleteButtonClasses: string[];
|
|
12
12
|
startButtonClasses: string[];
|
|
13
13
|
cancelButtonClasses: string[];
|
|
14
|
+
style?: CSSProperties;
|
|
14
15
|
}
|
|
15
16
|
declare const EditControlsCell: FC<EditControlsCellProps>;
|
|
16
17
|
export default EditControlsCell;
|
package/editing/EditableRow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, ReactNode } from "react";
|
|
1
|
+
import { CSSProperties, FC, ReactNode } from "react";
|
|
2
2
|
import { RowId } from "../types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { CellData } from "./types";
|
|
@@ -16,6 +16,7 @@ export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "cla
|
|
|
16
16
|
cancelButtonClasses: string[];
|
|
17
17
|
startButtonClasses: string[];
|
|
18
18
|
saveButtonClasses: string[];
|
|
19
|
+
editControlCellStyles?: CSSProperties;
|
|
19
20
|
};
|
|
20
21
|
declare const EditableRow: FC<EditableRowProps>;
|
|
21
22
|
export default EditableRow;
|
package/editing/EditableRow.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useRef, useState } from "react";
|
|
|
4
4
|
import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
|
|
5
5
|
import EditControlsCell from "./EditControlsCell";
|
|
6
6
|
import classNames from "classnames";
|
|
7
|
+
import getWidthStyle from "../util/getWidthStyle";
|
|
7
8
|
var initValueToFormValue = function (value, type) {
|
|
8
9
|
switch (type) {
|
|
9
10
|
case "date":
|
|
@@ -29,7 +30,7 @@ var colDataTypeToInputType = function (colDataType) {
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
var EditableRow = function (_a) {
|
|
32
|
-
var ariaColIndexOffset = _a.ariaColIndexOffset, cellData = _a.cellData, children = _a.children, updateCallback = _a.updateCallback, deleteCallback = _a.deleteCallback, onClick = _a.onClick, className = _a.className, ariaRowIndex = _a["aria-rowindex"], ariaSelected = _a["aria-selected"], dataRowId = _a.dataRowId, dataCellClasses = _a.dataCellClasses, dataCellInputClasses = _a.dataCellInputClasses, editCellClasses = _a.editCellClasses, saveButtonClasses = _a.saveButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses, deleteButtonClasses = _a.deleteButtonClasses;
|
|
33
|
+
var ariaColIndexOffset = _a.ariaColIndexOffset, cellData = _a.cellData, children = _a.children, updateCallback = _a.updateCallback, deleteCallback = _a.deleteCallback, onClick = _a.onClick, className = _a.className, ariaRowIndex = _a["aria-rowindex"], ariaSelected = _a["aria-selected"], dataRowId = _a.dataRowId, dataCellClasses = _a.dataCellClasses, dataCellInputClasses = _a.dataCellInputClasses, editCellClasses = _a.editCellClasses, saveButtonClasses = _a.saveButtonClasses, startButtonClasses = _a.startButtonClasses, cancelButtonClasses = _a.cancelButtonClasses, deleteButtonClasses = _a.deleteButtonClasses, editControlCellStyles = _a.editControlCellStyles;
|
|
33
34
|
var trRef = useRef(null);
|
|
34
35
|
var _b = useState(false), isEditing = _b[0], setIsEditing = _b[1];
|
|
35
36
|
var handleSave = function () {
|
|
@@ -60,8 +61,8 @@ var EditableRow = function (_a) {
|
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-rowid": dataRowId, children: [children, cellData.map(function (_a, index) {
|
|
63
|
-
var type = _a.type, value = _a.value, formattedValue = _a.formattedValue, label = _a.label;
|
|
64
|
-
return (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: "editable-cell-input-".concat(dataRowId, "-").concat(index), className: classNames("form-control", dataCellInputClasses(index)), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
|
|
65
|
-
}), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: function () { return setIsEditing(true); }, cancelEditingCallback: function () { return setIsEditing(false); }, isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses }))] }));
|
|
64
|
+
var type = _a.type, value = _a.value, formattedValue = _a.formattedValue, label = _a.label, width = _a.width;
|
|
65
|
+
return (_jsx("td", { "aria-colindex": index + ariaColIndexOffset + 1, className: classNames(dataCellClasses(index)), style: getWidthStyle(width), children: isEditing && !!updateCallback ? (_jsx("input", { "aria-label": label, name: "editable-cell-input-".concat(dataRowId, "-").concat(index), className: classNames("form-control", dataCellInputClasses(index)), type: colDataTypeToInputType(type), defaultValue: initValueToFormValue(value, type), required: type !== "string" })) : (formattedValue) }, index));
|
|
66
|
+
}), updateCallback && (_jsx(EditControlsCell, { ariaColIndex: ariaColIndexOffset + cellData.length + 1, beginEditingCallback: function () { return setIsEditing(true); }, cancelEditingCallback: function () { return setIsEditing(false); }, isEditing: isEditing, saveCallback: handleSave, deleteCallback: deleteCallback, editControlsCellClasses: editCellClasses, startButtonClasses: startButtonClasses, deleteButtonClasses: deleteButtonClasses, cancelButtonClasses: cancelButtonClasses, saveButtonClasses: saveButtonClasses, style: editControlCellStyles }))] }));
|
|
66
67
|
};
|
|
67
68
|
export default EditableRow;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const inputStrsToRowData: (cols:
|
|
1
|
+
import { ColDefBase, RowData } from "../types";
|
|
2
|
+
declare const inputStrsToRowData: (cols: ColDefBase[], inputStrs: string[]) => RowData;
|
|
3
3
|
export default inputStrsToRowData;
|
package/editing/types.d.ts
CHANGED
|
@@ -6,9 +6,11 @@ export interface CellData {
|
|
|
6
6
|
ariaColIndex: number;
|
|
7
7
|
formattedValue: string;
|
|
8
8
|
label: string;
|
|
9
|
+
width?: number;
|
|
9
10
|
}
|
|
10
11
|
export type UpdateCallbackGenerator = (id: RowId) => (rowData: RowData) => void;
|
|
11
12
|
export interface EditModel {
|
|
12
13
|
getUpdateCallback: UpdateCallbackGenerator;
|
|
13
14
|
getDeleteCallback?: (id: RowId) => () => void;
|
|
15
|
+
editColWidth?: number;
|
|
14
16
|
}
|
|
@@ -22,7 +22,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
import { useMemo, useState } from "react";
|
|
23
23
|
import StringFilterRow from "./StringFilterRow";
|
|
24
24
|
import NumberFilterRow from "./NumberFilterRow";
|
|
25
|
-
import
|
|
25
|
+
import useFilterFormState from "./useFilterFormState";
|
|
26
26
|
import DateFilterRow from "./DateFilterRow";
|
|
27
27
|
import classNames from "classnames";
|
|
28
28
|
import { unwrapFilterInputTableStyleModel } from "../styling/styleModelUnwrappers";
|
|
@@ -74,7 +74,7 @@ var convertFilterFormStateToEditableState = function (filterFormState) {
|
|
|
74
74
|
};
|
|
75
75
|
var FilterOptionsTable = function (_a) {
|
|
76
76
|
var filterState = _a.filterState, setFilterState = _a.setFilterState, caption = _a.caption, styleModel = _a.styleModel;
|
|
77
|
-
var formFilterState =
|
|
77
|
+
var formFilterState = useFilterFormState(filterState);
|
|
78
78
|
var _b = useState(formFilterState), formState = _b[0], setFormState = _b[1];
|
|
79
79
|
var unwrappedStyleModel = useMemo(function () { return unwrapFilterInputTableStyleModel(styleModel); }, [styleModel]);
|
|
80
80
|
var getRows = function () {
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { useMemo } from "react";
|
|
13
13
|
import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
|
|
14
|
-
var
|
|
14
|
+
var useFilterFormState = function (tableFilterState) {
|
|
15
15
|
return useMemo(function () {
|
|
16
16
|
return Object.keys(tableFilterState).reduce(function (filterFormState, colName) {
|
|
17
17
|
var editableState = tableFilterState[colName].editableState;
|
|
@@ -69,4 +69,4 @@ var useFormStateFromTableFilterState = function (tableFilterState) {
|
|
|
69
69
|
}, {});
|
|
70
70
|
}, [tableFilterState]);
|
|
71
71
|
};
|
|
72
|
-
export default
|
|
72
|
+
export default useFilterFormState;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AugFormattedRow } from "../types";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
import { UseGridSelectionFnsHook } from "../pipeline/useGridSelectionFns";
|
|
4
|
+
import { UseUnwrappedGridStylesHook } from "../pipeline/useUnwrappedGridStyles";
|
|
5
|
+
import { UseCombinedPipelineHook } from "../pipeline/useCombinedPipeline";
|
|
6
|
+
import { SelectModel } from "../selection/types";
|
|
7
|
+
import { EditModel } from "../editing/types";
|
|
8
|
+
import { UseGetInputStrSubmitCallbackHook } from "../pipeline/useGetInputStrSubmitCallback";
|
|
9
|
+
interface BodyRowsProps {
|
|
10
|
+
augFormattedRows: AugFormattedRow[];
|
|
11
|
+
gridSelectionFns: UseGridSelectionFnsHook;
|
|
12
|
+
unwrappedStyles: UseUnwrappedGridStylesHook;
|
|
13
|
+
combinedPipelineOutput: UseCombinedPipelineHook;
|
|
14
|
+
selectModel: SelectModel | undefined;
|
|
15
|
+
editModel: EditModel | undefined;
|
|
16
|
+
getInputStrSubmitCallback: UseGetInputStrSubmitCallbackHook;
|
|
17
|
+
}
|
|
18
|
+
declare const BodyRows: FC<BodyRowsProps>;
|
|
19
|
+
export default BodyRows;
|
package/main/BodyRows.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import EditableRow from "../editing/EditableRow";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import getWidthStyle from "../util/getWidthStyle";
|
|
5
|
+
import SelectionInput from "../selection/SelectionInput";
|
|
6
|
+
var BodyRows = function (_a) {
|
|
7
|
+
var augFormattedRows = _a.augFormattedRows, _b = _a.gridSelectionFns, selectedSet = _b.selectedSet, getSelectInputModel = _b.getSelectInputModel, getSelectHandler = _b.getSelectHandler, getRowClickHandler = _b.getRowClickHandler, getAriaSelectedValue = _b.getAriaSelectedValue, unwrappedTableModel = _a.unwrappedStyles.unwrappedTableModel, _c = _a.combinedPipelineOutput, showSelectCol = _c.showSelectCol, ariaColIndexOffset = _c.ariaColIndexOffset, selectModel = _a.selectModel, editModel = _a.editModel, getInputStrSubmitCallback = _a.getInputStrSubmitCallback;
|
|
8
|
+
return augFormattedRows.map(function (row, index) {
|
|
9
|
+
return (_jsx(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
10
|
+
"table-active": selectedSet.has(row.id),
|
|
11
|
+
}, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": index + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset, 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
|
+
return unwrappedTableModel.tbodyTd(row.id, index, colIndex);
|
|
13
|
+
}, dataCellInputClasses: function (colIndex) {
|
|
14
|
+
return unwrappedTableModel.tbodyTdInput(row.id, index, colIndex);
|
|
15
|
+
}, editCellClasses: unwrappedTableModel.editColTd(row.id, index), saveButtonClasses: unwrappedTableModel.editSaveButton(row.id, index), deleteButtonClasses: unwrappedTableModel.editDeleteButton(row.id, index), startButtonClasses: unwrappedTableModel.editStartButton(row.id, index), cancelButtonClasses: unwrappedTableModel.editCancelButton(row.id, index), children: showSelectCol && (_jsx("td", { className: classNames(unwrappedTableModel.rowSelectColTd(row.id, index)), "aria-colindex": 1, style: getWidthStyle(selectModel.selectColWidth), children: _jsx(SelectionInput, { selected: selectedSet.has(row.id), selectionInputModel: getSelectInputModel(row.id, selectModel), selectCallback: getSelectHandler(row.id), additionalClasses: unwrappedTableModel.rowSelectInput(row.id, index) }) })) }, row.id));
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export default BodyRows;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import getWidthStyle from "../../util/getWidthStyle";
|
|
5
|
+
import useSortHeaderStates from "./useSortHeaderStates";
|
|
6
|
+
var ColHeaderCell = function (_a) {
|
|
7
|
+
var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex, additionalClasses = _a.additionalClasses, width = _a.width;
|
|
8
|
+
var _b = useSortHeaderStates(sortModel), handleClick = _b.handleClick, handleMouseOver = _b.handleMouseOver, handleMouseOut = _b.handleMouseOut, sortSymbol = _b.sortSymbol;
|
|
9
|
+
return (_jsxs("th", { className: classNames({
|
|
10
|
+
"rbdg-clickable-grid-header-cell": sortModel,
|
|
11
|
+
"table-active": sortModel === null || sortModel === void 0 ? void 0 : sortModel.sortOrder,
|
|
12
|
+
}, additionalClasses || []), onClick: sortModel && handleClick, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, "aria-description": sortModel
|
|
13
|
+
? "Column header"
|
|
14
|
+
: "Column header that can be clicked to change the sorting mode", "aria-colindex": ariaColIndex, style: getWidthStyle(width), children: [label, sortSymbol] }));
|
|
15
|
+
};
|
|
16
|
+
export default ColHeaderCell;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseControlledHoverHook } from "../../util/useControlledHover";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { ColSortModel } from "../../sorting/types";
|
|
4
|
+
export type UseSortHeaderStatesHook = UseControlledHoverHook<HTMLTableCellElement> & {
|
|
5
|
+
handleClick: () => void;
|
|
6
|
+
sortSymbol: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
declare const useSortHeaderStates: (sortModel: ColSortModel | undefined) => UseSortHeaderStatesHook;
|
|
9
|
+
export default useSortHeaderStates;
|