@absreim/react-bootstrap-data-grid 0.1.4 → 1.0.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/ColHeaderCell.d.ts +1 -0
- package/ColHeaderCell.jsx +22 -5
- package/Grid.jsx +9 -6
- package/package.json +3 -3
package/ColHeaderCell.d.ts
CHANGED
package/ColHeaderCell.jsx
CHANGED
|
@@ -10,10 +10,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
10
10
|
};
|
|
11
11
|
import { useState } from "react";
|
|
12
12
|
import classNames from "classnames";
|
|
13
|
-
var getUpArrow = function (
|
|
13
|
+
var getUpArrow = function (grayed) { return (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className={classNames(__spreadArray([
|
|
14
|
+
"bi",
|
|
15
|
+
"bi-arrow-up"
|
|
16
|
+
], (grayed ? ["text-body-secondary"] : []), true))} viewBox="0 0 16 16">
|
|
17
|
+
{!grayed && (<>
|
|
18
|
+
<title>(sorted ascending)</title>
|
|
19
|
+
<desc>
|
|
20
|
+
Up arrow indicating that the column is being sorted in an ascending
|
|
21
|
+
manner
|
|
22
|
+
</desc>
|
|
23
|
+
</>)}
|
|
14
24
|
<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"/>
|
|
15
25
|
</svg>); };
|
|
16
26
|
var downArrow = (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-arrow-down" viewBox="0 0 16 16">
|
|
27
|
+
<title>(sorted descending)</title>
|
|
28
|
+
<desc>
|
|
29
|
+
Down arrow indicating that the column is being sorted in an descending
|
|
30
|
+
manner
|
|
31
|
+
</desc>
|
|
17
32
|
<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"/>
|
|
18
33
|
</svg>);
|
|
19
34
|
// Temporary solution to prevent column widths from changing when hovering over
|
|
@@ -22,7 +37,7 @@ var downArrow = (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
|
22
37
|
// values.
|
|
23
38
|
var placeholder = (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-arrow-down" viewBox="0 0 16 16"></svg>);
|
|
24
39
|
var ColHeaderCell = function (_a) {
|
|
25
|
-
var label = _a.label, sortModel = _a.sortModel;
|
|
40
|
+
var label = _a.label, sortModel = _a.sortModel, ariaColIndex = _a.ariaColIndex;
|
|
26
41
|
var _b = useState(false), isHovering = _b[0], setIsHovering = _b[1];
|
|
27
42
|
var handleMouseOver = function () {
|
|
28
43
|
return setIsHovering(true);
|
|
@@ -55,19 +70,21 @@ var ColHeaderCell = function (_a) {
|
|
|
55
70
|
switch (sortModel.sortOrder) {
|
|
56
71
|
case null: {
|
|
57
72
|
if (isHovering) {
|
|
58
|
-
return getUpArrow(
|
|
73
|
+
return getUpArrow(true);
|
|
59
74
|
}
|
|
60
75
|
return placeholder;
|
|
61
76
|
}
|
|
62
77
|
case "asc": {
|
|
63
|
-
return getUpArrow();
|
|
78
|
+
return getUpArrow(false);
|
|
64
79
|
}
|
|
65
80
|
case "desc": {
|
|
66
81
|
return downArrow;
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
};
|
|
70
|
-
return (<th onClick={sortModel && handleClick} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut} aria-description=
|
|
85
|
+
return (<th onClick={sortModel && handleClick} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut} aria-description={sortModel
|
|
86
|
+
? "Column header"
|
|
87
|
+
: "Column header that can be clicked to change the sorting mode"} style={{ cursor: sortModel ? "pointer" : "default" }} aria-colindex={ariaColIndex}>
|
|
71
88
|
{label}
|
|
72
89
|
{getSortSymbol()}
|
|
73
90
|
</th>);
|
package/Grid.jsx
CHANGED
|
@@ -79,7 +79,8 @@ var Grid = function (_a) {
|
|
|
79
79
|
var displayRow = [];
|
|
80
80
|
Object.keys(row).forEach(function (name) {
|
|
81
81
|
if (!nameToIndex.has(name)) {
|
|
82
|
-
|
|
82
|
+
console.error("Warning: row data contains a property named \"".concat(name, "\", but it was not found among the column definitions."));
|
|
83
|
+
return;
|
|
83
84
|
}
|
|
84
85
|
var index = nameToIndex.get(name);
|
|
85
86
|
var formatter = cols[index].formatter;
|
|
@@ -125,8 +126,8 @@ var Grid = function (_a) {
|
|
|
125
126
|
return (<div>
|
|
126
127
|
<table className="table">
|
|
127
128
|
<thead>
|
|
128
|
-
<tr>
|
|
129
|
-
{cols.map(function (_a) {
|
|
129
|
+
<tr aria-rowindex={1}>
|
|
130
|
+
{cols.map(function (_a, index) {
|
|
130
131
|
var _b;
|
|
131
132
|
var name = _a.name, label = _a.label, sortable = _a.sortable;
|
|
132
133
|
var colSortModel = sortModel && sortable
|
|
@@ -139,13 +140,15 @@ var Grid = function (_a) {
|
|
|
139
140
|
},
|
|
140
141
|
}
|
|
141
142
|
: undefined;
|
|
142
|
-
return (<ColHeaderCell key={name} label={label} sortModel={colSortModel}/>);
|
|
143
|
+
return (<ColHeaderCell key={name} label={label} sortModel={colSortModel} ariaColIndex={index + 1}/>);
|
|
143
144
|
})}
|
|
144
145
|
</tr>
|
|
145
146
|
</thead>
|
|
146
147
|
<tbody>
|
|
147
|
-
{displayRows.map(function (row, index) { return (<tr key={index}>
|
|
148
|
-
{row.map(function (value, index) { return (<td key={index}
|
|
148
|
+
{displayRows.map(function (row, index) { return (<tr key={index} aria-rowindex={index + 2}>
|
|
149
|
+
{row.map(function (value, index) { return (<td key={index} aria-colindex={index + 1}>
|
|
150
|
+
{value}
|
|
151
|
+
</td>); })}
|
|
149
152
|
</tr>); })}
|
|
150
153
|
</tbody>
|
|
151
154
|
</table>
|
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": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Brook Li",
|
|
7
7
|
"homepage": "https://react-bootstrap-data-grid.vercel.app/",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"classnames": "^2.5.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"react": "^
|
|
21
|
-
"react-dom": "^
|
|
20
|
+
"react": "^19",
|
|
21
|
+
"react-dom": "^19"
|
|
22
22
|
},
|
|
23
23
|
"main": "./index.js",
|
|
24
24
|
"module": "./index.js",
|