@absreim/react-bootstrap-data-grid 1.4.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Grid.js +35 -37
- package/README.md +1 -1
- package/editing/EditableRow.d.ts +2 -1
- package/editing/EditableRow.js +3 -3
- package/editing/inputStrsToRowData.d.ts +3 -0
- package/editing/{inputStrsToRowDef.js → inputStrsToRowData.js} +2 -2
- package/editing/types.d.ts +3 -3
- package/filtering/types.d.ts +7 -1
- package/package.json +1 -1
- package/pagination/Pagination.d.ts +3 -8
- package/pagination/Pagination.js +5 -4
- package/pagination/types.d.ts +17 -7
- package/pipeline/useCurrentPageRows.d.ts +6 -3
- package/pipeline/useCurrentPageRows.js +45 -7
- package/pipeline/useDisplayRows.d.ts +2 -2
- package/pipeline/useDisplayRows.js +5 -4
- package/pipeline/useFilter.d.ts +2 -2
- package/pipeline/useFilterStateStore.d.ts +4 -0
- package/pipeline/useFilterStateStore.js +57 -0
- package/pipeline/useSortedRows.d.ts +8 -3
- package/pipeline/useSortedRows.js +16 -6
- package/selection/types.d.ts +6 -5
- package/selection/types.js +1 -1
- package/sorting/types.d.ts +7 -1
- package/style.scss +1 -1
- package/styling/types.d.ts +11 -10
- package/types.d.ts +10 -10
- package/util/isSubset.d.ts +1 -1
- package/util/isSubset.js +2 -2
- package/editing/inputStrsToRowDef.d.ts +0 -3
- package/pipeline/useAugmentedRows.d.ts +0 -3
- package/pipeline/useAugmentedRows.js +0 -12
package/Grid.js
CHANGED
|
@@ -6,7 +6,6 @@ import useFilter from "./pipeline/useFilter";
|
|
|
6
6
|
import ToggleButton from "./ToggleButton";
|
|
7
7
|
import FilterOptionsTable from "./filtering/FilterOptionsTable";
|
|
8
8
|
import useFilterStateFromEditable from "./pipeline/useFilterStateFromEditable";
|
|
9
|
-
import useAugmentedRows from "./pipeline/useAugmentedRows";
|
|
10
9
|
import useSortedRows from "./pipeline/useSortedRows";
|
|
11
10
|
import useDisplayRows from "./pipeline/useDisplayRows";
|
|
12
11
|
import SelectAllHeaderCell from "./selection/SelectAllHeaderCell";
|
|
@@ -14,23 +13,24 @@ import SelectionInput from "./selection/SelectionInput";
|
|
|
14
13
|
import Pagination from "./pagination/Pagination";
|
|
15
14
|
import classNames from "classnames";
|
|
16
15
|
import EditableRow from "./editing/EditableRow";
|
|
17
|
-
import
|
|
16
|
+
import inputStrsToRowData from "./editing/inputStrsToRowData";
|
|
18
17
|
import { unwrapAdditionalComponentsStyleModel, unwrapTableStyleModel, } from "./styling/styleModelUnwrappers";
|
|
19
18
|
import useCurrentPageRows from "./pipeline/useCurrentPageRows";
|
|
20
19
|
import isSubset from "./util/isSubset";
|
|
20
|
+
import useFilterStateStore from "./pipeline/useFilterStateStore";
|
|
21
21
|
var Grid = function (_a) {
|
|
22
22
|
var _b;
|
|
23
23
|
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;
|
|
24
|
-
var
|
|
24
|
+
var normalizedTableFilterModel = useFilterStateStore(filterModel, cols);
|
|
25
|
+
var editableFilterState = (normalizedTableFilterModel === null || normalizedTableFilterModel === void 0 ? void 0 : normalizedTableFilterModel.tableFilterState) || null;
|
|
26
|
+
var filteredRows = useFilter(rows, editableFilterState);
|
|
25
27
|
var filterState = useFilterStateFromEditable(cols, editableFilterState);
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var sortedRows = useSortedRows(filteredRows, cols, sortModel);
|
|
29
|
-
var currentPageRows = useCurrentPageRows(sortedRows, pagination);
|
|
28
|
+
var _c = useSortedRows(filteredRows, cols, sortModel), sortedRows = _c.sortedRows, sortingEnabled = _c.sortingEnabled, sortColDef = _c.sortColDef, setSortColDef = _c.setSortColDef;
|
|
29
|
+
var _d = useCurrentPageRows(sortedRows, pagination), paginatedRows = _d.paginatedRows, normalizedModel = _d.normalizedModel;
|
|
30
30
|
var showSelectCol = selectModel && selectModel.mode !== "row";
|
|
31
31
|
var ariaColIndexOffset = showSelectCol ? 1 : 0;
|
|
32
|
-
var displayRows = useDisplayRows(
|
|
33
|
-
var
|
|
32
|
+
var displayRows = useDisplayRows(paginatedRows, cols, ariaColIndexOffset);
|
|
33
|
+
var _e = useState(false), filterOptionsVisible = _e[0], setFilterOptionsVisible = _e[1];
|
|
34
34
|
var handleToggleFilterOptions = function () {
|
|
35
35
|
setFilterOptionsVisible(!filterOptionsVisible);
|
|
36
36
|
};
|
|
@@ -81,7 +81,7 @@ var Grid = function (_a) {
|
|
|
81
81
|
selectModel.setSelected(selectModel.selected.filter(function (num) { return num !== index; }));
|
|
82
82
|
}; };
|
|
83
83
|
// used to group radio buttons for selection
|
|
84
|
-
var getSelectInputModel = function (
|
|
84
|
+
var getSelectInputModel = function (id, selectModel) {
|
|
85
85
|
if (selectModel.type === "single") {
|
|
86
86
|
return {
|
|
87
87
|
type: "radio",
|
|
@@ -90,7 +90,7 @@ var Grid = function (_a) {
|
|
|
90
90
|
}
|
|
91
91
|
return {
|
|
92
92
|
type: "checkbox",
|
|
93
|
-
deselectCallback: getDeselectHandler(
|
|
93
|
+
deselectCallback: getDeselectHandler(id),
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
var selectedSet = new Set();
|
|
@@ -110,14 +110,14 @@ var Grid = function (_a) {
|
|
|
110
110
|
if (selectModel.type === "single") {
|
|
111
111
|
return {
|
|
112
112
|
selectType: "single",
|
|
113
|
-
existingSelection: selectionExists
|
|
113
|
+
existingSelection: selectionExists,
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
var getMultiExistingSelection = function (selectionExists, rows) {
|
|
117
117
|
var rowIndices = rows.map(function (_, index) { return index; });
|
|
118
|
-
|
|
119
|
-
// Note that isFullSelection is true if there are no rows at all. In that case, the existing selection value
|
|
118
|
+
// Note that isFullSelection is true if there are no rows at all. In that case, the return value of this function
|
|
120
119
|
// should be "none", not "full".
|
|
120
|
+
var isFullSelection = isSubset(rowIndices, selectModel.selected);
|
|
121
121
|
if (!selectionExists) {
|
|
122
122
|
return "none";
|
|
123
123
|
}
|
|
@@ -128,7 +128,7 @@ var Grid = function (_a) {
|
|
|
128
128
|
};
|
|
129
129
|
return {
|
|
130
130
|
selectType: "multi",
|
|
131
|
-
existingSelection: getMultiExistingSelection(selectionExists, rows)
|
|
131
|
+
existingSelection: getMultiExistingSelection(selectionExists, rows),
|
|
132
132
|
};
|
|
133
133
|
}, [selectModel, selectionExists, rows]);
|
|
134
134
|
var getRowClickHandler = function (index) { return function () {
|
|
@@ -141,50 +141,48 @@ var Grid = function (_a) {
|
|
|
141
141
|
}
|
|
142
142
|
getSelectHandler(index)();
|
|
143
143
|
}; };
|
|
144
|
-
var getAriaSelectedValue = function (
|
|
144
|
+
var getAriaSelectedValue = function (id) {
|
|
145
145
|
if (!selectModel) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
|
-
return String(selectedSet.has(
|
|
148
|
+
return String(selectedSet.has(id));
|
|
149
149
|
};
|
|
150
150
|
var getInputStrSubmitCallback = editModel &&
|
|
151
|
-
(function (
|
|
152
|
-
var
|
|
151
|
+
(function (id) {
|
|
152
|
+
var idSpecificCallback = editModel.getUpdateCallback(id);
|
|
153
153
|
return function (inputStrs) {
|
|
154
|
-
var
|
|
155
|
-
|
|
154
|
+
var rowData = inputStrsToRowData(cols, inputStrs);
|
|
155
|
+
idSpecificCallback(rowData);
|
|
156
156
|
};
|
|
157
157
|
});
|
|
158
158
|
var unwrappedTableModel = useMemo(function () { return unwrapTableStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel); }, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel]);
|
|
159
159
|
var unwrappedAdditionalStyleModel = useMemo(function () {
|
|
160
160
|
return unwrapAdditionalComponentsStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel);
|
|
161
161
|
}, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel]);
|
|
162
|
-
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [
|
|
162
|
+
return (_jsxs("div", { "data-testid": "rbdg-top-level-div", className: classNames(unwrappedAdditionalStyleModel.topLevelDiv), children: [normalizedTableFilterModel && (_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 }))] })), _jsxs("div", { "data-testid": "rbdg-table-and-pagination-div", className: classNames(unwrappedAdditionalStyleModel.tableAndPaginationDiv), children: [_jsxs("table", { className: classNames("table", {
|
|
163
163
|
"table-hover": rowsAreSelectable,
|
|
164
164
|
}, 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) {
|
|
165
|
-
var _b;
|
|
166
165
|
var name = _a.name, label = _a.label, sortable = _a.sortable;
|
|
167
|
-
var colSortModel =
|
|
166
|
+
var colSortModel = sortingEnabled && sortable
|
|
168
167
|
? {
|
|
169
|
-
sortOrder: (
|
|
170
|
-
? sortModel.sortColDef.order
|
|
171
|
-
: null,
|
|
168
|
+
sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === name ? sortColDef.order : null,
|
|
172
169
|
setSortOrder: function (order) {
|
|
173
|
-
|
|
170
|
+
setSortColDef &&
|
|
171
|
+
setSortColDef(order && { name: name, order: order });
|
|
174
172
|
},
|
|
175
173
|
}
|
|
176
174
|
: undefined;
|
|
177
175
|
return (_jsx(ColHeaderCell, { label: label, sortModel: colSortModel, ariaColIndex: index + 1 + (showSelectCol ? 1 : 0), additionalClasses: unwrappedTableModel.theadTh(index) }, name));
|
|
178
176
|
}), 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) {
|
|
179
|
-
return (_jsx(EditableRow, { onClick: getRowClickHandler(row.
|
|
180
|
-
"table-active": selectedSet.has(row.
|
|
181
|
-
}, unwrappedTableModel.tbodyTr(row.
|
|
182
|
-
getInputStrSubmitCallback(row.
|
|
183
|
-
editModel.getDeleteCallback(row.
|
|
184
|
-
return unwrappedTableModel.tbodyTd(row.
|
|
177
|
+
return (_jsx(EditableRow, { onClick: getRowClickHandler(row.id), className: classNames({
|
|
178
|
+
"table-active": selectedSet.has(row.id),
|
|
179
|
+
}, unwrappedTableModel.tbodyTr(row.id, index)), "aria-rowindex": index + 2, dataRowId: row.id, "aria-selected": getAriaSelectedValue(row.id), ariaColIndexOffset: ariaColIndexOffset, cellData: row.contents, updateCallback: getInputStrSubmitCallback &&
|
|
180
|
+
getInputStrSubmitCallback(row.id), deleteCallback: (editModel === null || editModel === void 0 ? void 0 : editModel.getDeleteCallback) &&
|
|
181
|
+
editModel.getDeleteCallback(row.id), dataCellClasses: function (colIndex) {
|
|
182
|
+
return unwrappedTableModel.tbodyTd(row.id, index, colIndex);
|
|
185
183
|
}, dataCellInputClasses: function (colIndex) {
|
|
186
|
-
return unwrappedTableModel.tbodyTdInput(row.
|
|
187
|
-
}, editCellClasses: unwrappedTableModel.editColTd(row.
|
|
188
|
-
}) })] }),
|
|
184
|
+
return unwrappedTableModel.tbodyTdInput(row.id, index, colIndex);
|
|
185
|
+
}, 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));
|
|
186
|
+
}) })] }), normalizedModel && (_jsx(Pagination, { normalizedModel: normalizedModel, prePagingNumRows: sortedRows.length }))] })] }));
|
|
189
187
|
};
|
|
190
188
|
export default Grid;
|
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
See the documentation site at https://react-bootstrap-data-grid.vercel.app/ for instructions on usage.
|
|
4
4
|
|
|
5
|
-
See the source repository at https://github.com/absreim/react-bootstrap-data-grid to view the source code.
|
|
5
|
+
See the source repository at https://github.com/absreim/react-bootstrap-data-grid to view the source code.
|
package/editing/EditableRow.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
+
import { RowId } from "../types";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { CellData } from "./types";
|
|
4
5
|
export type EditableRowProps = Pick<React.ComponentProps<"tr">, "onClick" | "className" | "aria-rowindex" | "aria-selected"> & {
|
|
5
6
|
ariaColIndexOffset: number;
|
|
6
|
-
|
|
7
|
+
dataRowId: RowId;
|
|
7
8
|
children: ReactNode;
|
|
8
9
|
cellData: CellData[];
|
|
9
10
|
updateCallback?: (values: string[]) => void;
|
package/editing/EditableRow.js
CHANGED
|
@@ -29,7 +29,7 @@ var colDataTypeToInputType = function (colDataType) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
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"],
|
|
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
33
|
var trRef = useRef(null);
|
|
34
34
|
var _b = useState(false), isEditing = _b[0], setIsEditing = _b[1];
|
|
35
35
|
var handleSave = function () {
|
|
@@ -59,9 +59,9 @@ var EditableRow = function (_a) {
|
|
|
59
59
|
setIsEditing(false);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
return (_jsxs("tr", { ref: trRef, onClick: onClick, className: className, "aria-rowindex": ariaRowIndex, "aria-selected": ariaSelected, "data-
|
|
62
|
+
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
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(
|
|
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
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 }))] }));
|
|
66
66
|
};
|
|
67
67
|
export default EditableRow;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var inputStrsToRowData = function (cols, inputStrs) {
|
|
2
2
|
var newRow = {};
|
|
3
3
|
inputStrs.forEach(function (value, index) {
|
|
4
4
|
var col = cols[index];
|
|
@@ -15,4 +15,4 @@ var inputStrsToRowDef = function (cols, inputStrs) {
|
|
|
15
15
|
});
|
|
16
16
|
return newRow;
|
|
17
17
|
};
|
|
18
|
-
export default
|
|
18
|
+
export default inputStrsToRowData;
|
package/editing/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColDataType, ColDataTypeStrings,
|
|
1
|
+
import { ColDataType, ColDataTypeStrings, RowData, RowId } from "../types";
|
|
2
2
|
export interface CellData {
|
|
3
3
|
fieldName: string;
|
|
4
4
|
value: ColDataType;
|
|
@@ -7,8 +7,8 @@ export interface CellData {
|
|
|
7
7
|
formattedValue: string;
|
|
8
8
|
label: string;
|
|
9
9
|
}
|
|
10
|
-
export type UpdateCallbackGenerator = (
|
|
10
|
+
export type UpdateCallbackGenerator = (id: RowId) => (rowData: RowData) => void;
|
|
11
11
|
export interface EditModel {
|
|
12
12
|
getUpdateCallback: UpdateCallbackGenerator;
|
|
13
|
-
getDeleteCallback?: (
|
|
13
|
+
getDeleteCallback?: (id: RowId) => () => void;
|
|
14
14
|
}
|
package/filtering/types.d.ts
CHANGED
|
@@ -45,16 +45,22 @@ export interface BetweenDatesFilterState extends AbstractDateFilterState {
|
|
|
45
45
|
}
|
|
46
46
|
export type DateFilterState = StartDateFilterState | EndDateFilterState | BetweenDatesFilterState;
|
|
47
47
|
export type FilterState = StringFilterState | NumberFilterState | DateFilterState;
|
|
48
|
-
export interface
|
|
48
|
+
export interface ControlledFilterModel {
|
|
49
|
+
type?: "controlled";
|
|
49
50
|
tableFilterState: EditableTableFilterState;
|
|
50
51
|
setTableFilterState: (state: EditableTableFilterState) => void;
|
|
51
52
|
filterTableCaption?: string;
|
|
52
53
|
}
|
|
54
|
+
export type UncontrolledFilterModel = Partial<Pick<ControlledFilterModel, "tableFilterState" | "filterTableCaption">> & {
|
|
55
|
+
type: "uncontrolled";
|
|
56
|
+
};
|
|
57
|
+
export type NormalizedTableFilterModel = Pick<ControlledFilterModel, "tableFilterState" | "setTableFilterState">;
|
|
53
58
|
export interface NumberFormFilterState extends AbstractFilterState {
|
|
54
59
|
type: "number";
|
|
55
60
|
scheme: NumberFilterScheme;
|
|
56
61
|
inputValue: string;
|
|
57
62
|
}
|
|
63
|
+
export type FilterModel = ControlledFilterModel | UncontrolledFilterModel;
|
|
58
64
|
export interface DateFormFilterState extends AbstractDateFilterState {
|
|
59
65
|
scheme: DateFilterScheme;
|
|
60
66
|
startDate: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absreim/react-bootstrap-data-grid",
|
|
3
3
|
"description": "Data grid UI component for use with web apps using React and Bootstrap",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Brook Li",
|
|
7
7
|
"homepage": "https://react-bootstrap-data-grid.vercel.app/",
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { JustifyContentSetting
|
|
2
|
+
import { JustifyContentSetting } from "../types";
|
|
3
|
+
import { NormalizedPaginationModel } from "./types";
|
|
3
4
|
export interface PaginationProps {
|
|
4
|
-
|
|
5
|
-
pageSizeOptions: number[];
|
|
6
|
-
pageSizeIndex: number;
|
|
7
|
-
handleSetPageSizeIndex: (index: number) => void;
|
|
8
|
-
handleSetPageNum: (index: number) => void;
|
|
5
|
+
normalizedModel: NormalizedPaginationModel;
|
|
9
6
|
prePagingNumRows: number;
|
|
10
|
-
maxPageButtons: number;
|
|
11
|
-
currentPage: number;
|
|
12
7
|
pageSelectorAriaLabel?: string;
|
|
13
8
|
pageSelectorJustifyContent?: JustifyContentSetting;
|
|
14
9
|
}
|
package/pagination/Pagination.js
CHANGED
|
@@ -2,19 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import PageSizeSelector from "./PageSizeSelector";
|
|
3
3
|
import PageSelector from "./PageSelector";
|
|
4
4
|
var Pagination = function (_a) {
|
|
5
|
-
var
|
|
5
|
+
var normalizedModel = _a.normalizedModel, prePagingNumRows = _a.prePagingNumRows;
|
|
6
|
+
var pageSizeOptions = normalizedModel.pageSizeOptions, pageSizeIndex = normalizedModel.pageSizeIndex, currentPage = normalizedModel.currentPage, setCurrentPage = normalizedModel.setCurrentPage, setPageSizeIndex = normalizedModel.setPageSizeIndex, componentSize = normalizedModel.componentSize, maxPageButtons = normalizedModel.maxPageButtons, pageSelectorAriaLabel = normalizedModel.pageSelectorAriaLabel, pageSelectorJustifyContent = normalizedModel.pageSelectorJustifyContent;
|
|
6
7
|
var numPages = Math.ceil(prePagingNumRows / pageSizeOptions[pageSizeIndex]);
|
|
7
8
|
var pageIndexAwarePageSizeSetter = function (newPageSizeIndex) {
|
|
8
9
|
var newPageSize = pageSizeOptions[newPageSizeIndex];
|
|
9
10
|
var maxPages = Math.ceil(prePagingNumRows / newPageSize);
|
|
10
|
-
|
|
11
|
+
setPageSizeIndex(newPageSizeIndex);
|
|
11
12
|
// The new page size can cause the current page number to be out of bounds.
|
|
12
13
|
// In that case, set the page num to the maximum possible with new page
|
|
13
14
|
// size.
|
|
14
15
|
if (currentPage > maxPages) {
|
|
15
|
-
|
|
16
|
+
setCurrentPage(maxPages);
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
|
-
return (_jsxs("div", { className: "d-flex justify-content-end gap-2", children: [_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }), _jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum:
|
|
19
|
+
return (_jsxs("div", { className: "d-flex justify-content-end gap-2", children: [_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }), _jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum: setCurrentPage, size: componentSize, ariaLabel: pageSelectorAriaLabel, alignment: pageSelectorJustifyContent })] }));
|
|
19
20
|
};
|
|
20
21
|
export default Pagination;
|
package/pagination/types.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { JustifyContentSetting, Size } from "../types";
|
|
2
|
-
export interface
|
|
3
|
-
pageSizeOptions
|
|
4
|
-
|
|
5
|
-
setPageSizeIndex: (pageSizeIndex: number) => void;
|
|
6
|
-
currentPage: number;
|
|
7
|
-
setCurrentPage: (pageNum: number) => void;
|
|
8
|
-
maxPageButtons: number;
|
|
2
|
+
export interface PaginationOptions {
|
|
3
|
+
pageSizeOptions?: number[];
|
|
4
|
+
maxPageButtons?: number;
|
|
9
5
|
componentSize?: Size;
|
|
10
6
|
pageSelectorAriaLabel?: string;
|
|
11
7
|
pageSelectorJustifyContent?: JustifyContentSetting;
|
|
12
8
|
}
|
|
9
|
+
export type ControlledPaginationModel = PaginationOptions & {
|
|
10
|
+
type?: "controlled";
|
|
11
|
+
pageSizeIndex: number;
|
|
12
|
+
setPageSizeIndex: (pageSizeIndex: number) => void;
|
|
13
|
+
currentPage: number;
|
|
14
|
+
setCurrentPage: (pageNum: number) => void;
|
|
15
|
+
};
|
|
16
|
+
export type UncontrolledPaginationModel = PaginationOptions & {
|
|
17
|
+
type: "uncontrolled";
|
|
18
|
+
startingPageSizeIndex?: number;
|
|
19
|
+
startingCurrentPage?: number;
|
|
20
|
+
};
|
|
21
|
+
export type GridPaginationState = ControlledPaginationModel | UncontrolledPaginationModel;
|
|
22
|
+
export type NormalizedPaginationModel = Required<Omit<ControlledPaginationModel, "type" | "pageSelectorAriaLabel" | "pageSelectorJustifyContent">> & Pick<ControlledPaginationModel, "pageSelectorAriaLabel" | "pageSelectorJustifyContent">;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GridPaginationState } from "../pagination/types";
|
|
3
|
-
declare const useCurrentPageRows: (sortedRows:
|
|
1
|
+
import { RowDef } from "../types";
|
|
2
|
+
import { NormalizedPaginationModel, GridPaginationState } from "../pagination/types";
|
|
3
|
+
declare const useCurrentPageRows: (sortedRows: RowDef[], paginationModel: GridPaginationState | undefined) => {
|
|
4
|
+
paginatedRows: RowDef[];
|
|
5
|
+
normalizedModel: NormalizedPaginationModel | null;
|
|
6
|
+
};
|
|
4
7
|
export default useCurrentPageRows;
|
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
var useCurrentPageRows = function (sortedRows,
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
var useCurrentPageRows = function (sortedRows, paginationModel) {
|
|
3
|
+
var componentSize = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.componentSize) || "medium";
|
|
4
|
+
var isControlled = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.type) !== "uncontrolled";
|
|
5
|
+
var _a = useState(isControlled ? 0 : paginationModel.startingPageSizeIndex || 0), internalPageSizeIndex = _a[0], setInternalPageSizeIndex = _a[1];
|
|
6
|
+
var pageSizeIndex = isControlled
|
|
7
|
+
? (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSizeIndex) || 0
|
|
8
|
+
: internalPageSizeIndex;
|
|
9
|
+
var setPageSizeIndex = isControlled
|
|
10
|
+
? paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.setPageSizeIndex
|
|
11
|
+
: setInternalPageSizeIndex;
|
|
12
|
+
var _b = useState(isControlled ? 1 : paginationModel.startingCurrentPage || 1), internalPageNum = _b[0], setInternalPageNum = _b[1];
|
|
13
|
+
var currentPage = isControlled
|
|
14
|
+
? (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.currentPage) || 1
|
|
15
|
+
: internalPageNum;
|
|
16
|
+
var setCurrentPage = isControlled
|
|
17
|
+
? paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.setCurrentPage
|
|
18
|
+
: setInternalPageNum;
|
|
19
|
+
var maxPageButtons = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.maxPageButtons) || 5;
|
|
3
20
|
return useMemo(function () {
|
|
4
|
-
if (
|
|
5
|
-
return sortedRows;
|
|
21
|
+
if (paginationModel === undefined) {
|
|
22
|
+
return { paginatedRows: sortedRows, normalizedModel: null };
|
|
6
23
|
}
|
|
7
|
-
var pageSizeOptions =
|
|
24
|
+
var pageSizeOptions = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSizeOptions) || [10, 25, 100];
|
|
25
|
+
var normalizedModel = {
|
|
26
|
+
pageSizeIndex: pageSizeIndex,
|
|
27
|
+
setPageSizeIndex: setPageSizeIndex,
|
|
28
|
+
currentPage: currentPage,
|
|
29
|
+
setCurrentPage: setCurrentPage,
|
|
30
|
+
pageSizeOptions: pageSizeOptions,
|
|
31
|
+
maxPageButtons: maxPageButtons,
|
|
32
|
+
componentSize: componentSize,
|
|
33
|
+
pageSelectorAriaLabel: paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSelectorAriaLabel,
|
|
34
|
+
pageSelectorJustifyContent: paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSelectorJustifyContent,
|
|
35
|
+
};
|
|
8
36
|
var pageSize = pageSizeOptions[pageSizeIndex];
|
|
9
37
|
var lowerIndex = pageSize * (currentPage - 1);
|
|
10
38
|
var upperIndex = lowerIndex + pageSize;
|
|
11
|
-
|
|
12
|
-
|
|
39
|
+
var paginatedRows = sortedRows.slice(lowerIndex, upperIndex);
|
|
40
|
+
return { paginatedRows: paginatedRows, normalizedModel: normalizedModel };
|
|
41
|
+
}, [
|
|
42
|
+
paginationModel,
|
|
43
|
+
pageSizeIndex,
|
|
44
|
+
setPageSizeIndex,
|
|
45
|
+
currentPage,
|
|
46
|
+
setCurrentPage,
|
|
47
|
+
maxPageButtons,
|
|
48
|
+
componentSize,
|
|
49
|
+
sortedRows,
|
|
50
|
+
]);
|
|
13
51
|
};
|
|
14
52
|
export default useCurrentPageRows;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const useDisplayRows: (currentPageRows:
|
|
1
|
+
import { RowDef, FormattedRow, ColDef } from "../types";
|
|
2
|
+
declare const useDisplayRows: (currentPageRows: RowDef[], cols: ColDef[], ariaColIndexOffset: number) => FormattedRow[];
|
|
3
3
|
export default useDisplayRows;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
|
|
2
3
|
var getFormattedValue = function (value, formatter, typeString) {
|
|
3
4
|
if (formatter) {
|
|
4
5
|
return formatter(value);
|
|
5
6
|
}
|
|
6
7
|
if (typeString === "date") {
|
|
7
|
-
return value
|
|
8
|
+
return dateToInputStr(value);
|
|
8
9
|
}
|
|
9
10
|
if (typeString === "datetime") {
|
|
10
|
-
return value
|
|
11
|
+
return dateToDatetimeInputStr(value);
|
|
11
12
|
}
|
|
12
13
|
if (typeString === "number") {
|
|
13
|
-
return value.
|
|
14
|
+
return value.toString();
|
|
14
15
|
}
|
|
15
16
|
return value;
|
|
16
17
|
};
|
|
@@ -52,7 +53,7 @@ var useDisplayRows = function (currentPageRows, cols, ariaColIndexOffset) {
|
|
|
52
53
|
label: cols[index].label,
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
|
-
return { contents: displayRow,
|
|
56
|
+
return { contents: displayRow, id: row.id };
|
|
56
57
|
});
|
|
57
58
|
}, [currentPageRows, cols, ariaColIndexOffset]);
|
|
58
59
|
};
|
package/pipeline/useFilter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RowDef } from "../types";
|
|
2
2
|
import { EditableTableFilterState } from "../filtering/types";
|
|
3
|
-
declare const useFilter: (rows:
|
|
3
|
+
declare const useFilter: (rows: RowDef[], filterState: EditableTableFilterState | null) => RowDef[];
|
|
4
4
|
export default useFilter;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FilterModel, NormalizedTableFilterModel } from "../filtering/types";
|
|
2
|
+
import { ColDef } from "../types";
|
|
3
|
+
declare const useFilterStateStore: (filterModel: FilterModel | undefined, cols: ColDef[]) => NormalizedTableFilterModel | null;
|
|
4
|
+
export default useFilterStateStore;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
var generateEmptyFilterState = function (cols) {
|
|
3
|
+
var filterState = {};
|
|
4
|
+
cols.forEach(function (_a) {
|
|
5
|
+
var type = _a.type, name = _a.name;
|
|
6
|
+
switch (type) {
|
|
7
|
+
case "string": {
|
|
8
|
+
filterState[name] = {
|
|
9
|
+
type: "string",
|
|
10
|
+
enabled: false,
|
|
11
|
+
scheme: "contains",
|
|
12
|
+
searchString: "",
|
|
13
|
+
};
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
case "number": {
|
|
17
|
+
filterState[name] = {
|
|
18
|
+
type: "number",
|
|
19
|
+
enabled: false,
|
|
20
|
+
scheme: "greaterOrEqual",
|
|
21
|
+
numValue: null,
|
|
22
|
+
};
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
default: {
|
|
26
|
+
filterState[name] = {
|
|
27
|
+
type: type,
|
|
28
|
+
enabled: false,
|
|
29
|
+
scheme: "startFrom",
|
|
30
|
+
startDate: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return filterState;
|
|
36
|
+
};
|
|
37
|
+
var useFilterStateStore = function (filterModel, cols) {
|
|
38
|
+
// Initial states being from prop values means that should uncontrolled
|
|
39
|
+
// FilterModel starting values change, the changes will not take effect
|
|
40
|
+
// unless the Grid is remounted. The documentation for this and other
|
|
41
|
+
// uncontrolled features should indicate this fact and recommend using
|
|
42
|
+
// controlled modes if this behavior is unacceptable.
|
|
43
|
+
var _a = useState((filterModel === null || filterModel === void 0 ? void 0 : filterModel.tableFilterState) || generateEmptyFilterState(cols)), internalFilterState = _a[0], setInternalFilterState = _a[1];
|
|
44
|
+
if (!filterModel) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return filterModel.type === "uncontrolled"
|
|
48
|
+
? {
|
|
49
|
+
tableFilterState: internalFilterState,
|
|
50
|
+
setTableFilterState: setInternalFilterState,
|
|
51
|
+
}
|
|
52
|
+
: {
|
|
53
|
+
tableFilterState: filterModel.tableFilterState,
|
|
54
|
+
setTableFilterState: filterModel.setTableFilterState,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export default useFilterStateStore;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TableSortModel } from "../sorting/types";
|
|
3
|
-
declare const useSortedRows: (rows:
|
|
1
|
+
import { ColDef, RowDef } from "../types";
|
|
2
|
+
import { SortColDef, TableSortModel } from "../sorting/types";
|
|
3
|
+
declare const useSortedRows: (rows: RowDef[], cols: ColDef[], sortModel: TableSortModel | undefined) => {
|
|
4
|
+
sortedRows: RowDef[];
|
|
5
|
+
sortingEnabled: boolean;
|
|
6
|
+
sortColDef: SortColDef | null | undefined;
|
|
7
|
+
setSortColDef: ((sortColDef: SortColDef | null) => void) | undefined;
|
|
8
|
+
};
|
|
4
9
|
export default useSortedRows;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
2
|
var getTypeComparator = function (typeStr) {
|
|
3
3
|
if (typeStr === "date" || typeStr === "datetime") {
|
|
4
4
|
return function (a, b) { return a.valueOf() - b.valueOf(); };
|
|
@@ -20,12 +20,21 @@ var getRowComparator = function (comparator, fieldName) {
|
|
|
20
20
|
return function (rowA, rowB) { return comparator(rowA.data[fieldName], rowB.data[fieldName]); };
|
|
21
21
|
};
|
|
22
22
|
var useSortedRows = function (rows, cols, sortModel) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var _a = useState(((sortModel === null || sortModel === void 0 ? void 0 : sortModel.type) === "uncontrolled" && sortModel.initialSortColDef) ||
|
|
24
|
+
null), internalSortColDef = _a[0], setInternalSortColDef = _a[1];
|
|
25
|
+
var sortColDef = (sortModel === null || sortModel === void 0 ? void 0 : sortModel.type) === "uncontrolled"
|
|
26
|
+
? internalSortColDef
|
|
27
|
+
: (sortModel === null || sortModel === void 0 ? void 0 : sortModel.sortColDef) || undefined;
|
|
28
|
+
var setSortColDef = (sortModel === null || sortModel === void 0 ? void 0 : sortModel.type) === "uncontrolled"
|
|
29
|
+
? setInternalSortColDef
|
|
30
|
+
: (sortModel === null || sortModel === void 0 ? void 0 : sortModel.setSortColDef) || undefined;
|
|
31
|
+
var sortingEnabled = !!sortModel;
|
|
32
|
+
var sortedRows = useMemo(function () {
|
|
33
|
+
if (!sortColDef) {
|
|
25
34
|
return rows;
|
|
26
35
|
}
|
|
27
|
-
var sortFieldName =
|
|
28
|
-
var sortOrder =
|
|
36
|
+
var sortFieldName = sortColDef.name;
|
|
37
|
+
var sortOrder = sortColDef.order;
|
|
29
38
|
var sortColIndex = cols.findIndex(function (_a) {
|
|
30
39
|
var name = _a.name;
|
|
31
40
|
return name === sortFieldName;
|
|
@@ -43,6 +52,7 @@ var useSortedRows = function (rows, cols, sortModel) {
|
|
|
43
52
|
rowComparator = getRowComparator(descComparator, sortFieldName);
|
|
44
53
|
}
|
|
45
54
|
return rows.slice().sort(rowComparator);
|
|
46
|
-
}, [
|
|
55
|
+
}, [sortColDef, cols, rows]);
|
|
56
|
+
return { sortedRows: sortedRows, sortingEnabled: sortingEnabled, sortColDef: sortColDef, setSortColDef: setSortColDef };
|
|
47
57
|
};
|
|
48
58
|
export default useSortedRows;
|
package/selection/types.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { RowId } from "../types";
|
|
1
2
|
export type SelectMode = "column" | "row" | "both";
|
|
2
3
|
export type SelectType = "single" | "multi";
|
|
3
4
|
export interface MultiSelectModel {
|
|
4
5
|
mode: SelectMode;
|
|
5
6
|
type: "multi";
|
|
6
|
-
selected:
|
|
7
|
-
setSelected: (selected:
|
|
7
|
+
selected: RowId[];
|
|
8
|
+
setSelected: (selected: RowId[]) => void;
|
|
8
9
|
}
|
|
9
10
|
export interface SingleSelectModel {
|
|
10
11
|
mode: SelectMode;
|
|
11
12
|
type: "single";
|
|
12
|
-
selected:
|
|
13
|
-
setSelected: (selected:
|
|
13
|
+
selected: RowId | null;
|
|
14
|
+
setSelected: (selected: RowId | null) => void;
|
|
14
15
|
groupName: string;
|
|
15
16
|
}
|
|
16
17
|
export type SelectModel = SingleSelectModel | MultiSelectModel;
|
|
@@ -21,6 +22,6 @@ export interface SingleSelectionInfo {
|
|
|
21
22
|
}
|
|
22
23
|
export interface MultiSelectionInfo {
|
|
23
24
|
selectType: "multi";
|
|
24
|
-
existingSelection:
|
|
25
|
+
existingSelection: "full" | "partial" | "none";
|
|
25
26
|
}
|
|
26
27
|
export type SelectionInfo = SingleSelectionInfo | MultiSelectionInfo;
|
package/selection/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Selected indices are based on the
|
|
1
|
+
// Selected indices are based on the id of the input rows. If
|
|
2
2
|
// filtered-out items are included in the 'selected' property, there will be a
|
|
3
3
|
// visual indication to the user of that fact.
|
|
4
4
|
export {};
|
package/sorting/types.d.ts
CHANGED
|
@@ -7,7 +7,13 @@ export interface ColSortModel {
|
|
|
7
7
|
sortOrder: SortOrder | null;
|
|
8
8
|
setSortOrder: (order: SortOrder | null) => void;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface ControlledTableSortModel {
|
|
11
|
+
type?: "controlled";
|
|
11
12
|
sortColDef: SortColDef | null;
|
|
12
13
|
setSortColDef: (sortColDef: SortColDef | null) => void;
|
|
13
14
|
}
|
|
15
|
+
export interface UncontrolledTableSortModel {
|
|
16
|
+
type: "uncontrolled";
|
|
17
|
+
initialSortColDef: SortColDef | null;
|
|
18
|
+
}
|
|
19
|
+
export type TableSortModel = ControlledTableSortModel | UncontrolledTableSortModel;
|
package/style.scss
CHANGED
package/styling/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RowId } from "../types";
|
|
1
2
|
export interface SharedTableStyleModel {
|
|
2
3
|
table?: string[];
|
|
3
4
|
tbody?: string[];
|
|
@@ -7,18 +8,18 @@ export interface SharedTableStyleModel {
|
|
|
7
8
|
caption?: string[];
|
|
8
9
|
}
|
|
9
10
|
export type TableStyleModel = SharedTableStyleModel & {
|
|
10
|
-
tbodyTr?: (
|
|
11
|
-
tbodyTd?: (
|
|
12
|
-
tbodyTdInput?: (
|
|
11
|
+
tbodyTr?: (rowId: RowId, displayIndex: number) => string[];
|
|
12
|
+
tbodyTd?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[];
|
|
13
|
+
tbodyTdInput?: (rowId: RowId, displayRowIndex: number, colIndex: number) => string[];
|
|
13
14
|
editColTh?: string[];
|
|
14
|
-
editColTd?: (
|
|
15
|
-
editStartButton?: (
|
|
16
|
-
editDeleteButton?: (
|
|
17
|
-
editSaveButton?: (
|
|
18
|
-
editCancelButton?: (
|
|
15
|
+
editColTd?: (rowId: RowId, displayIndex: number) => string[];
|
|
16
|
+
editStartButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
17
|
+
editDeleteButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
18
|
+
editSaveButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
19
|
+
editCancelButton?: (rowId: RowId, displayIndex: number) => string[];
|
|
19
20
|
rowSelectColTh?: string[];
|
|
20
|
-
rowSelectColTd?: (
|
|
21
|
-
rowSelectInput?: (
|
|
21
|
+
rowSelectColTd?: (rowId: RowId, displayIndex: number) => string[];
|
|
22
|
+
rowSelectInput?: (rowId: RowId, displayIndex: number) => string[];
|
|
22
23
|
};
|
|
23
24
|
export type FilterInputTableStyleModel = SharedTableStyleModel & {
|
|
24
25
|
tbodyTr?: (rowIndex: number) => string[];
|
package/types.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { CellData } from "./editing/types";
|
|
2
2
|
export type ColDataType = string | number | Date;
|
|
3
3
|
export type ColDataTypeStrings = "string" | "number" | "date" | "datetime";
|
|
4
|
-
export interface ColDef {
|
|
4
|
+
export interface ColDef<ValueType = any> {
|
|
5
5
|
type: ColDataTypeStrings;
|
|
6
6
|
name: string;
|
|
7
7
|
label: string;
|
|
8
|
-
formatter?: (value:
|
|
8
|
+
formatter?: (value: ValueType) => string;
|
|
9
9
|
sortable?: boolean;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
data:
|
|
17
|
-
meta: RowMetadata;
|
|
11
|
+
type ValidRowData = Record<string, any>;
|
|
12
|
+
export type RowData<Data extends ValidRowData = ValidRowData> = Data;
|
|
13
|
+
export type RowId = string | number;
|
|
14
|
+
export interface RowDef<Data extends ValidRowData = ValidRowData> {
|
|
15
|
+
id: RowId;
|
|
16
|
+
data: RowData<Data>;
|
|
18
17
|
}
|
|
19
18
|
export interface FormattedRow {
|
|
20
19
|
contents: CellData[];
|
|
21
|
-
|
|
20
|
+
id: RowId;
|
|
22
21
|
}
|
|
23
22
|
export type JustifyContentSetting = "start" | "end" | "center" | "between" | "around" | "evenly";
|
|
24
23
|
export type Size = "small" | "medium" | "large";
|
|
24
|
+
export {};
|
package/util/isSubset.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const isSubset: (subset:
|
|
1
|
+
declare const isSubset: <T>(subset: T[], superSet: T[]) => boolean;
|
|
2
2
|
export default isSubset;
|
package/util/isSubset.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var isSubset = function (subset, superSet) {
|
|
2
2
|
var supersetSet = new Set(superSet);
|
|
3
3
|
for (var _i = 0, subset_1 = subset; _i < subset_1.length; _i++) {
|
|
4
|
-
var
|
|
5
|
-
if (!supersetSet.has(
|
|
4
|
+
var member = subset_1[_i];
|
|
5
|
+
if (!supersetSet.has(member)) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
var useAugmentedRows = function (rows) {
|
|
3
|
-
return useMemo(function () {
|
|
4
|
-
return rows.map(function (row, index) { return ({
|
|
5
|
-
data: row,
|
|
6
|
-
meta: {
|
|
7
|
-
origIndex: index,
|
|
8
|
-
},
|
|
9
|
-
}); });
|
|
10
|
-
}, [rows]);
|
|
11
|
-
};
|
|
12
|
-
export default useAugmentedRows;
|