@absreim/react-bootstrap-data-grid 4.2.0 → 4.3.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.
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { IconProps } from "./internalTypes";
3
+ declare const CaretUpFill: FC<IconProps>;
4
+ export default CaretUpFill;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ var CaretUpFill = function (_a) {
3
+ var className = _a.className;
4
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: className, viewBox: "0 0 16 16", children: _jsx("path", { d: "M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z" }) }));
5
+ };
6
+ export default CaretUpFill;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { IconProps } from "./internalTypes";
3
+ declare const CaretUp: FC<IconProps>;
4
+ export default CaretUp;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ var CaretUp = function (_a) {
3
+ var className = _a.className;
4
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: className, viewBox: "0 0 16 16", children: _jsx("path", { d: "M3.204 11h9.592L8 5.519zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659" }) }));
5
+ };
6
+ export default CaretUp;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { IconProps } from "./internalTypes";
3
+ declare const CaretUpFill: FC<IconProps>;
4
+ export default CaretUpFill;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ var CaretUpFill = function (_a) {
3
+ var className = _a.className;
4
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: className, viewBox: "0 0 16 16", children: _jsx("path", { d: "m7.247 4.86-4.796 5.481c-.566.647-.106 1.659.753 1.659h9.592a1 1 0 0 0 .753-1.659l-4.796-5.48a1 1 0 0 0-1.506 0z" }) }));
5
+ };
6
+ export default CaretUpFill;
@@ -0,0 +1,3 @@
1
+ export interface IconProps {
2
+ className?: string;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const ArrowPlaceholder: FC;
3
+ export default ArrowPlaceholder;
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ var ArrowPlaceholder = function () { return (_jsxs("svg", { "aria-hidden": "true", 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" })] })); };
3
+ export default ArrowPlaceholder;
@@ -0,0 +1,6 @@
1
+ import { FC } from "react";
2
+ export interface DownArrowProps {
3
+ className?: string;
4
+ }
5
+ declare const DownArrow: FC<DownArrowProps>;
6
+ export default DownArrow;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ var DownArrow = function (_a) {
3
+ var className = _a.className;
4
+ return (_jsxs("svg", { "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", className: className, children: [_jsx("title", { children: "Down arrow" }), _jsx("desc", { children: "Downward-pointing arrow" }), _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" })] }));
5
+ };
6
+ export default DownArrow;
@@ -0,0 +1,6 @@
1
+ import { FC } from "react";
2
+ export interface UpArrowProps {
3
+ className?: string;
4
+ }
5
+ declare const UpArrow: FC<UpArrowProps>;
6
+ export default UpArrow;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ var UpArrow = function (_a) {
3
+ var className = _a.className;
4
+ return (_jsxs("svg", { "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", className: className, viewBox: "0 0 16 16", children: [_jsx("title", { children: "Up arrow" }), _jsx("desc", { children: "Upward-pointing arrow" }), _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" })] }));
5
+ };
6
+ export default UpArrow;
@@ -1,8 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import useControlledHover from "../util/useControlledHover";
2
3
  import { useMemo } from "react";
3
- import upArrow from "./upArrow";
4
- import arrowPlaceholder from "./arrowPlaceholder";
5
- import downArrow from "./downArrow";
4
+ import UpArrow from "./UpArrow";
5
+ import ArrowPlaceholder from "./ArrowPlaceholder";
6
+ import DownArrow from "./DownArrow";
6
7
  var useSortHeaderStates = function (sortModel) {
7
8
  var _a = useControlledHover(), isHovering = _a.isHovering, setIsHovering = _a.setIsHovering, handleMouseOver = _a.handleMouseOver, handleMouseOut = _a.handleMouseOut;
8
9
  var handleClick = function () {
@@ -30,15 +31,15 @@ var useSortHeaderStates = function (sortModel) {
30
31
  switch (sortModel.sortOrder) {
31
32
  case null: {
32
33
  if (isHovering) {
33
- return upArrow(true);
34
+ return _jsx(UpArrow, { className: "text-body-secondary" });
34
35
  }
35
- return arrowPlaceholder;
36
+ return _jsx(ArrowPlaceholder, {});
36
37
  }
37
38
  case "asc": {
38
- return upArrow(false);
39
+ return _jsx(UpArrow, {});
39
40
  }
40
41
  case "desc": {
41
- return downArrow;
42
+ return _jsx(DownArrow, {});
42
43
  }
43
44
  }
44
45
  }, [isHovering, sortModel]);
package/common/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SortModel } from "./sorting/types";
1
2
  /**
2
3
  * Union of all possible column data types.
3
4
  *
@@ -116,26 +117,31 @@ export interface RowDef<Data extends ValidRowData = ValidRowData> {
116
117
  data: RowData<Data>;
117
118
  }
118
119
  /**
119
- * Interface that contains parameters shared between the Table, TablePro, and
120
- * Grid components.
120
+ * Interface that contains parameters shared between the {@link Table},
121
+ * {@link TablePro}, and {@link Grid} components.
121
122
  *
122
123
  * @public
123
124
  */
124
125
  export interface MainComponentSharedProps {
125
126
  /**
126
- * The rows of data to be displayed by the table or grid
127
+ * The rows of data to be displayed by the table or grid.
127
128
  */
128
129
  rows: RowDef[];
129
130
  /**
130
- * The column definitions of the table or grid
131
+ * The column definitions of the table or grid.
131
132
  */
132
133
  cols: ColDef[];
134
+ /**
135
+ * The sort model of the table or grid. Passing a truthy value enables the
136
+ * sorting feature of the component.
137
+ */
138
+ sortModel?: SortModel;
133
139
  }
134
140
  /**
135
141
  * {@link RowDef} object that additionally contains the index of the row in the
136
142
  * original array.
137
143
  *
138
- * @typeParam Data - type of the data property of the RowDef object
144
+ * @typeParam Data - type of the data property of the {@link RowDef} object
139
145
  *
140
146
  * @public
141
147
  */
@@ -6,5 +6,5 @@ export interface GridFocusOutput {
6
6
  gridKeydownHandler: KeyboardEventHandler<HTMLDivElement>;
7
7
  }
8
8
  declare const useGridFocus: (gridRef: RefObject<HTMLDivElement | null>, numRows: number, // Number that includes the header row
9
- numCols: number) => GridFocusOutput;
9
+ numCols: number, sortableColIndices: number[]) => GridFocusOutput;
10
10
  export default useGridFocus;
@@ -3,7 +3,7 @@ var startingCoordinates = {
3
3
  ariaColIndex: 1,
4
4
  ariaRowIndex: 1,
5
5
  };
6
- var useGridFocus = function (gridRef, numRows, numCols) {
6
+ var useGridFocus = function (gridRef, numRows, numCols, sortableColIndices) {
7
7
  var _a = useState(startingCoordinates), coords = _a[0], setCoords = _a[1];
8
8
  // Even though row and col count can be gotten from attributes, it needs to
9
9
  // be a prop here to update effective coordinates at the appropriate times.
@@ -11,9 +11,16 @@ var useGridFocus = function (gridRef, numRows, numCols) {
11
11
  ariaColIndex: Math.min(coords.ariaColIndex, numCols),
12
12
  ariaRowIndex: Math.min(coords.ariaRowIndex, numRows),
13
13
  }); }, [coords.ariaColIndex, coords.ariaRowIndex, numCols, numRows]);
14
+ var currentCellIsSortableHeader = useMemo(function () {
15
+ if (coords.ariaRowIndex !== 1) {
16
+ return false;
17
+ }
18
+ return sortableColIndices.includes(coords.ariaColIndex);
19
+ }, [coords.ariaColIndex, coords.ariaRowIndex, sortableColIndices]);
14
20
  var gridClickHandler = useCallback(function (event) {
15
21
  var cursor = event.target;
16
- while (cursor !== event.currentTarget && !cursor.hasAttribute("aria-colindex")) {
22
+ while (cursor !== event.currentTarget &&
23
+ !cursor.hasAttribute("aria-colindex")) {
17
24
  cursor = cursor.parentElement;
18
25
  }
19
26
  if (!cursor.hasAttribute("aria-colindex")) {
@@ -116,15 +123,23 @@ var useGridFocus = function (gridRef, numRows, numCols) {
116
123
  if (!gridRef.current.contains(document.activeElement)) {
117
124
  return;
118
125
  }
119
- var elToFocus = gridRef.current.querySelector(":scope > div > div[aria-rowindex=\"".concat(effectiveCoords.ariaRowIndex, "\"] > div[aria-colindex=\"").concat(effectiveCoords.ariaColIndex, "\"]"));
126
+ var cellSelector = ":scope > div > div[aria-rowindex=\"".concat(effectiveCoords.ariaRowIndex, "\"] > div[aria-colindex=\"").concat(effectiveCoords.ariaColIndex, "\"]");
127
+ var elToFocus = gridRef.current.querySelector(currentCellIsSortableHeader
128
+ ? cellSelector + " .rbdg-grid-header-button"
129
+ : cellSelector);
120
130
  if (elToFocus !== document.activeElement) {
121
131
  elToFocus.focus({ preventScroll: true });
122
132
  }
123
- }, [effectiveCoords.ariaColIndex, effectiveCoords.ariaRowIndex, gridRef]);
133
+ }, [
134
+ effectiveCoords.ariaColIndex,
135
+ effectiveCoords.ariaRowIndex,
136
+ gridRef,
137
+ currentCellIsSortableHeader,
138
+ ]);
124
139
  return {
125
140
  effectiveCoords: effectiveCoords,
126
141
  gridClickHandler: gridClickHandler,
127
- gridKeydownHandler: gridKeydownHandler
142
+ gridKeydownHandler: gridKeydownHandler,
128
143
  };
129
144
  };
130
145
  export default useGridFocus;
package/grid/main/Grid.js CHANGED
@@ -15,11 +15,12 @@ import useGridFocus from "../focus/useGridFocus";
15
15
  * @public
16
16
  */
17
17
  var Grid = function (_a) {
18
- var rows = _a.rows, cols = _a.cols, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant;
18
+ var rows = _a.rows, cols = _a.cols, sortModel = _a.sortModel, width = _a.width, height = _a.height, variant = _a.variant, stripes = _a.stripes, hover = _a.hover, borders = _a.borders, small = _a.small, divider = _a.divider, borderVariant = _a.borderVariant, headerCellVariant = _a.headerCellVariant, headerRowVariant = _a.headerRowVariant, bodyCellVariant = _a.bodyCellVariant, bodyRowVariant = _a.bodyRowVariant, headerCellFocusVariant = _a.headerCellFocusVariant, bodyCellFocusVariant = _a.bodyCellFocusVariant;
19
19
  var _b = useCombinedPipeline({
20
20
  rows: rows,
21
21
  cols: cols,
22
- }), displayRows = _b.displayRows, filteredRows = _b.filteredRows;
22
+ sortModel: sortModel,
23
+ }), displayRows = _b.displayRows, filteredRows = _b.filteredRows, sortedRowsOutput = _b.sortedRowsOutput;
23
24
  var colNameToWidth = useColNameToWidth(cols);
24
25
  var augFormattedRows = useAugFormattedRows(colNameToWidth, displayRows);
25
26
  var gridStyle = useMemo(function () {
@@ -48,7 +49,12 @@ var Grid = function (_a) {
48
49
  }, [width, height]);
49
50
  var vertScrollable = height !== undefined && height !== "auto";
50
51
  var gridRef = useRef(null);
51
- var _c = useGridFocus(gridRef, rows.length + 1, cols.length), effectiveCoords = _c.effectiveCoords, gridClickHandler = _c.gridClickHandler, gridKeydownHandler = _c.gridKeydownHandler;
52
+ var sortableColIndices = sortModel
53
+ ? cols
54
+ .map(function (_, index) { return index + 1; })
55
+ .filter(function (ariaColIndex) { return cols[ariaColIndex - 1].sortable; })
56
+ : [];
57
+ var _c = useGridFocus(gridRef, rows.length + 1, cols.length, sortableColIndices), effectiveCoords = _c.effectiveCoords, gridClickHandler = _c.gridClickHandler, gridKeydownHandler = _c.gridKeydownHandler;
52
58
  var onCopy = useCallback(function (event) {
53
59
  var _a;
54
60
  if (!((_a = gridRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))) {
@@ -73,6 +79,6 @@ var Grid = function (_a) {
73
79
  "rbdg-grid-group-divider": !!divider,
74
80
  }, "rbdg-grid", variant && "".concat(CSS_PREFIX, "-").concat(variant), borderVariant && "border-".concat(borderVariant)), role: "grid", "aria-colcount": cols.length, "aria-rowcount": filteredRows.length + 1, children: [_jsx(GridHeader, { cols: cols, rowVariant: headerRowVariant, cellVariant: headerCellVariant, vertScrollable: vertScrollable, focusColIndex: effectiveCoords.ariaRowIndex === 1
75
81
  ? effectiveCoords.ariaColIndex
76
- : null, cellFocusVariant: headerCellFocusVariant }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
82
+ : null, cellFocusVariant: headerCellFocusVariant, sortInfo: sortedRowsOutput }), _jsx(GridBody, { focusCoords: effectiveCoords, augFormattedRows: augFormattedRows, cols: cols, rowVariant: bodyRowVariant, cellVariant: bodyCellVariant, cellFocusVariant: bodyCellFocusVariant })] }));
77
83
  };
78
84
  export default Grid;
@@ -3,14 +3,41 @@ import getWidthStyles from "./getWidthStyles";
3
3
  import classNames from "classnames";
4
4
  import { CSS_PREFIX, DEFAULT_COL_WIDTH } from "../../common/constants";
5
5
  import { GRID_HEADER_DATA_TEST_ID } from "../constants";
6
+ import HeaderToggleButton from "../sort/HeaderToggleButton";
7
+ import sortOrderToAriaSort from "../../common/sorting/sortOrderToAriaSort";
6
8
  var GridHeader = function (_a) {
7
- var cols = _a.cols, vertScrollable = _a.vertScrollable, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusColIndex = _a.focusColIndex, cellFocusVariant = _a.cellFocusVariant;
9
+ var cols = _a.cols, vertScrollable = _a.vertScrollable, rowVariant = _a.rowVariant, cellVariant = _a.cellVariant, focusColIndex = _a.focusColIndex, cellFocusVariant = _a.cellFocusVariant, sortInfo = _a.sortInfo;
10
+ var sortingEnabled = sortInfo.sortingEnabled, sortColDef = sortInfo.sortColDef, setSortColDef = sortInfo.setSortColDef;
11
+ var getSortButtonListener = function (colName) { return function () {
12
+ if ((sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) !== colName) {
13
+ setSortColDef({
14
+ name: colName,
15
+ order: "asc",
16
+ });
17
+ return;
18
+ }
19
+ if (sortColDef.order === "asc") {
20
+ setSortColDef({
21
+ name: colName,
22
+ order: "desc",
23
+ });
24
+ return;
25
+ }
26
+ setSortColDef(null);
27
+ }; };
8
28
  return (_jsx("div", { "data-testid": GRID_HEADER_DATA_TEST_ID, role: "rowgroup", className: classNames(vertScrollable ? ["position-sticky", "z-1", "top-0"] : []), children: _jsx("div", { role: "row", className: classNames("d-flex", "flex-row", rowVariant && "".concat(CSS_PREFIX, "-").concat(rowVariant)), "aria-rowindex": 1, children: cols.map(function (col, index) {
9
29
  var ariaColIndex = index + 1;
10
30
  var isFocused = focusColIndex === ariaColIndex;
11
31
  var cellVariantVal = cellVariant && cellVariant(col, index);
12
32
  var cellFocusVariantVal = cellFocusVariant && cellFocusVariant(col, index);
13
- return (_jsx("div", { tabIndex: isFocused ? 0 : -1, className: classNames("rbdg-grid-cell", "fw-bold", cellVariantVal && "".concat(CSS_PREFIX, "-").concat(cellVariantVal), cellFocusVariantVal && "focus-ring-".concat(cellFocusVariantVal), { "z-2": isFocused, "rbdg-focusable-cell": isFocused }), role: "columnheader", "aria-colindex": ariaColIndex, style: getWidthStyles(col.width || DEFAULT_COL_WIDTH), children: col.label }, col.name));
33
+ var currentColSortingEnabled = sortingEnabled && col.sortable;
34
+ return (_jsx("div", { tabIndex: isFocused && !currentColSortingEnabled ? 0 : -1, className: classNames("rbdg-grid-cell", "fw-bold", cellVariantVal && "".concat(CSS_PREFIX, "-").concat(cellVariantVal), cellFocusVariantVal && "focus-ring-".concat(cellFocusVariantVal), {
35
+ "z-2": isFocused,
36
+ "rbdg-focusable-cell": isFocused && !currentColSortingEnabled,
37
+ "rbdg-sortable-header-cell": currentColSortingEnabled,
38
+ }), role: "columnheader", "aria-colindex": ariaColIndex, "aria-sort": currentColSortingEnabled && (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === col.name
39
+ ? sortOrderToAriaSort(sortColDef.order)
40
+ : undefined, style: getWidthStyles(col.width || DEFAULT_COL_WIDTH), children: currentColSortingEnabled ? (_jsx(HeaderToggleButton, { tabIndex: isFocused ? 0 : -1, colLabel: col.label, sortOrder: (sortColDef === null || sortColDef === void 0 ? void 0 : sortColDef.name) === col.name ? sortColDef.order : null, onClick: getSortButtonListener(col.name) })) : (col.label) }, col.name));
14
41
  }) }) }));
15
42
  };
16
43
  export default GridHeader;
@@ -1,6 +1,7 @@
1
1
  import { AugFormattedRow } from "../../common/internalTypes";
2
2
  import { FocusCoordinates } from "../focus/types";
3
3
  import { GridProps } from "./types";
4
+ import { SortedRowsOutput } from "../../common/pipeline/useCombinedPipeline/useSortedRows";
4
5
  /**
5
6
  * Props interface for the GridHeader component
6
7
  *
@@ -13,6 +14,7 @@ export interface GridHeaderProps {
13
14
  cellVariant?: GridProps["headerCellVariant"];
14
15
  focusColIndex: number | null;
15
16
  cellFocusVariant?: GridProps["headerCellFocusVariant"];
17
+ sortInfo: Omit<SortedRowsOutput, "sortedRows">;
16
18
  }
17
19
  /**
18
20
  * Props interface for the GridBody component
@@ -6,8 +6,8 @@ import { CellData, ColDef, FormattedRow, MainComponentSharedProps } from "../../
6
6
  * @param cell - details the current cell
7
7
  * @param row - details of the entire row that the current cell is in
8
8
  * @param colIndex - zero-based column index of the current cell
9
- * @param displayIndex - the zero-based index of the row that the cell is in. The
10
- * index is based on how the cell is actually displayed, after pagination,
9
+ * @param displayIndex - the zero-based index of the row that the cell is in.
10
+ * The index is based on how the cell is actually displayed after pagination,
11
11
  * filtering, and sorting are applied.
12
12
  *
13
13
  * @returns - a string that is name of the color variant or null for no color
@@ -43,10 +43,14 @@ export type GridProps = MainComponentSharedProps & GridSpecificProps;
43
43
  export interface GridSpecificProps {
44
44
  /**
45
45
  * The height setting of the grid
46
+ *
47
+ * @defaultValue `auto`
46
48
  */
47
49
  height?: GridHeightSetting;
48
50
  /**
49
51
  * The width setting of the grid
52
+ *
53
+ * @defaultValue `auto`
50
54
  */
51
55
  width?: GridWidthSetting;
52
56
  /**
@@ -107,12 +111,20 @@ export interface GridSpecificProps {
107
111
  /**
108
112
  * The type of the prop to set grid height behavior
109
113
  *
114
+ * - number: fixed height of grid in pixels
115
+ * - `auto`: takes on the intrinsic height of the contents
116
+ * - `parent`: takes on 100% of the parent height
117
+ *
110
118
  * @public
111
119
  */
112
120
  export type GridHeightSetting = number | "auto" | "parent";
113
121
  /**
114
122
  * The type of the prop to set grid width behavior
115
123
  *
124
+ * - number: fixed width of grid in pixels
125
+ * - `auto`: takes on the intrinsic width of the contents
126
+ * - `parent`: takes on 100% of the parent width
127
+ *
116
128
  * @public
117
129
  */
118
130
  export type GridWidthSetting = number | "auto" | "parent";
@@ -0,0 +1,11 @@
1
+ import { SortOrder } from "../../common";
2
+ import { FC, MouseEventHandler } from "react";
3
+ export interface HeaderToggleButtonProps {
4
+ colLabel: string;
5
+ sortOrder: SortOrder | null;
6
+ onClick: MouseEventHandler<HTMLButtonElement>;
7
+ tabIndex: number;
8
+ className?: string;
9
+ }
10
+ declare const HeaderToggleButton: FC<HeaderToggleButtonProps>;
11
+ export default HeaderToggleButton;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import CaretUp from "../../common/icons/CaretUp";
3
+ import CaretDownFill from "../../common/icons/CaretDownFill";
4
+ import CaretUpFill from "../../common/icons/CaretUpFill";
5
+ import classNames from "classnames";
6
+ var HeaderToggleButton = function (_a) {
7
+ var colLabel = _a.colLabel, sortOrder = _a.sortOrder, onClick = _a.onClick, tabIndex = _a.tabIndex, className = _a.className;
8
+ function getIcon() {
9
+ switch (sortOrder) {
10
+ case "asc":
11
+ return _jsx(CaretUpFill, { className: "rbdg-grid-header-button-icon" });
12
+ case "desc":
13
+ return _jsx(CaretDownFill, { className: "rbdg-grid-header-button-icon" });
14
+ default:
15
+ return (_jsx(CaretUp, { className: "rbdg-grid-header-button-icon rbdg-grid-header-button-hover-only-icon" }));
16
+ }
17
+ }
18
+ function getAriaLabelSuffix() {
19
+ switch (sortOrder) {
20
+ case "asc":
21
+ return "(Sorted ascending. Click to sort descending.)";
22
+ case "desc":
23
+ return "(Sorted descending. Click to stop sorting.)";
24
+ default:
25
+ return "(Not sorted. Click to sort ascending.)";
26
+ }
27
+ }
28
+ return (_jsxs("button", { "aria-label": colLabel + " " + getAriaLabelSuffix(), onClick: onClick, className: classNames("rbdg-grid-header-button", className), tabIndex: tabIndex, children: [_jsx("span", { className: "rbdg-grid-header-button-label", children: colLabel }), getIcon()] }));
29
+ };
30
+ export default HeaderToggleButton;
package/grid.css CHANGED
@@ -1 +1 @@
1
- .rbdg-grid>div,.rbdg-grid>div>div,.rbdg-grid>div>div>div{border-color:inherit;border-style:solid;border-width:0}.rbdg-grid{--rbdg-grid-color: var(--bs-emphasis-color);--rbdg-grid-bg: var(--bs-body-bg);--rbdg-grid-border-color: var(--bs-border-color);--rbdg-grid-accent-bg: transparent;--rbdg-grid-striped-color: var(--bs-emphasis-color);--rbdg-grid-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);--rbdg-grid-active-color: var(--bs-emphasis-color);--rbdg-grid-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);--rbdg-grid-hover-color: var(--bs-emphasis-color);--rbdg-grid-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);border-color:var(--rbdg-grid-border-color)}.rbdg-grid>div{width:min-content}.rbdg-grid>div>div>div{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:.5rem .5rem;color:var(--rbdg-grid-color-state, var(--rbdg-grid-color-type, var(--rbdg-grid-color)));background-color:var(--rbdg-grid-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg)))}.rbdg-grid>div>div>div.rbdg-focusable-cell:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid>div:first-child>div>div{border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-group-divider{--rbdg-grid-divider-border-width: calc(var(--bs-border-width) * 2);--rbdg-grid-divider-border-style: solid;--rbdg-grid-divider-border-color: currentcolor}.rbdg-grid-sm>div>div>div{padding:.25rem .25rem}.rbdg-grid-bordered{border-width:var(--bs-border-width);border-style:solid}.rbdg-grid-bordered>div>div>div:not(:last-child){border-width:0 var(--bs-border-width) 0 0}.rbdg-grid-bordered>div>div>div:last-child{border-width:0}.rbdg-grid-bordered>div:first-child>div{border-top-width:0;border-right-width:0;border-left-width:0;border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-bordered>div:last-child>div:not(:last-child){border-width:0 0 var(--bs-border-width) 0}.rbdg-grid-borderless{--rbdg-grid-divider-borderless-width: 0}.rbdg-grid-borderless>div>div>div{border-bottom-width:0}.rbdg-grid-borderless>:not(:first-child){border-top-width:0}.rbdg-grid-striped>div:nth-of-type(2)>div:nth-of-type(odd)>div{--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-striped-columns>div>div>:nth-child(even){--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-active{--rbdg-grid-color-state: var(--bs-grid-active-color);--rbdg-grid-bg-state: var(--rbdg-grid-active-bg)}.rbdg-grid-hover>div:nth-of-type(2)>div:hover>div{--rbdg-grid-color-state: var(--rbdg-grid-hover-color);--rbdg-grid-bg-state: var(--rbdg-grid-hover-bg)}.rbdg-grid-primary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 226, 254.6);--rbdg-grid-border-color: rgb(165.28, 180.8, 203.68);--rbdg-grid-striped-bg: rgb(196.27, 214.7, 241.87);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 203.4, 229.14);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 209.05, 235.505);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-secondary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(225.6, 227.4, 229);--rbdg-grid-border-color: rgb(180.48, 181.92, 183.2);--rbdg-grid-striped-bg: rgb(214.32, 216.03, 217.55);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(203.04, 204.66, 206.1);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(208.68, 210.345, 211.825);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-success{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(209, 231, 220.8);--rbdg-grid-border-color: rgb(167.2, 184.8, 176.64);--rbdg-grid-striped-bg: rgb(198.55, 219.45, 209.76);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(188.1, 207.9, 198.72);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(193.325, 213.675, 204.24);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-info{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 244.4, 252);--rbdg-grid-border-color: rgb(165.28, 195.52, 201.6);--rbdg-grid-striped-bg: rgb(196.27, 232.18, 239.4);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 219.96, 226.8);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 226.07, 233.1);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-warning{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(255, 242.6, 205.4);--rbdg-grid-border-color: rgb(204, 194.08, 164.32);--rbdg-grid-striped-bg: rgb(242.25, 230.47, 195.13);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(229.5, 218.34, 184.86);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(235.875, 224.405, 189.995);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-danger{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(248, 214.6, 217.8);--rbdg-grid-border-color: rgb(198.4, 171.68, 174.24);--rbdg-grid-striped-bg: rgb(235.6, 203.87, 206.91);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 193.14, 196.02);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 198.505, 201.465);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-light{--rbdg-grid-color: #000;--rbdg-grid-bg: #f8f9fa;--rbdg-grid-border-color: rgb(198.4, 199.2, 200);--rbdg-grid-striped-bg: rgb(235.6, 236.55, 237.5);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 224.1, 225);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 230.325, 231.25);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-dark{--rbdg-grid-color: #fff;--rbdg-grid-bg: #212529;--rbdg-grid-border-color: rgb(77.4, 80.6, 83.8);--rbdg-grid-striped-bg: rgb(44.1, 47.9, 51.7);--rbdg-grid-striped-color: #fff;--rbdg-grid-active-bg: rgb(55.2, 58.8, 62.4);--rbdg-grid-active-color: #fff;--rbdg-grid-hover-bg: rgb(49.65, 53.35, 57.05);--rbdg-grid-hover-color: #fff;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}
1
+ .rbdg-grid>div,.rbdg-grid>div>div,.rbdg-grid>div>div>div{border-color:inherit;border-style:solid;border-width:0}.rbdg-grid{--rbdg-grid-color: var(--bs-emphasis-color);--rbdg-grid-bg: var(--bs-body-bg);--rbdg-grid-border-color: var(--bs-border-color);--rbdg-grid-accent-bg: transparent;--rbdg-grid-striped-color: var(--bs-emphasis-color);--rbdg-grid-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);--rbdg-grid-active-color: var(--bs-emphasis-color);--rbdg-grid-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);--rbdg-grid-hover-color: var(--bs-emphasis-color);--rbdg-grid-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);border-color:var(--rbdg-grid-border-color)}.rbdg-grid>div{width:min-content}.rbdg-grid>div>div>div{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:.5rem .5rem;color:var(--rbdg-grid-color-state, var(--rbdg-grid-color-type, var(--rbdg-grid-color)));background-color:var(--rbdg-grid-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg)))}.rbdg-grid>div>div>div.rbdg-sortable-header-cell{padding:0;overflow:visible}.rbdg-grid>div>div>div.rbdg-focusable-cell:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid>div:first-child>div>div{border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-group-divider{--rbdg-grid-divider-border-width: calc(var(--bs-border-width) * 2);--rbdg-grid-divider-border-style: solid;--rbdg-grid-divider-border-color: currentcolor}.rbdg-grid-sm>div>div>div{padding:.25rem .25rem}.rbdg-grid-bordered{border-width:var(--bs-border-width);border-style:solid}.rbdg-grid-bordered>div>div>div:not(:last-child){border-width:0 var(--bs-border-width) 0 0}.rbdg-grid-bordered>div>div>div:last-child{border-width:0}.rbdg-grid-bordered>div:first-child>div{border-top-width:0;border-right-width:0;border-left-width:0;border-bottom-width:var(--rbdg-grid-divider-border-width, var(--rbdg-grid-divider-borderless-width, var(--bs-border-width)));border-bottom-style:var(--rbdg-grid-divider-border-style, inherit);border-bottom-color:var(--rbdg-grid-divider-border-color, inherit)}.rbdg-grid-bordered>div:last-child>div:not(:last-child){border-width:0 0 var(--bs-border-width) 0}.rbdg-grid-borderless{--rbdg-grid-divider-borderless-width: 0}.rbdg-grid-borderless>div>div>div{border-bottom-width:0}.rbdg-grid-borderless>:not(:first-child){border-top-width:0}.rbdg-grid-striped>div:nth-of-type(2)>div:nth-of-type(odd)>div{--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-striped-columns>div>div>:nth-child(even){--rbdg-grid-color-type: var(--rbdg-grid-striped-color);--rbdg-grid-bg-type: var(--rbdg-grid-striped-bg)}.rbdg-grid-active{--rbdg-grid-color-state: var(--bs-grid-active-color);--rbdg-grid-bg-state: var(--rbdg-grid-active-bg)}.rbdg-grid-hover>div:nth-of-type(2)>div:hover>div{--rbdg-grid-color-state: var(--rbdg-grid-hover-color);--rbdg-grid-bg-state: var(--rbdg-grid-hover-bg)}.rbdg-grid-primary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 226, 254.6);--rbdg-grid-border-color: rgb(165.28, 180.8, 203.68);--rbdg-grid-striped-bg: rgb(196.27, 214.7, 241.87);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 203.4, 229.14);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 209.05, 235.505);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-secondary{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(225.6, 227.4, 229);--rbdg-grid-border-color: rgb(180.48, 181.92, 183.2);--rbdg-grid-striped-bg: rgb(214.32, 216.03, 217.55);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(203.04, 204.66, 206.1);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(208.68, 210.345, 211.825);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-success{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(209, 231, 220.8);--rbdg-grid-border-color: rgb(167.2, 184.8, 176.64);--rbdg-grid-striped-bg: rgb(198.55, 219.45, 209.76);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(188.1, 207.9, 198.72);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(193.325, 213.675, 204.24);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-info{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(206.6, 244.4, 252);--rbdg-grid-border-color: rgb(165.28, 195.52, 201.6);--rbdg-grid-striped-bg: rgb(196.27, 232.18, 239.4);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(185.94, 219.96, 226.8);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(191.105, 226.07, 233.1);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-warning{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(255, 242.6, 205.4);--rbdg-grid-border-color: rgb(204, 194.08, 164.32);--rbdg-grid-striped-bg: rgb(242.25, 230.47, 195.13);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(229.5, 218.34, 184.86);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(235.875, 224.405, 189.995);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-danger{--rbdg-grid-color: #000;--rbdg-grid-bg: rgb(248, 214.6, 217.8);--rbdg-grid-border-color: rgb(198.4, 171.68, 174.24);--rbdg-grid-striped-bg: rgb(235.6, 203.87, 206.91);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 193.14, 196.02);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 198.505, 201.465);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-light{--rbdg-grid-color: #000;--rbdg-grid-bg: #f8f9fa;--rbdg-grid-border-color: rgb(198.4, 199.2, 200);--rbdg-grid-striped-bg: rgb(235.6, 236.55, 237.5);--rbdg-grid-striped-color: #000;--rbdg-grid-active-bg: rgb(223.2, 224.1, 225);--rbdg-grid-active-color: #000;--rbdg-grid-hover-bg: rgb(229.4, 230.325, 231.25);--rbdg-grid-hover-color: #000;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-dark{--rbdg-grid-color: #fff;--rbdg-grid-bg: #212529;--rbdg-grid-border-color: rgb(77.4, 80.6, 83.8);--rbdg-grid-striped-bg: rgb(44.1, 47.9, 51.7);--rbdg-grid-striped-color: #fff;--rbdg-grid-active-bg: rgb(55.2, 58.8, 62.4);--rbdg-grid-active-color: #fff;--rbdg-grid-hover-bg: rgb(49.65, 53.35, 57.05);--rbdg-grid-hover-color: #fff;color:var(--rbdg-grid-color);border-color:var(--rbdg-grid-border-color)}.rbdg-grid-header-button{display:flex;align-items:center;appearance:none;background:rgba(0,0,0,0);border:none;padding:.5rem .5rem;width:100%;height:100%;cursor:pointer;color:inherit;font-weight:inherit;text-align:inherit}.rbdg-grid-header-button .rbdg-grid-header-button-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex-shrink:1}.rbdg-grid-header-button .rbdg-grid-header-button-hover-only-icon{visibility:hidden}.rbdg-grid-header-button:hover{color:var(--rbdg-grid-hover-color);background:var(--rbdg-grid-hover-bg)}.rbdg-grid-header-button:hover .rbdg-grid-header-button-hover-only-icon{visibility:visible}.rbdg-grid-header-button:focus{outline:0;box-shadow:inset 0 0 0 9999px var(--rbdg-grid-bg-state, var(--rbdg-grid-bg-type, var(--rbdg-grid-accent-bg))),var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.rbdg-grid-header-button-icon{height:1em;flex-shrink:0}
package/grid.scss CHANGED
@@ -11,6 +11,19 @@ $rbdg-prefix: "rbdg-";
11
11
  border-width: 0;
12
12
  }
13
13
 
14
+ @mixin rbdg-focusable-element {
15
+ outline: 0;
16
+ box-shadow:
17
+ inset 0 0 0 9999px
18
+ var(
19
+ --#{$rbdg-prefix}grid-bg-state,
20
+ var(--#{$rbdg-prefix}grid-bg-type, var(--#{$rbdg-prefix}grid-accent-bg))
21
+ ),
22
+ var(--#{$prefix}focus-ring-x, 0) var(--#{$prefix}focus-ring-y, 0)
23
+ var(--#{$prefix}focus-ring-blur, 0) var(--#{$prefix}focus-ring-width)
24
+ var(--#{$prefix}focus-ring-color);
25
+ }
26
+
14
27
  // While these rules seem to work, the way that the three border modes, default; bordered; and borderless override each
15
28
  // other is quite hard to understand.
16
29
  // Consider refactoring so that each type mode, including default, has a separate class that contains rules for just
@@ -47,28 +60,30 @@ $rbdg-prefix: "rbdg-";
47
60
  padding: $table-cell-padding-y $table-cell-padding-x;
48
61
  color: var(
49
62
  --#{$rbdg-prefix}grid-color-state,
50
- var(--#{$rbdg-prefix}grid-color-type, var(--#{$rbdg-prefix}grid-color))
63
+ var(
64
+ --#{$rbdg-prefix}grid-color-type,
65
+ var(--#{$rbdg-prefix}grid-color)
66
+ )
51
67
  );
52
68
  background-color: var(--#{$rbdg-prefix}grid-bg);
53
69
  border-bottom-width: $table-border-width;
54
- box-shadow: inset 0 0 0 9999px var(
55
- --#{$rbdg-prefix}grid-bg-state,
70
+ box-shadow: inset 0 0 0 9999px
56
71
  var(
57
- --#{$rbdg-prefix}grid-bg-type,
58
- var(--#{$rbdg-prefix}grid-accent-bg)
59
- )
60
- );
72
+ --#{$rbdg-prefix}grid-bg-state,
73
+ var(
74
+ --#{$rbdg-prefix}grid-bg-type,
75
+ var(--#{$rbdg-prefix}grid-accent-bg)
76
+ )
77
+ );
78
+ }
79
+
80
+ > div.rbdg-sortable-header-cell {
81
+ padding: 0;
82
+ overflow: visible;
61
83
  }
62
84
 
63
85
  > div.rbdg-focusable-cell:focus {
64
- outline: 0;
65
- box-shadow: inset 0 0 0 9999px var(
66
- --#{$rbdg-prefix}grid-bg-state,
67
- var(
68
- --#{$rbdg-prefix}grid-bg-type,
69
- var(--#{$rbdg-prefix}grid-accent-bg)
70
- )
71
- ), var(--#{$prefix}focus-ring-x, 0) var(--#{$prefix}focus-ring-y, 0) var(--#{$prefix}focus-ring-blur, 0) var(--#{$prefix}focus-ring-width) var(--#{$prefix}focus-ring-color);
86
+ @include rbdg-focusable-element;
72
87
  }
73
88
  }
74
89
  }
@@ -223,21 +238,68 @@ $rbdg-prefix: "rbdg-";
223
238
  @include rbdg-grid-variant($color, $value);
224
239
  }
225
240
 
226
- // A note about Responsive Tables
227
- //
228
- // The Bootstrap _tables.scss file contains a series of classes to apply responsive tables at various breakpoints.
229
- // There is no such equivalent for RBDG flex grid for the following reason.
230
- //
231
- // The RBDG flex grid is a div of type "block," so the concept of "responsive" scrollable breakpoints doesn't apply.
232
- // It appears that for a table, even if the width is to 100%, the browser sometimes disobeys this setting causing
233
- // the width to be more than the parent, hence the need for responsive tables. Divs do not appear to have this problem.
234
- //
235
- // The RBDG flex grid provides other options to achieving a horizontally scrollable grid. They are as follows.
236
- //
237
- // When using the default or "auto" setting for the RBDG grid's "width," the intrinsic width of the grid columns is
238
- // used. In such circumstances, if one wants to make the grid scrollable horizontally, they can enclose the grid in a
239
- // horizontally-scrollable div.
240
- //
241
- // When the grid's width is to set to "parent", the grid takes on the width of the parent (width 100% CSS value) just
242
- // like the Bootstrap table does. In this case, the grid div itself is horizontally scrollable. In contrast, for
243
- // responsive Bootstrap tables, it is a div that encloses the table element that is scrollable.
241
+ /*
242
+ A Note About Responsive Tables
243
+
244
+ The Bootstrap _tables.scss file contains a series of classes to apply responsive tables at various breakpoints.
245
+ There is no such equivalent for RBDG flex grid for the following reason.
246
+
247
+ The RBDG flex grid is a div of type "block," so the concept of "responsive" scrollable breakpoints doesn't apply.
248
+ It appears that for a table, even if the width is to 100%, the browser sometimes disobeys this setting causing
249
+ the width to be more than the parent, hence the need for responsive tables. Divs do not appear to have this problem.
250
+
251
+ The RBDG flex grid provides other options to achieving a horizontally scrollable grid. They are as follows.
252
+
253
+ When using the default or "auto" setting for the RBDG grid's "width," the intrinsic width of the grid columns is
254
+ used. In such circumstances, if one wants to make the grid scrollable horizontally, they can enclose the grid in a
255
+ horizontally-scrollable div.
256
+
257
+ When the grid's width is to set to "parent", the grid takes on the width of the parent (width 100% CSS value) just
258
+ like the Bootstrap table does. In this case, the grid div itself is horizontally scrollable. In contrast, for
259
+ responsive Bootstrap tables, it is a div that encloses the table element that is scrollable.
260
+ */
261
+
262
+ .rbdg-grid-header-button {
263
+ display: flex;
264
+ align-items: center;
265
+ appearance: none;
266
+ background: transparent;
267
+ border: none;
268
+ padding: $table-cell-padding-y $table-cell-padding-x;
269
+ width: 100%;
270
+ height: 100%;
271
+ cursor: pointer;
272
+ color: inherit;
273
+ font-weight: inherit;
274
+ text-align: inherit;
275
+
276
+ .rbdg-grid-header-button-label {
277
+ overflow: hidden;
278
+ text-overflow: ellipsis;
279
+ white-space: nowrap;
280
+ min-width: 0;
281
+ flex-shrink: 1;
282
+ }
283
+
284
+ .rbdg-grid-header-button-hover-only-icon {
285
+ visibility: hidden;
286
+ }
287
+
288
+ &:hover {
289
+ color: var(--#{$rbdg-prefix}grid-hover-color);
290
+ background: var(--#{$rbdg-prefix}grid-hover-bg);
291
+
292
+ .rbdg-grid-header-button-hover-only-icon {
293
+ visibility: visible;
294
+ }
295
+ }
296
+
297
+ &:focus {
298
+ @include rbdg-focusable-element;
299
+ }
300
+ }
301
+
302
+ .rbdg-grid-header-button-icon {
303
+ height: 1em;
304
+ flex-shrink: 0;
305
+ }
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": "4.2.0",
4
+ "version": "4.3.0",
5
5
  "license": "MIT",
6
6
  "author": "Brook Li",
7
7
  "homepage": "https://react-bootstrap-data-grid.vercel.app/",
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useRef, useState } from "react";
4
- import { dateToDatetimeInputStr, dateToInputStr, } from "../../common";
4
+ import { dateToDatetimeInputStr, dateToInputStr } from "../../common";
5
5
  import EditControlsCell from "./EditControlsCell";
6
6
  import classNames from "classnames";
7
7
  import getWidthStyle from "../../common/util/getWidthStyle";
package/table/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EditModel, FilterModel, MainComponentSharedProps, PaginationModel, SelectModel, SortModel, StyleModel } from "../common";
1
+ import { EditModel, FilterModel, MainComponentSharedProps, PaginationModel, SelectModel, StyleModel } from "../common";
2
2
  /**
3
3
  * Available options for the displayMode prop of {@link TableSpecificProps}.
4
4
  *
@@ -17,11 +17,6 @@ export interface TableSpecificProps {
17
17
  * the pagination feature of the component.
18
18
  */
19
19
  pagination?: PaginationModel;
20
- /**
21
- * The sort model of the table. Passing a truthy value enables the
22
- * sorting feature of the component.
23
- */
24
- sortModel?: SortModel;
25
20
  /**
26
21
  * The filter model of the table. Passing a truthy value enables the
27
22
  * filtering feature of the component.
@@ -1,2 +0,0 @@
1
- declare const arrowPlaceholder: import("react/jsx-runtime").JSX.Element;
2
- export default arrowPlaceholder;
@@ -1,7 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const downArrow: import("react/jsx-runtime").JSX.Element;
2
- export default downArrow;
@@ -1,3 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const upArrow: (grayed: boolean) => import("react/jsx-runtime").JSX.Element;
2
- export default upArrow;
@@ -1,13 +0,0 @@
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;