@absreim/react-bootstrap-data-grid-pro 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/LICENSE +16 -0
- package/README.md +6 -0
- package/grid/Grid.d.ts +5 -0
- package/grid/Grid.js +56 -0
- package/grid/InternalGrid.d.ts +19 -0
- package/grid/InternalGrid.js +57 -0
- package/grid/editing/EditControlsCell.d.ts +17 -0
- package/grid/editing/EditControlsCell.js +19 -0
- package/grid/editing/EditableRow.d.ts +22 -0
- package/grid/editing/EditableRow.js +68 -0
- package/grid/editing/inputStrsToRowData.d.ts +3 -0
- package/grid/editing/inputStrsToRowData.js +18 -0
- package/grid/editing/types.d.ts +16 -0
- package/grid/editing/types.js +1 -0
- package/grid/export/ExportForm.d.ts +9 -0
- package/grid/export/ExportForm.js +97 -0
- package/grid/export/types.d.ts +5 -0
- package/grid/export/types.js +1 -0
- package/grid/export/useExportFn.d.ts +23 -0
- package/grid/export/useExportFn.js +115 -0
- package/grid/filtering/DateFilterRow.d.ts +16 -0
- package/grid/filtering/DateFilterRow.js +45 -0
- package/grid/filtering/FilterOptionsTable.d.ts +11 -0
- package/grid/filtering/FilterOptionsTable.js +117 -0
- package/grid/filtering/FilterRow.d.ts +19 -0
- package/grid/filtering/FilterRow.js +18 -0
- package/grid/filtering/NumberFilterRow.d.ts +14 -0
- package/grid/filtering/NumberFilterRow.js +35 -0
- package/grid/filtering/StringFilterRow.d.ts +14 -0
- package/grid/filtering/StringFilterRow.js +35 -0
- package/grid/filtering/types.d.ts +70 -0
- package/grid/filtering/types.js +30 -0
- package/grid/filtering/useFilterFormState.d.ts +3 -0
- package/grid/filtering/useFilterFormState.js +72 -0
- package/grid/index.d.ts +10 -0
- package/grid/index.js +10 -0
- package/grid/main/BodyRows.d.ts +19 -0
- package/grid/main/BodyRows.js +18 -0
- package/grid/main/ColHeaderCell/index.d.ts +4 -0
- package/grid/main/ColHeaderCell/index.js +16 -0
- package/grid/main/ColHeaderCell/useSortHeaderStates.d.ts +9 -0
- package/grid/main/ColHeaderCell/useSortHeaderStates.js +54 -0
- package/grid/main/ToggleButton.d.ts +9 -0
- package/grid/main/ToggleButton.js +14 -0
- package/grid/pagination/PageSelector.d.ts +24 -0
- package/grid/pagination/PageSelector.js +92 -0
- package/grid/pagination/PageSizeSelector.d.ts +10 -0
- package/grid/pagination/PageSizeSelector.js +15 -0
- package/grid/pagination/Pagination.d.ts +9 -0
- package/grid/pagination/Pagination.js +24 -0
- package/grid/pagination/types.d.ts +22 -0
- package/grid/pagination/types.js +1 -0
- package/grid/pipeline/types.d.ts +1 -0
- package/grid/pipeline/types.js +1 -0
- package/grid/pipeline/useAugFormattedRows.d.ts +4 -0
- package/grid/pipeline/useAugFormattedRows.js +22 -0
- package/grid/pipeline/useCombinedPipeline/index.d.ts +19 -0
- package/grid/pipeline/useCombinedPipeline/index.js +31 -0
- package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.d.ts +8 -0
- package/grid/pipeline/useCombinedPipeline/useCurrentPageRows.js +52 -0
- package/grid/pipeline/useCombinedPipeline/useDisplayRows.d.ts +3 -0
- package/grid/pipeline/useCombinedPipeline/useDisplayRows.js +60 -0
- package/grid/pipeline/useCombinedPipeline/useFilter.d.ts +4 -0
- package/grid/pipeline/useCombinedPipeline/useFilter.js +84 -0
- package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.d.ts +4 -0
- package/grid/pipeline/useCombinedPipeline/useFilterStateFromEditable.js +18 -0
- package/grid/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +4 -0
- package/grid/pipeline/useCombinedPipeline/useFilterStateStore.js +57 -0
- package/grid/pipeline/useCombinedPipeline/useSortedRows.d.ts +10 -0
- package/grid/pipeline/useCombinedPipeline/useSortedRows.js +58 -0
- package/grid/pipeline/useGetInputStrSubmitCallback.d.ts +5 -0
- package/grid/pipeline/useGetInputStrSubmitCallback.js +13 -0
- package/grid/pipeline/useGridSelectionFns.d.ts +16 -0
- package/grid/pipeline/useGridSelectionFns.js +131 -0
- package/grid/pipeline/useUnwrappedGridStyles.d.ts +7 -0
- package/grid/pipeline/useUnwrappedGridStyles.js +17 -0
- package/grid/selection/SelectAllHeaderCell.d.ts +11 -0
- package/grid/selection/SelectAllHeaderCell.js +55 -0
- package/grid/selection/SelectionInput.d.ts +19 -0
- package/grid/selection/SelectionInput.js +23 -0
- package/grid/selection/types.d.ts +30 -0
- package/grid/selection/types.js +4 -0
- package/grid/sorting/arrowPlaceholder.d.ts +2 -0
- package/grid/sorting/arrowPlaceholder.js +7 -0
- package/grid/sorting/downArrow.d.ts +2 -0
- package/grid/sorting/downArrow.js +3 -0
- package/grid/sorting/types.d.ts +19 -0
- package/grid/sorting/types.js +1 -0
- package/grid/sorting/upArrow.d.ts +2 -0
- package/grid/sorting/upArrow.js +13 -0
- package/grid/styling/styleModelUnwrappers.d.ts +4 -0
- package/grid/styling/styleModelUnwrappers.js +58 -0
- package/grid/styling/types.d.ts +62 -0
- package/grid/styling/types.js +1 -0
- package/grid/toolbar/Toolbar.d.ts +12 -0
- package/grid/toolbar/Toolbar.js +26 -0
- package/grid/toolbar/ToolbarContainer.d.ts +9 -0
- package/grid/toolbar/ToolbarContainer.js +24 -0
- package/grid/toolbar/types.d.ts +3 -0
- package/grid/toolbar/types.js +1 -0
- package/grid/toolbar/useInterfaces.d.ts +9 -0
- package/grid/toolbar/useInterfaces.js +23 -0
- package/grid/types.d.ts +63 -0
- package/grid/types.js +1 -0
- package/grid/util/datetime.d.ts +2 -0
- package/grid/util/datetime.js +5 -0
- package/grid/util/getWidthStyle.d.ts +3 -0
- package/grid/util/getWidthStyle.js +9 -0
- package/grid/util/isSubset.d.ts +2 -0
- package/grid/util/isSubset.js +11 -0
- package/grid/util/useControlledHover.d.ts +9 -0
- package/grid/util/useControlledHover.js +13 -0
- package/grid-pro/ColHeaderCellPro.d.ts +4 -0
- package/grid-pro/ColHeaderCellPro.js +140 -0
- package/grid-pro/GridPro.d.ts +4 -0
- package/grid-pro/GridPro.js +56 -0
- package/grid-pro/index.d.ts +3 -0
- package/grid-pro/index.js +3 -0
- package/grid-pro/resize/types.d.ts +5 -0
- package/grid-pro/resize/types.js +1 -0
- package/grid-pro/resize/useResizeModel.d.ts +5 -0
- package/grid-pro/resize/useResizeModel.js +65 -0
- package/grid-pro/types.d.ts +18 -0
- package/grid-pro/types.js +1 -0
- package/package.json +34 -0
- package/style.css +1 -0
|
@@ -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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColDefBase, RowDef } from "../../types";
|
|
2
|
+
import { SortColDef, TableSortModel } from "../../sorting/types";
|
|
3
|
+
export interface SortedRowsOutput {
|
|
4
|
+
sortedRows: RowDef[];
|
|
5
|
+
sortingEnabled: boolean;
|
|
6
|
+
sortColDef: SortColDef | null | undefined;
|
|
7
|
+
setSortColDef: ((sortColDef: SortColDef | null) => void) | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare const useSortedRows: (rows: RowDef[], cols: ColDefBase[], sortModel: TableSortModel | undefined) => SortedRowsOutput;
|
|
10
|
+
export default useSortedRows;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
var getTypeComparator = function (typeStr) {
|
|
3
|
+
if (typeStr === "date" || typeStr === "datetime") {
|
|
4
|
+
return function (a, b) { return a.valueOf() - b.valueOf(); };
|
|
5
|
+
}
|
|
6
|
+
if (typeStr === "number") {
|
|
7
|
+
return function (a, b) { return a - b; };
|
|
8
|
+
}
|
|
9
|
+
return function (a, b) {
|
|
10
|
+
if (a < b) {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
if (a > b) {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
return 0;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
var getRowComparator = function (comparator, fieldName) {
|
|
20
|
+
return function (rowA, rowB) { return comparator(rowA.data[fieldName], rowB.data[fieldName]); };
|
|
21
|
+
};
|
|
22
|
+
var useSortedRows = function (rows, cols, sortModel) {
|
|
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) {
|
|
34
|
+
return rows;
|
|
35
|
+
}
|
|
36
|
+
var sortFieldName = sortColDef.name;
|
|
37
|
+
var sortOrder = sortColDef.order;
|
|
38
|
+
var sortColIndex = cols.findIndex(function (_a) {
|
|
39
|
+
var name = _a.name;
|
|
40
|
+
return name === sortFieldName;
|
|
41
|
+
});
|
|
42
|
+
if (sortColIndex < 0) {
|
|
43
|
+
throw new Error("The sortModel for the grid specifies that the data should be sorted based on a column named ".concat(sortFieldName, ", but it was not found among the column definitions."));
|
|
44
|
+
}
|
|
45
|
+
var typeStr = cols[sortColIndex].type;
|
|
46
|
+
var ascComparator = getTypeComparator(typeStr);
|
|
47
|
+
var rowComparator = getRowComparator(ascComparator, sortFieldName);
|
|
48
|
+
if (sortOrder === "desc") {
|
|
49
|
+
var descComparator = function (a, b) {
|
|
50
|
+
return ascComparator(a, b) * -1;
|
|
51
|
+
};
|
|
52
|
+
rowComparator = getRowComparator(descComparator, sortFieldName);
|
|
53
|
+
}
|
|
54
|
+
return rows.slice().sort(rowComparator);
|
|
55
|
+
}, [sortColDef, cols, rows]);
|
|
56
|
+
return { sortedRows: sortedRows, sortingEnabled: sortingEnabled, sortColDef: sortColDef, setSortColDef: setSortColDef };
|
|
57
|
+
};
|
|
58
|
+
export default useSortedRows;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ColDefBase, RowId } from "../types";
|
|
2
|
+
import { EditModel } from "../editing/types";
|
|
3
|
+
export type UseGetInputStrSubmitCallbackHook = ((id: RowId) => (inputStrs: string[]) => void) | undefined;
|
|
4
|
+
declare const useGetInputStrSubmitCallback: (editModel: EditModel | undefined, cols: ColDefBase[]) => UseGetInputStrSubmitCallbackHook;
|
|
5
|
+
export default useGetInputStrSubmitCallback;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import inputStrsToRowData from "../editing/inputStrsToRowData";
|
|
2
|
+
var useGetInputStrSubmitCallback = function (editModel, cols) {
|
|
3
|
+
var getInputStrSubmitCallback = editModel &&
|
|
4
|
+
(function (id) {
|
|
5
|
+
var idSpecificCallback = editModel.getUpdateCallback(id);
|
|
6
|
+
return function (inputStrs) {
|
|
7
|
+
var rowData = inputStrsToRowData(cols, inputStrs);
|
|
8
|
+
idSpecificCallback(rowData);
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
return getInputStrSubmitCallback;
|
|
12
|
+
};
|
|
13
|
+
export default useGetInputStrSubmitCallback;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RowDef, RowId } from "../types";
|
|
2
|
+
import { MouseEventHandler } from "react";
|
|
3
|
+
import { SelectionInfo, SelectModel } from "../selection/types";
|
|
4
|
+
import { SelectionInputModel } from "../selection/SelectionInput";
|
|
5
|
+
export interface UseGridSelectionFnsHook {
|
|
6
|
+
selectedSet: Set<RowId>;
|
|
7
|
+
rowsAreSelectable: boolean | undefined;
|
|
8
|
+
selectionInfo: SelectionInfo | null;
|
|
9
|
+
selectAllOnClick: () => void;
|
|
10
|
+
getSelectHandler: (index: RowId) => () => void;
|
|
11
|
+
getSelectInputModel: (id: RowId, selectModel: SelectModel) => SelectionInputModel;
|
|
12
|
+
getRowClickHandler: (index: RowId) => MouseEventHandler<HTMLTableRowElement>;
|
|
13
|
+
getAriaSelectedValue: (id: RowId) => "true" | "false" | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare const useGridSelectionFns: (selectModel: SelectModel | undefined, rows: RowDef[]) => UseGridSelectionFnsHook;
|
|
16
|
+
export default useGridSelectionFns;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { useCallback, useId, useMemo } from "react";
|
|
2
|
+
import isSubset from "../util/isSubset";
|
|
3
|
+
var useGridSelectionFns = function (selectModel, rows) {
|
|
4
|
+
var selectionExists = useMemo(function () {
|
|
5
|
+
if (!selectModel) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (selectModel.type === "single") {
|
|
9
|
+
return selectModel.selected !== null;
|
|
10
|
+
}
|
|
11
|
+
return selectModel.selected.length > 0;
|
|
12
|
+
}, [selectModel]);
|
|
13
|
+
var selectAllOnClick = useCallback(function () {
|
|
14
|
+
if (!selectModel) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (selectionExists && selectModel.type === "single") {
|
|
18
|
+
selectModel.setSelected(null);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (selectionExists && selectModel.type === "multi") {
|
|
22
|
+
selectModel.setSelected([]);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!selectionExists && selectModel.type === "multi") {
|
|
26
|
+
var allRowIndices = rows.map(function (_, index) { return index; });
|
|
27
|
+
selectModel.setSelected(allRowIndices);
|
|
28
|
+
}
|
|
29
|
+
// Button should be disabled in the case of selectionExists &&
|
|
30
|
+
// selectModel.type === "single", so function execution should never get
|
|
31
|
+
// to this point.
|
|
32
|
+
}, [rows, selectModel, selectionExists]);
|
|
33
|
+
var getSelectHandler = function (index) { return function () {
|
|
34
|
+
if (!selectModel) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (selectModel.type === "single") {
|
|
38
|
+
selectModel.setSelected(index);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
selectModel.setSelected(selectModel.selected.concat(index));
|
|
42
|
+
}; };
|
|
43
|
+
var getDeselectHandler = function (index) { return function () {
|
|
44
|
+
if (!selectModel || selectModel.type === "single") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
selectModel.setSelected(selectModel.selected.filter(function (num) { return num !== index; }));
|
|
48
|
+
}; };
|
|
49
|
+
// used to group radio buttons for selection
|
|
50
|
+
var gridId = useId();
|
|
51
|
+
var getSelectInputModel = function (id, selectModel) {
|
|
52
|
+
if (selectModel.type === "single") {
|
|
53
|
+
return {
|
|
54
|
+
type: "radio",
|
|
55
|
+
name: selectModel.groupName || gridId,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
type: "checkbox",
|
|
60
|
+
deselectCallback: getDeselectHandler(id),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var selectedSet = useMemo(function () {
|
|
64
|
+
var set = new Set();
|
|
65
|
+
if (selectModel && selectModel.type === "multi") {
|
|
66
|
+
selectModel.selected.forEach(function (value) { return set.add(value); });
|
|
67
|
+
}
|
|
68
|
+
if (selectModel &&
|
|
69
|
+
selectModel.type === "single" &&
|
|
70
|
+
selectModel.selected !== null) {
|
|
71
|
+
set.add(selectModel.selected);
|
|
72
|
+
}
|
|
73
|
+
return set;
|
|
74
|
+
}, [selectModel]);
|
|
75
|
+
var rowsAreSelectable = selectModel && selectModel.mode !== "column";
|
|
76
|
+
var selectionInfo = useMemo(function () {
|
|
77
|
+
if (!selectModel) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (selectModel.type === "single") {
|
|
81
|
+
return {
|
|
82
|
+
selectType: "single",
|
|
83
|
+
existingSelection: selectionExists,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
var getMultiExistingSelection = function (selectionExists, rows) {
|
|
87
|
+
var rowIndices = rows.map(function (_, index) { return index; });
|
|
88
|
+
// Note that isFullSelection is true if there are no rows at all. In that case, the return value of this function
|
|
89
|
+
// should be "none", not "full".
|
|
90
|
+
var isFullSelection = isSubset(rowIndices, selectModel.selected);
|
|
91
|
+
if (!selectionExists) {
|
|
92
|
+
return "none";
|
|
93
|
+
}
|
|
94
|
+
if (isFullSelection) {
|
|
95
|
+
return "full";
|
|
96
|
+
}
|
|
97
|
+
return "partial";
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
selectType: "multi",
|
|
101
|
+
existingSelection: getMultiExistingSelection(selectionExists, rows),
|
|
102
|
+
};
|
|
103
|
+
}, [selectModel, selectionExists, rows]);
|
|
104
|
+
var getRowClickHandler = function (index) { return function () {
|
|
105
|
+
if (!rowsAreSelectable) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (selectedSet.has(index)) {
|
|
109
|
+
getDeselectHandler(index)();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
getSelectHandler(index)();
|
|
113
|
+
}; };
|
|
114
|
+
var getAriaSelectedValue = function (id) {
|
|
115
|
+
if (!selectModel) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
return String(selectedSet.has(id));
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
selectedSet: selectedSet,
|
|
122
|
+
rowsAreSelectable: rowsAreSelectable,
|
|
123
|
+
selectionInfo: selectionInfo,
|
|
124
|
+
selectAllOnClick: selectAllOnClick,
|
|
125
|
+
getSelectHandler: getSelectHandler,
|
|
126
|
+
getSelectInputModel: getSelectInputModel,
|
|
127
|
+
getRowClickHandler: getRowClickHandler,
|
|
128
|
+
getAriaSelectedValue: getAriaSelectedValue,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export default useGridSelectionFns;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AdditionalComponentsStyleModel, StyleModel, TableStyleModel } from "../styling/types";
|
|
2
|
+
export interface UseUnwrappedGridStylesHook {
|
|
3
|
+
unwrappedTableModel: Required<TableStyleModel>;
|
|
4
|
+
unwrappedAdditionalStyleModel: Required<AdditionalComponentsStyleModel>;
|
|
5
|
+
}
|
|
6
|
+
declare const UseUnwrappedGridStyles: (styleModel: StyleModel | undefined) => UseUnwrappedGridStylesHook;
|
|
7
|
+
export default UseUnwrappedGridStyles;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { unwrapAdditionalComponentsStyleModel, unwrapTableStyleModel, } from "../styling/styleModelUnwrappers";
|
|
3
|
+
var UseUnwrappedGridStyles = function (styleModel) {
|
|
4
|
+
// To give the developer the ability to specify between removing existing styles
|
|
5
|
+
// and simply adding additional ones, we should migrate off of this "unwrapped"
|
|
6
|
+
// design over time and instead apply logic based on the original params that
|
|
7
|
+
// can be undefined.
|
|
8
|
+
var unwrappedTableModel = useMemo(function () { return unwrapTableStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel); }, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.mainTableStyleModel]);
|
|
9
|
+
var unwrappedAdditionalStyleModel = useMemo(function () {
|
|
10
|
+
return unwrapAdditionalComponentsStyleModel(styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel);
|
|
11
|
+
}, [styleModel === null || styleModel === void 0 ? void 0 : styleModel.additionalComponentsStyleModel]);
|
|
12
|
+
return {
|
|
13
|
+
unwrappedTableModel: unwrappedTableModel,
|
|
14
|
+
unwrappedAdditionalStyleModel: unwrappedAdditionalStyleModel,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default UseUnwrappedGridStyles;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties, FC } from "react";
|
|
2
|
+
import { SelectionInfo } from "./types";
|
|
3
|
+
interface SelectAllHeaderCellProps {
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
selectionInfo: SelectionInfo;
|
|
6
|
+
totalRows: number;
|
|
7
|
+
additionalClasses?: string[];
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
declare const SelectAllHeaderCell: FC<SelectAllHeaderCellProps>;
|
|
11
|
+
export default SelectAllHeaderCell;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
var getCheckboxState = function (selectionInfo, noRows) {
|
|
6
|
+
var disabledState = {
|
|
7
|
+
indeterminate: false,
|
|
8
|
+
checked: false,
|
|
9
|
+
disabled: true,
|
|
10
|
+
description: "Select all (disabled)",
|
|
11
|
+
};
|
|
12
|
+
if (noRows) {
|
|
13
|
+
return disabledState;
|
|
14
|
+
}
|
|
15
|
+
var existingSelection = selectionInfo.existingSelection;
|
|
16
|
+
if (existingSelection === "full") {
|
|
17
|
+
return {
|
|
18
|
+
indeterminate: false,
|
|
19
|
+
checked: true,
|
|
20
|
+
disabled: false,
|
|
21
|
+
description: "Deselect all rows",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (existingSelection === true || existingSelection === "partial") {
|
|
25
|
+
return {
|
|
26
|
+
indeterminate: true,
|
|
27
|
+
checked: true,
|
|
28
|
+
disabled: false,
|
|
29
|
+
description: "Deselect all rows",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (existingSelection === "none") {
|
|
33
|
+
return {
|
|
34
|
+
indeterminate: false,
|
|
35
|
+
checked: false,
|
|
36
|
+
disabled: false,
|
|
37
|
+
description: "Select all rows",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// single select mode and none selected
|
|
41
|
+
return disabledState;
|
|
42
|
+
};
|
|
43
|
+
var SelectAllHeaderCell = function (_a) {
|
|
44
|
+
var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows, additionalClasses = _a.additionalClasses, style = _a.style;
|
|
45
|
+
var noRows = totalRows === 0;
|
|
46
|
+
var _b = getCheckboxState(selectionInfo, noRows), indeterminate = _b.indeterminate, checked = _b.checked, disabled = _b.disabled, description = _b.description;
|
|
47
|
+
var ref = useRef(null);
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
ref.current.indeterminate = indeterminate;
|
|
50
|
+
}, [indeterminate]);
|
|
51
|
+
return (_jsx("th", { style: style, "aria-colindex": 1, title: description, "aria-description": description, className: classNames({
|
|
52
|
+
"btn-primary": !additionalClasses || additionalClasses.length === 0,
|
|
53
|
+
}, additionalClasses || []), children: _jsx("input", { type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
|
|
54
|
+
};
|
|
55
|
+
export default SelectAllHeaderCell;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export interface RadioSelectionInputModel {
|
|
3
|
+
type: "radio";
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CheckboxSelectionInputModel {
|
|
7
|
+
type: "checkbox";
|
|
8
|
+
deselectCallback: () => void;
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
export type SelectionInputModel = RadioSelectionInputModel | CheckboxSelectionInputModel;
|
|
12
|
+
export interface SelectionInputProps {
|
|
13
|
+
selected: boolean;
|
|
14
|
+
selectionInputModel: SelectionInputModel;
|
|
15
|
+
selectCallback: () => void;
|
|
16
|
+
additionalClasses?: string[];
|
|
17
|
+
}
|
|
18
|
+
declare const SelectionInput: FC<SelectionInputProps>;
|
|
19
|
+
export default SelectionInput;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
var SelectionInput = function (_a) {
|
|
4
|
+
var selectionInputModel = _a.selectionInputModel, selected = _a.selected, selectCallback = _a.selectCallback, additionalClasses = _a.additionalClasses;
|
|
5
|
+
var type = selectionInputModel.type;
|
|
6
|
+
var onChange = function (_a) {
|
|
7
|
+
var checked = _a.target.checked;
|
|
8
|
+
// theoretically, a radio button shouldn't become unchecked so the below
|
|
9
|
+
// check of the "type" variable is not needed except for narrowing the
|
|
10
|
+
// type of the "selectionInputModel"
|
|
11
|
+
if (!checked && type === "checkbox") {
|
|
12
|
+
selectionInputModel.deselectCallback();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (checked) {
|
|
16
|
+
selectCallback();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return (_jsx("input", { className: classNames(additionalClasses || []), "aria-label": "Input to select the current row", onClick: function (event) {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
}, type: type, checked: selected, onChange: onChange, name: selectionInputModel.name }));
|
|
22
|
+
};
|
|
23
|
+
export default SelectionInput;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RowId } from "../types";
|
|
2
|
+
export type SelectMode = "column" | "row" | "both";
|
|
3
|
+
export type SelectType = "single" | "multi";
|
|
4
|
+
interface BaseSelectModel {
|
|
5
|
+
mode: SelectMode;
|
|
6
|
+
selectColWidth?: number;
|
|
7
|
+
}
|
|
8
|
+
export type MultiSelectModel = BaseSelectModel & {
|
|
9
|
+
type: "multi";
|
|
10
|
+
selected: RowId[];
|
|
11
|
+
setSelected: (selected: RowId[]) => void;
|
|
12
|
+
};
|
|
13
|
+
export type SingleSelectModel = BaseSelectModel & {
|
|
14
|
+
type: "single";
|
|
15
|
+
selected: RowId | null;
|
|
16
|
+
setSelected: (selected: RowId | null) => void;
|
|
17
|
+
groupName?: string;
|
|
18
|
+
};
|
|
19
|
+
export type SelectModel = SingleSelectModel | MultiSelectModel;
|
|
20
|
+
export type MultiExistingSelection = "full" | "partial" | "none";
|
|
21
|
+
export interface SingleSelectionInfo {
|
|
22
|
+
selectType: "single";
|
|
23
|
+
existingSelection: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface MultiSelectionInfo {
|
|
26
|
+
selectType: "multi";
|
|
27
|
+
existingSelection: "full" | "partial" | "none";
|
|
28
|
+
}
|
|
29
|
+
export type SelectionInfo = SingleSelectionInfo | MultiSelectionInfo;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Temporary solution to prevent column widths from changing when hovering over
|
|
3
|
+
// columns with a mouse.
|
|
4
|
+
// More ideal permanent solution would be to fix column widths based on preset
|
|
5
|
+
// values.
|
|
6
|
+
var arrowPlaceholder = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("title", { children: "(not being sorted)" }), _jsx("desc", { children: "Empty transparent square for styling purposes" })] }));
|
|
7
|
+
export default arrowPlaceholder;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
var downArrow = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [_jsx("title", { children: "(sorted descending)" }), _jsx("desc", { children: "Down arrow indicating that the column is being sorted in an descending manner" }), _jsx("path", { fillRule: "evenodd", d: "M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1" })] }));
|
|
3
|
+
export default downArrow;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SortOrder = "asc" | "desc";
|
|
2
|
+
export interface SortColDef {
|
|
3
|
+
name: string;
|
|
4
|
+
order: SortOrder;
|
|
5
|
+
}
|
|
6
|
+
export interface ColSortModel {
|
|
7
|
+
sortOrder: SortOrder | null;
|
|
8
|
+
setSortOrder: (order: SortOrder | null) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ControlledTableSortModel {
|
|
11
|
+
type?: "controlled";
|
|
12
|
+
sortColDef: SortColDef | null;
|
|
13
|
+
setSortColDef: (sortColDef: SortColDef | null) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface UncontrolledTableSortModel {
|
|
16
|
+
type: "uncontrolled";
|
|
17
|
+
initialSortColDef: SortColDef | null;
|
|
18
|
+
}
|
|
19
|
+
export type TableSortModel = ControlledTableSortModel | UncontrolledTableSortModel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import classNames from "classnames";
|
|
12
|
+
var upArrow = function (grayed) { return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: classNames(__spreadArray([], (grayed ? ["text-body-secondary"] : []), true)), viewBox: "0 0 16 16", children: [!grayed && (_jsxs(_Fragment, { children: [_jsx("title", { children: "(sorted ascending)" }), _jsx("desc", { children: "Up arrow indicating that the column is being sorted in an ascending manner" })] })), _jsx("path", { fillRule: "evenodd", d: "M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5" })] })); };
|
|
13
|
+
export default upArrow;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AdditionalComponentsStyleModel, FilterInputTableStyleModel, TableStyleModel } from "./types";
|
|
2
|
+
export declare const unwrapTableStyleModel: (tableStyleModel: TableStyleModel | undefined) => Required<TableStyleModel>;
|
|
3
|
+
export declare const unwrapFilterInputTableStyleModel: (filterTableStyleModel: FilterInputTableStyleModel | undefined) => Required<FilterInputTableStyleModel>;
|
|
4
|
+
export declare const unwrapAdditionalComponentsStyleModel: (styleModel: AdditionalComponentsStyleModel | undefined) => Required<AdditionalComponentsStyleModel>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var unwrapSharedStyleModel = function (sharedStyleModel) { return ({
|
|
13
|
+
table: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.table) || [],
|
|
14
|
+
tbody: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.tbody) || [],
|
|
15
|
+
thead: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.thead) || [],
|
|
16
|
+
theadTr: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTr) || [],
|
|
17
|
+
theadTh: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.theadTh) ? sharedStyleModel.theadTh : function () { return []; },
|
|
18
|
+
caption: (sharedStyleModel === null || sharedStyleModel === void 0 ? void 0 : sharedStyleModel.caption) || [],
|
|
19
|
+
}); };
|
|
20
|
+
export var unwrapTableStyleModel = function (tableStyleModel) { return (__assign(__assign({}, unwrapSharedStyleModel(tableStyleModel)), { tbodyTr: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTr) ? tableStyleModel.tbodyTr : function () { return []; }, tbodyTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTd) ? tableStyleModel.tbodyTd : function () { return []; }, tbodyTdInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.tbodyTdInput)
|
|
21
|
+
? tableStyleModel.tbodyTdInput
|
|
22
|
+
: function () { return []; }, editColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTh) || [], editColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editColTd) ? tableStyleModel.editColTd : function () { return []; }, editCancelButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editCancelButton)
|
|
23
|
+
? tableStyleModel.editCancelButton
|
|
24
|
+
: function () { return []; }, editDeleteButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editDeleteButton)
|
|
25
|
+
? tableStyleModel.editDeleteButton
|
|
26
|
+
: function () { return []; }, editSaveButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editSaveButton)
|
|
27
|
+
? tableStyleModel.editSaveButton
|
|
28
|
+
: function () { return []; }, editStartButton: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.editStartButton)
|
|
29
|
+
? tableStyleModel.editStartButton
|
|
30
|
+
: function () { return []; }, rowSelectColTh: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTh) || [], rowSelectColTd: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectColTd)
|
|
31
|
+
? tableStyleModel.rowSelectColTd
|
|
32
|
+
: function () { return []; }, rowSelectInput: (tableStyleModel === null || tableStyleModel === void 0 ? void 0 : tableStyleModel.rowSelectInput)
|
|
33
|
+
? tableStyleModel.rowSelectInput
|
|
34
|
+
: function () { return []; } })); };
|
|
35
|
+
export var unwrapFilterInputTableStyleModel = function (filterTableStyleModel) { return (__assign(__assign({}, unwrapSharedStyleModel(filterTableStyleModel)), { tbodyTr: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTr)
|
|
36
|
+
? filterTableStyleModel.tbodyTr
|
|
37
|
+
: function () { return []; }, tbodyTd: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.tbodyTd)
|
|
38
|
+
? filterTableStyleModel.tbodyTd
|
|
39
|
+
: function () { return []; }, enablementInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.enablementInput)
|
|
40
|
+
? filterTableStyleModel.enablementInput
|
|
41
|
+
: function () { return []; }, schemeSelectionInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.schemeSelectionInput)
|
|
42
|
+
? filterTableStyleModel.schemeSelectionInput
|
|
43
|
+
: function () { return []; }, searchStringInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.searchStringInput)
|
|
44
|
+
? filterTableStyleModel.searchStringInput
|
|
45
|
+
: function () { return []; }, numberInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.numberInput)
|
|
46
|
+
? filterTableStyleModel.numberInput
|
|
47
|
+
: function () { return []; }, startDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.startDateInput)
|
|
48
|
+
? filterTableStyleModel.startDateInput
|
|
49
|
+
: function () { return []; }, endDateInput: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.endDateInput)
|
|
50
|
+
? filterTableStyleModel.endDateInput
|
|
51
|
+
: function () { return []; }, submitButton: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.submitButton) || [], form: (filterTableStyleModel === null || filterTableStyleModel === void 0 ? void 0 : filterTableStyleModel.form) || [] })); };
|
|
52
|
+
export var unwrapAdditionalComponentsStyleModel = function (styleModel) { return ({
|
|
53
|
+
topLevelDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.topLevelDiv) || [],
|
|
54
|
+
filterInputsDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterInputsDiv) || [],
|
|
55
|
+
tableAndPaginationDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.tableAndPaginationDiv) || [],
|
|
56
|
+
filterUiToggleButton: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.filterUiToggleButton) || [],
|
|
57
|
+
paginationUiDiv: (styleModel === null || styleModel === void 0 ? void 0 : styleModel.paginationUiDiv) || [],
|
|
58
|
+
}); };
|