@absreim/react-bootstrap-data-grid 2.3.0 → 2.4.1

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.
Files changed (62) hide show
  1. package/Grid.d.ts +2 -20
  2. package/Grid.js +48 -211
  3. package/InternalGrid.d.ts +19 -0
  4. package/InternalGrid.js +57 -0
  5. package/LICENSE +21 -0
  6. package/editing/EditControlsCell.d.ts +2 -1
  7. package/editing/EditableRow.d.ts +2 -1
  8. package/editing/EditableRow.js +5 -4
  9. package/editing/inputStrsToRowData.d.ts +2 -2
  10. package/editing/types.d.ts +2 -0
  11. package/filtering/FilterOptionsTable.js +2 -2
  12. package/filtering/useFilterFormState.d.ts +3 -0
  13. package/filtering/{useFormStateFromTableFilterState.js → useFilterFormState.js} +2 -2
  14. package/main/BodyRows.d.ts +19 -0
  15. package/main/BodyRows.js +18 -0
  16. package/main/ColHeaderCell/index.d.ts +4 -0
  17. package/main/ColHeaderCell/index.js +16 -0
  18. package/main/ColHeaderCell/useSortHeaderStates.d.ts +9 -0
  19. package/main/ColHeaderCell/useSortHeaderStates.js +54 -0
  20. package/package.json +2 -2
  21. package/pipeline/types.d.ts +1 -0
  22. package/pipeline/types.js +1 -0
  23. package/pipeline/useAugFormattedRows.d.ts +4 -0
  24. package/pipeline/useAugFormattedRows.js +22 -0
  25. package/pipeline/useCombinedPipeline/index.d.ts +19 -0
  26. package/pipeline/useCombinedPipeline/index.js +31 -0
  27. package/pipeline/{useCurrentPageRows.d.ts → useCombinedPipeline/useCurrentPageRows.d.ts} +5 -4
  28. package/pipeline/{useDisplayRows.d.ts → useCombinedPipeline/useDisplayRows.d.ts} +1 -1
  29. package/pipeline/{useDisplayRows.js → useCombinedPipeline/useDisplayRows.js} +1 -1
  30. package/pipeline/{useEditableFromFilterState.d.ts → useCombinedPipeline/useEditableFromFilterState.d.ts} +1 -1
  31. package/pipeline/{useFilter.d.ts → useCombinedPipeline/useFilter.d.ts} +2 -2
  32. package/pipeline/{useFilterStateFromEditable.d.ts → useCombinedPipeline/useFilterStateFromEditable.d.ts} +2 -2
  33. package/pipeline/useCombinedPipeline/useFilterStateStore.d.ts +4 -0
  34. package/pipeline/useCombinedPipeline/useSortedRows.d.ts +10 -0
  35. package/pipeline/useGetInputStrSubmitCallback.d.ts +5 -0
  36. package/pipeline/useGetInputStrSubmitCallback.js +13 -0
  37. package/pipeline/useGridSelectionFns.d.ts +16 -0
  38. package/pipeline/useGridSelectionFns.js +131 -0
  39. package/pipeline/useUnwrappedGridStyles.d.ts +7 -0
  40. package/pipeline/useUnwrappedGridStyles.js +17 -0
  41. package/selection/SelectAllHeaderCell.d.ts +2 -1
  42. package/selection/SelectAllHeaderCell.js +2 -2
  43. package/selection/types.d.ts +8 -5
  44. package/sorting/arrowPlaceholder.js +2 -2
  45. package/style.css +1 -1
  46. package/style.scss +1 -1
  47. package/types.d.ts +41 -2
  48. package/util/getWidthStyle.d.ts +3 -0
  49. package/util/getWidthStyle.js +9 -0
  50. package/ColHeaderCell.d.ts +0 -10
  51. package/ColHeaderCell.js +0 -55
  52. package/filtering/useFormStateFromTableFilterState.d.ts +0 -3
  53. package/pipeline/useFilterStateStore.d.ts +0 -4
  54. package/pipeline/useSortedRows.d.ts +0 -9
  55. /package/{ToggleButton.d.ts → main/ToggleButton.d.ts} +0 -0
  56. /package/{ToggleButton.js → main/ToggleButton.js} +0 -0
  57. /package/pipeline/{useCurrentPageRows.js → useCombinedPipeline/useCurrentPageRows.js} +0 -0
  58. /package/pipeline/{useEditableFromFilterState.js → useCombinedPipeline/useEditableFromFilterState.js} +0 -0
  59. /package/pipeline/{useFilter.js → useCombinedPipeline/useFilter.js} +0 -0
  60. /package/pipeline/{useFilterStateFromEditable.js → useCombinedPipeline/useFilterStateFromEditable.js} +0 -0
  61. /package/pipeline/{useFilterStateStore.js → useCombinedPipeline/useFilterStateStore.js} +0 -0
  62. /package/pipeline/{useSortedRows.js → useCombinedPipeline/useSortedRows.js} +0 -0
