@urbanos/react-discovery-ui 2.1.48 → 2.1.49
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,37 +80,64 @@ 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
|
});
|
|
@@ -118,8 +151,7 @@ var DataTable = function DataTable(_ref) {
|
|
|
118
151
|
ref: tableRef,
|
|
119
152
|
style: {
|
|
120
153
|
minWidth: "".concat(columns.length * 120, "px")
|
|
121
|
-
}
|
|
122
|
-
onKeyDown: handleKeyDown
|
|
154
|
+
}
|
|
123
155
|
}, /*#__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
156
|
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
125
157
|
key: headerGroup.id
|