@urbanos/react-discovery-ui 2.1.48 → 2.1.50
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.
|
@@ -14,11 +14,11 @@ var _reactTabs = require("react-tabs");
|
|
|
14
14
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
17
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
17
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
19
18
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
19
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
21
20
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
21
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
24
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -50,6 +50,12 @@ var DataTable = function DataTable(_ref) {
|
|
|
50
50
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
51
51
|
focusedCell = _useState4[0],
|
|
52
52
|
setFocusedCell = _useState4[1];
|
|
53
|
+
var focusedCellRef = (0, _react.useRef)({
|
|
54
|
+
row: 0,
|
|
55
|
+
col: 0
|
|
56
|
+
});
|
|
57
|
+
var totalRowsRef = (0, _react.useRef)(1);
|
|
58
|
+
var totalColsRef = (0, _react.useRef)(columns.length);
|
|
53
59
|
var tableRef = (0, _react.useRef)(null);
|
|
54
60
|
(0, _react.useEffect)(function () {
|
|
55
61
|
setPagination(function (prev) {
|
|
@@ -74,41 +80,71 @@ var DataTable = function DataTable(_ref) {
|
|
|
74
80
|
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
75
81
|
getPaginationRowModel: (0, _reactTable.getPaginationRowModel)()
|
|
76
82
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (moves[e.key]) {
|
|
83
|
+
|
|
84
|
+
// Keep refs current on every render so the native keydown handler always sees fresh values
|
|
85
|
+
totalRowsRef.current = table.getRowModel().rows.length + 1; // row 0 = header
|
|
86
|
+
totalColsRef.current = columns.length;
|
|
87
|
+
|
|
88
|
+
// Native keydown listener — fires before React's document-level delegation,
|
|
89
|
+
// so e.preventDefault() reliably cancels browser arrow-key scroll.
|
|
90
|
+
(0, _react.useEffect)(function () {
|
|
91
|
+
var tableEl = tableRef.current;
|
|
92
|
+
if (!tableEl) return;
|
|
93
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
94
|
+
var _focusedCellRef$curre = focusedCellRef.current,
|
|
95
|
+
row = _focusedCellRef$curre.row,
|
|
96
|
+
col = _focusedCellRef$curre.col;
|
|
97
|
+
var moves = {
|
|
98
|
+
ArrowUp: [row - 1, col],
|
|
99
|
+
ArrowDown: [row + 1, col],
|
|
100
|
+
ArrowLeft: [row, col - 1],
|
|
101
|
+
ArrowRight: [row, col + 1]
|
|
102
|
+
};
|
|
103
|
+
if (!moves[e.key]) return;
|
|
99
104
|
e.preventDefault();
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
var r = Math.max(0, Math.min(totalRowsRef.current - 1, moves[e.key][0]));
|
|
106
|
+
var c = Math.max(0, Math.min(totalColsRef.current - 1, moves[e.key][1]));
|
|
107
|
+
focusedCellRef.current = {
|
|
108
|
+
row: r,
|
|
109
|
+
col: c
|
|
110
|
+
};
|
|
111
|
+
setFocusedCell({
|
|
112
|
+
row: r,
|
|
113
|
+
col: c
|
|
114
|
+
});
|
|
115
|
+
var cell = tableEl.querySelector("[data-row=\"".concat(r, "\"][data-col=\"").concat(c, "\"]"));
|
|
116
|
+
if (cell) {
|
|
117
|
+
cell.focus({
|
|
118
|
+
preventScroll: true
|
|
119
|
+
});
|
|
120
|
+
cell.scrollIntoView({
|
|
121
|
+
block: 'nearest',
|
|
122
|
+
inline: 'nearest'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
tableEl.addEventListener('keydown', handleKeyDown);
|
|
127
|
+
return function () {
|
|
128
|
+
return tableEl.removeEventListener('keydown', handleKeyDown);
|
|
129
|
+
};
|
|
130
|
+
}, []); // empty deps — all values accessed via refs
|
|
131
|
+
|
|
103
132
|
var tabIndex = function tabIndex(row, col) {
|
|
104
133
|
return focusedCell.row === row && focusedCell.col === col ? 0 : -1;
|
|
105
134
|
};
|
|
106
135
|
var onCellFocus = function onCellFocus(row, col) {
|
|
107
|
-
|
|
136
|
+
focusedCellRef.current = {
|
|
137
|
+
row: row,
|
|
138
|
+
col: col
|
|
139
|
+
};
|
|
140
|
+
setFocusedCell({
|
|
108
141
|
row: row,
|
|
109
142
|
col: col
|
|
110
143
|
});
|
|
111
144
|
};
|
|
145
|
+
var dataRows = table.getRowModel().rows;
|
|
146
|
+
var pageIndex = pagination.pageIndex;
|
|
147
|
+
var pageSize = pagination.pageSize;
|
|
112
148
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
113
149
|
style: {
|
|
114
150
|
height: '400px',
|
|
@@ -116,52 +152,68 @@ var DataTable = function DataTable(_ref) {
|
|
|
116
152
|
}
|
|
117
153
|
}, /*#__PURE__*/_react.default.createElement("table", {
|
|
118
154
|
ref: tableRef,
|
|
155
|
+
role: "grid",
|
|
156
|
+
"aria-rowcount": dataRows.length + 1,
|
|
157
|
+
"aria-colcount": columns.length,
|
|
119
158
|
style: {
|
|
120
159
|
minWidth: "".concat(columns.length * 120, "px")
|
|
121
|
-
}
|
|
122
|
-
onKeyDown: handleKeyDown
|
|
160
|
+
}
|
|
123
161
|
}, /*#__PURE__*/_react.default.createElement("caption", null, datasetName ? "".concat(datasetName, " Dataset Preview") : 'Dataset Preview'), /*#__PURE__*/_react.default.createElement("thead", null, table.getHeaderGroups().map(function (headerGroup) {
|
|
124
162
|
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
125
|
-
key: headerGroup.id
|
|
163
|
+
key: headerGroup.id,
|
|
164
|
+
role: "row",
|
|
165
|
+
"aria-rowindex": 1
|
|
126
166
|
}, headerGroup.headers.map(function (header, colIndex) {
|
|
127
167
|
var _header$column$column;
|
|
128
168
|
return /*#__PURE__*/_react.default.createElement("th", {
|
|
129
169
|
key: header.id,
|
|
170
|
+
role: "columnheader",
|
|
130
171
|
scope: "col",
|
|
131
172
|
tabIndex: tabIndex(0, colIndex),
|
|
132
173
|
"data-row": 0,
|
|
133
174
|
"data-col": colIndex,
|
|
175
|
+
"aria-colindex": colIndex + 1,
|
|
134
176
|
onFocus: function onFocus() {
|
|
135
177
|
return onCellFocus(0, colIndex);
|
|
136
178
|
},
|
|
137
179
|
className: ((_header$column$column = header.column.columnDef.meta) === null || _header$column$column === void 0 ? void 0 : _header$column$column.headerClassName) || 'table-header'
|
|
138
180
|
}, header.isPlaceholder ? null : (0, _reactTable.flexRender)(header.column.columnDef.header, header.getContext()));
|
|
139
181
|
}));
|
|
140
|
-
})), /*#__PURE__*/_react.default.createElement("tbody", null,
|
|
182
|
+
})), /*#__PURE__*/_react.default.createElement("tbody", null, dataRows.length === 0 ? /*#__PURE__*/_react.default.createElement("tr", {
|
|
183
|
+
role: "row"
|
|
184
|
+
}, /*#__PURE__*/_react.default.createElement("td", {
|
|
185
|
+
role: "gridcell",
|
|
141
186
|
colSpan: columns.length,
|
|
142
187
|
className: "no-data-message"
|
|
143
|
-
}, "No rows found")) :
|
|
188
|
+
}, "No rows found")) : dataRows.map(function (row, rowIndex) {
|
|
144
189
|
var tableRow = rowIndex + 1;
|
|
190
|
+
var ariaRowIndex = pageIndex * pageSize + rowIndex + 2; // +1 for header, +1 for 1-based
|
|
145
191
|
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
146
192
|
key: row.id,
|
|
193
|
+
role: "row",
|
|
194
|
+
"aria-rowindex": ariaRowIndex,
|
|
147
195
|
className: rowIndex % 2 === 0 ? 'striped-row' : ''
|
|
148
196
|
}, row.getVisibleCells().map(function (cell, colIndex) {
|
|
149
197
|
var content = (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
150
198
|
return colIndex === 0 ? /*#__PURE__*/_react.default.createElement("th", {
|
|
151
199
|
key: cell.id,
|
|
200
|
+
role: "rowheader",
|
|
152
201
|
scope: "row",
|
|
153
202
|
tabIndex: tabIndex(tableRow, colIndex),
|
|
154
203
|
"data-row": tableRow,
|
|
155
204
|
"data-col": colIndex,
|
|
205
|
+
"aria-colindex": 1,
|
|
156
206
|
onFocus: function onFocus() {
|
|
157
207
|
return onCellFocus(tableRow, colIndex);
|
|
158
208
|
},
|
|
159
209
|
className: "row-header"
|
|
160
210
|
}, content) : /*#__PURE__*/_react.default.createElement("td", {
|
|
161
211
|
key: cell.id,
|
|
212
|
+
role: "gridcell",
|
|
162
213
|
tabIndex: tabIndex(tableRow, colIndex),
|
|
163
214
|
"data-row": tableRow,
|
|
164
215
|
"data-col": colIndex,
|
|
216
|
+
"aria-colindex": colIndex + 1,
|
|
165
217
|
onFocus: function onFocus() {
|
|
166
218
|
return onCellFocus(tableRow, colIndex);
|
|
167
219
|
}
|