@@ -0,0 +1,54 @@
1
+ import useControlledHover from "../../util/useControlledHover";
2
+ import { useMemo } from "react";
3
+ import upArrow from "../../sorting/upArrow";
4
+ import arrowPlaceholder from "../../sorting/arrowPlaceholder";
5
+ import downArrow from "../../sorting/downArrow";
6
+ var useSortHeaderStates = function (sortModel) {
7
+ var _a = useControlledHover(), isHovering = _a.isHovering, setIsHovering = _a.setIsHovering, handleMouseOver = _a.handleMouseOver, handleMouseOut = _a.handleMouseOut;
8
+ var handleClick = function () {
9
+ if (!sortModel) {
10
+ return;
11
+ }
12
+ switch (sortModel.sortOrder) {
13
+ case null: {
14
+ sortModel.setSortOrder("asc");
15
+ return;
16
+ }
17
+ case "asc": {
18
+ sortModel.setSortOrder("desc");
19
+ return;
20
+ }
21
+ case "desc": {
22
+ sortModel.setSortOrder(null);
23
+ }
24
+ }
25
+ };
26
+ var sortSymbol = useMemo(function () {
27
+ if (!sortModel) {
28
+ return null;
29
+ }
30
+ switch (sortModel.sortOrder) {
31
+ case null: {
32
+ if (isHovering) {
33
+ return upArrow(true);
34
+ }
35
+ return arrowPlaceholder;
36
+ }
37
+ case "asc": {
38
+ return upArrow(false);
39
+ }
40
+ case "desc": {
41
+ return downArrow;
42
+ }
43
+ }
44
+ }, [isHovering, sortModel]);
45
+ return {
46
+ isHovering: isHovering,
47
+ setIsHovering: setIsHovering,
48
+ handleMouseOver: handleMouseOver,
49
+ handleMouseOut: handleMouseOut,
50
+ handleClick: handleClick,
51
+ sortSymbol: sortSymbol,
52
+ };
53
+ };
54
+ export default useSortHeaderStates;
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": "2.3.0",
4
+ "version": "2.4.1",
5
5
  "license": "MIT",
6
6
  "author": "Brook Li",
7
7
  "homepage": "https://react-bootstrap-data-grid.vercel.app/",
@@ -29,6 +29,6 @@
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "git+https://github.com/absreim/react-bootstrap-data-grid.git",
32
- "directory": "grid"
32
+ "directory": "src/grid"
33
33
  }
34
34
  }
@@ -0,0 +1 @@
1
+ export type ColNameToWidth<ColName extends string = string> = Record<ColName, number | undefined>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AugFormattedRow, FormattedRow } from "../types";
2
+ import { ColNameToWidth } from "./types";
3
+ declare const useAugFormattedRows: (colNameToWidth: ColNameToWidth, rows: FormattedRow[]) => AugFormattedRow[];
4
+ export default useAugFormattedRows;
@@ -0,0 +1,22 @@
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
+ import { useMemo } from "react";
13
+ var useAugFormattedRows = function (colNameToWidth, rows) {
14
+ return useMemo(function () {
15
+ return rows.map(function (row) {
16
+ return __assign(__assign({}, row), { contents: row.contents.map(function (cell) {
17
+ return __assign(__assign({}, cell), { width: colNameToWidth[cell.fieldName] });
18
+ }) });
19
+ });
20
+ }, [colNameToWidth, rows]);
21
+ };
22
+ export default useAugFormattedRows;
@@ -0,0 +1,19 @@
1
+ import { SortedRowsOutput } from "./useSortedRows";
2
+ import { CurrentPageRowsOutput } from "./useCurrentPageRows";
3
+ import { ColDefBase, FormattedRow, GridProps, RowDef } from "../../types";
4
+ import { NormalizedTableFilterModel, TableFilterState } from "../../filtering/types";
5
+ export type CombinedPipelineParams = Pick<GridProps, "rows" | "filterModel" | "sortModel" | "pagination" | "selectModel"> & {
6
+ cols: ColDefBase[];
7
+ };
8
+ export interface UseCombinedPipelineHook {
9
+ normalizedTableFilterModel: NormalizedTableFilterModel | null;
10
+ filteredRows: RowDef[];
11
+ filterState: TableFilterState | null;
12
+ sortedRowsOutput: SortedRowsOutput;
13
+ currentPageRowsOutput: CurrentPageRowsOutput;
14
+ showSelectCol: boolean;
15
+ ariaColIndexOffset: number;
16
+ displayRows: FormattedRow[];
17
+ }
18
+ declare const UseCombinedPipeline: (params: CombinedPipelineParams) => UseCombinedPipelineHook;
19
+ export default UseCombinedPipeline;
@@ -0,0 +1,31 @@
1
+ import useFilterStateStore from "./useFilterStateStore";
2
+ import useFilter from "./useFilter";
3
+ import useFilterStateFromEditable from "./useFilterStateFromEditable";
4
+ import useSortedRows from "./useSortedRows";
5
+ import useCurrentPageRows from "./useCurrentPageRows";
6
+ import useDisplayRows from "./useDisplayRows";
7
+ var UseCombinedPipeline = function (_a) {
8
+ var filterModel = _a.filterModel, cols = _a.cols, rows = _a.rows, sortModel = _a.sortModel, pagination = _a.pagination, selectModel = _a.selectModel;
9
+ var normalizedTableFilterModel = useFilterStateStore(filterModel, cols);
10
+ var editableFilterState = (normalizedTableFilterModel === null || normalizedTableFilterModel === void 0 ? void 0 : normalizedTableFilterModel.tableFilterState) || null;
11
+ var filteredRows = useFilter(rows, editableFilterState);
12
+ var filterState = useFilterStateFromEditable(cols, editableFilterState);
13
+ var sortedRowsOutput = useSortedRows(filteredRows, cols, sortModel);
14
+ var sortedRows = sortedRowsOutput.sortedRows;
15
+ var currentPageRowsOutput = useCurrentPageRows(sortedRows, pagination);
16
+ var showSelectCol = !!(selectModel && selectModel.mode !== "row");
17
+ var ariaColIndexOffset = showSelectCol ? 1 : 0;
18
+ var paginatedRows = currentPageRowsOutput.paginatedRows;
19
+ var displayRows = useDisplayRows(paginatedRows, cols, ariaColIndexOffset);
20
+ return {
21
+ normalizedTableFilterModel: normalizedTableFilterModel,
22
+ filteredRows: filteredRows,
23
+ filterState: filterState,
24
+ sortedRowsOutput: sortedRowsOutput,
25
+ currentPageRowsOutput: currentPageRowsOutput,
26
+ showSelectCol: showSelectCol,
27
+ ariaColIndexOffset: ariaColIndexOffset,
28
+ displayRows: displayRows,
29
+ };
30
+ };
31
+ export default UseCombinedPipeline;
@@ -1,7 +1,8 @@
1
- import { RowDef } from "../types";
2
- import { NormalizedPaginationModel, GridPaginationState } from "../pagination/types";
3
- declare const useCurrentPageRows: (sortedRows: RowDef[], paginationModel: GridPaginationState | undefined) => {
1
+ import { RowDef } from "../../types";
2
+ import { NormalizedPaginationModel, GridPaginationState } from "../../pagination/types";
3
+ export interface CurrentPageRowsOutput {
4
4
  paginatedRows: RowDef[];
5
5
  normalizedModel: NormalizedPaginationModel | null;
6
- };
6
+ }
7
+ declare const useCurrentPageRows: (sortedRows: RowDef[], paginationModel: GridPaginationState | undefined) => CurrentPageRowsOutput;
7
8
  export default useCurrentPageRows;
@@ -1,3 +1,3 @@
1
- import { RowDef, FormattedRow, ColDef } from "../types";
1
+ import { RowDef, FormattedRow, ColDef } from "../../types";
2
2
  declare const useDisplayRows: (currentPageRows: RowDef[], cols: ColDef[], ariaColIndexOffset: number) => FormattedRow[];
3
3
  export default useDisplayRows;
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from "react";
2
- import { dateToDatetimeInputStr, dateToInputStr } from "../util/datetime";
2
+ import { dateToDatetimeInputStr, dateToInputStr } from "../../util/datetime";
3
3
  var getFormattedValue = function (value, formatter, typeString) {
4
4
  if (formatter) {
5
5
  return formatter(value);
@@ -1,3 +1,3 @@
1
- import { EditableTableFilterState, TableFilterState } from "../filtering/types";
1
+ import { EditableTableFilterState, TableFilterState } from "../../filtering/types";
2
2
  declare const useEditableFromFilterState: (filterState: TableFilterState | null) => EditableTableFilterState | null;
3
3
  export default useEditableFromFilterState;
@@ -1,4 +1,4 @@
1
- import { RowDef } from "../types";
2
- import { EditableTableFilterState } from "../filtering/types";
1
+ import { RowDef } from "../../types";
2
+ import { EditableTableFilterState } from "../../filtering/types";
3
3
  declare const useFilter: (rows: RowDef[], filterState: EditableTableFilterState | null) => RowDef[];
4
4
  export default useFilter;
@@ -1,4 +1,4 @@
1
- import { ColDef } from "../types";
2
- import { EditableTableFilterState, TableFilterState } from "../filtering/types";
1
+ import { ColDef } from "../../types";
2
+ import { EditableTableFilterState, TableFilterState } from "../../filtering/types";
3
3
  declare const useFilterStateFromEditable: (colDefs: ColDef[], editableFilterState: EditableTableFilterState | null) => TableFilterState | null;
4
4
  export default useFilterStateFromEditable;
@@ -0,0 +1,4 @@
1
+ import { FilterModel, NormalizedTableFilterModel } from "../../filtering/types";
2
+ import { ColDefBase } from "../../types";
3
+ declare const useFilterStateStore: (filterModel: FilterModel | undefined, cols: ColDefBase[]) => NormalizedTableFilterModel | null;
4
+ 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,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;
@@ -1,10 +1,11 @@
1
- import { FC } from "react";
1
+ import { CSSProperties, FC } from "react";
2
2
  import { SelectionInfo } from "./types";
3
3
  interface SelectAllHeaderCellProps {
4
4
  onClick: () => void;
5
5
  selectionInfo: SelectionInfo;
6
6
  totalRows: number;
7
7
  additionalClasses?: string[];
8
+ style?: CSSProperties;
8
9
  }
9
10
  declare const SelectAllHeaderCell: FC<SelectAllHeaderCellProps>;
10
11
  export default SelectAllHeaderCell;
@@ -41,14 +41,14 @@ var getCheckboxState = function (selectionInfo, noRows) {
41
41
  return disabledState;
42
42
  };
43
43
  var SelectAllHeaderCell = function (_a) {
44
- var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows, additionalClasses = _a.additionalClasses;
44
+ var onClick = _a.onClick, selectionInfo = _a.selectionInfo, totalRows = _a.totalRows, additionalClasses = _a.additionalClasses, style = _a.style;
45
45
  var noRows = totalRows === 0;
46
46
  var _b = getCheckboxState(selectionInfo, noRows), indeterminate = _b.indeterminate, checked = _b.checked, disabled = _b.disabled, description = _b.description;
47
47
  var ref = useRef(null);
48
48
  useEffect(function () {
49
49
  ref.current.indeterminate = indeterminate;
50
50
  }, [indeterminate]);
51
- return (_jsx("th", { "aria-colindex": 1, title: description, "aria-description": description, className: classNames({
51
+ return (_jsx("th", { style: style, "aria-colindex": 1, title: description, "aria-description": description, className: classNames({
52
52
  "btn-primary": !additionalClasses || additionalClasses.length === 0,
53
53
  }, additionalClasses || []), children: _jsx("input", { type: "checkbox", checked: checked, ref: ref, disabled: disabled, "aria-label": description, onChange: onClick }) }));
54
54
  };
@@ -1,19 +1,21 @@
1
1
  import { RowId } from "../types";
2
2
  export type SelectMode = "column" | "row" | "both";
3
3
  export type SelectType = "single" | "multi";
4
- export interface MultiSelectModel {
4
+ interface BaseSelectModel {
5
5
  mode: SelectMode;
6
+ selectColWidth?: number;
7
+ }
8
+ export type MultiSelectModel = BaseSelectModel & {
6
9
  type: "multi";
7
10
  selected: RowId[];
8
11
  setSelected: (selected: RowId[]) => void;
9
- }
10
- export interface SingleSelectModel {
11
- mode: SelectMode;
12
+ };
13
+ export type SingleSelectModel = BaseSelectModel & {
12
14
  type: "single";
13
15
  selected: RowId | null;
14
16
  setSelected: (selected: RowId | null) => void;
15
17
  groupName?: string;
16
- }
18
+ };
17
19
  export type SelectModel = SingleSelectModel | MultiSelectModel;
18
20
  export type MultiExistingSelection = "full" | "partial" | "none";
19
21
  export interface SingleSelectionInfo {
@@ -25,3 +27,4 @@ export interface MultiSelectionInfo {
25
27
  existingSelection: "full" | "partial" | "none";
26
28
  }
27
29
  export type SelectionInfo = SingleSelectionInfo | MultiSelectionInfo;
30
+ export {};
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Temporary solution to prevent column widths from changing when hovering over
3
3
  // columns with a mouse.
4
4
  // More ideal permanent solution would be to fix column widths based on preset
5
5
  // values.
6
- var arrowPlaceholder = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: _jsx("desc", { children: "Empty transparent square for styling purposes" }) }));
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
7
  export default arrowPlaceholder;
package/style.css CHANGED
@@ -1 +1 @@
1
- .rbdg-clickable-grid-header-cell{cursor:pointer}
1
+ .rbdg-sort-toggler{cursor:pointer}
package/style.scss CHANGED
@@ -1,3 +1,3 @@
1
- .rbdg-clickable-grid-header-cell {
1
+ .rbdg-sort-toggler {
2
2
  cursor: pointer;
3
3
  }
package/types.d.ts CHANGED
@@ -1,13 +1,21 @@
1
- import { CellData } from "./editing/types";
1
+ import { CellData, EditModel } from "./editing/types";
2
+ import { GridPaginationState } from "./pagination/types";
3
+ import { ColSortModel, TableSortModel } from "./sorting/types";
4
+ import { FilterModel } from "./filtering/types";
5
+ import { SelectModel } from "./selection/types";
6
+ import { StyleModel } from "./styling/types";
2
7
  export type ColDataType = string | number | Date;
3
8
  export type ColDataTypeStrings = "string" | "number" | "date" | "datetime";
4
- export interface ColDef<ValueType = any> {
9
+ export interface ColDefBase<ValueType = any> {
5
10
  type: ColDataTypeStrings;
6
11
  name: string;
7
12
  label: string;
8
13
  formatter?: (value: ValueType) => string;
9
14
  sortable?: boolean;
10
15
  }
16
+ export type ColDef<ValueType = any> = ColDefBase<ValueType> & {
17
+ width?: number;
18
+ };
11
19
  type ValidRowData = Record<string, any>;
12
20
  export type RowData<Data extends ValidRowData = ValidRowData> = Data;
13
21
  export type RowId = string | number;
@@ -19,6 +27,37 @@ export interface FormattedRow {
19
27
  contents: CellData[];
20
28
  id: RowId;
21
29
  }
30
+ export type AugCellData = CellData & {
31
+ width?: number;
32
+ };
33
+ export type AugFormattedRow = Omit<FormattedRow, "contents"> & {
34
+ contents: AugCellData[];
35
+ };
22
36
  export type JustifyContentSetting = "start" | "end" | "center" | "between" | "around" | "evenly";
23
37
  export type Size = "small" | "medium" | "large";
38
+ export type DisplayMode = "table" | "block";
39
+ export interface GridProps {
40
+ rows: RowDef[];
41
+ cols: ColDef[];
42
+ pagination?: GridPaginationState;
43
+ sortModel?: TableSortModel;
44
+ filterModel?: FilterModel;
45
+ selectModel?: SelectModel;
46
+ editModel?: EditModel;
47
+ caption?: string;
48
+ styleModel?: StyleModel;
49
+ useToolbar?: boolean;
50
+ responsive?: boolean;
51
+ displayMode?: DisplayMode;
52
+ }
53
+ export type BaseGridProps = Omit<GridProps, "cols"> & {
54
+ cols: ColDefBase[];
55
+ };
56
+ export interface ColHeaderCellProps {
57
+ label: string;
58
+ sortModel?: ColSortModel;
59
+ ariaColIndex: number;
60
+ additionalClasses?: string[];
61
+ width?: number;
62
+ }
24
63
  export {};
@@ -0,0 +1,3 @@
1
+ import { CSSProperties } from "react";
2
+ declare const getWidthStyle: (width: number | undefined) => CSSProperties | undefined;
3
+ export default getWidthStyle;
@@ -0,0 +1,9 @@
1
+ var getWidthStyle = function (width) {
2
+ return width === undefined
3
+ ? undefined
4
+ : {
5
+ minWidth: width,
6
+ maxWidth: width,
7
+ };
8
+ };
9
+ export default getWidthStyle;
@@ -1,10 +0,0 @@
1
- import { FC } from "react";
2
- import { ColSortModel } from "./sorting/types";
3
- interface ColHeaderCellProps {
4
- label: string;
5
- sortModel?: ColSortModel;
6
- ariaColIndex: number;
7
- additionalClasses?: string[];
8
- }
9
- declare const ColHeaderCell: FC<ColHeaderCellProps>;
10
- export default ColHeaderCell;