@neo4j-ndl/react 3.2.12 → 3.2.14
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/lib/cjs/banner/Banner.js +1 -1
- package/lib/cjs/banner/Banner.js.map +1 -1
- package/lib/cjs/data-grid/Components.js +48 -63
- package/lib/cjs/data-grid/Components.js.map +1 -1
- package/lib/cjs/data-grid/DataGrid.js +11 -12
- package/lib/cjs/data-grid/DataGrid.js.map +1 -1
- package/lib/cjs/data-grid/DataGridContext.js.map +1 -1
- package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js +510 -0
- package/lib/cjs/data-grid/data-grid-nav/data-grid-nav.js.map +1 -0
- package/lib/cjs/data-grid/data-grid-nav/helpers.js +49 -0
- package/lib/cjs/data-grid/data-grid-nav/helpers.js.map +1 -0
- package/lib/cjs/data-grid/data-grid-nav/index.js +77 -0
- package/lib/cjs/data-grid/data-grid-nav/index.js.map +1 -0
- package/lib/cjs/data-grid/data-grid-nav/keys.js +42 -0
- package/lib/cjs/data-grid/data-grid-nav/keys.js.map +1 -0
- package/lib/cjs/data-grid/data-grid-nav/selectors.js +31 -0
- package/lib/cjs/data-grid/data-grid-nav/selectors.js.map +1 -0
- package/lib/cjs/data-grid/helpers.js +47 -1
- package/lib/cjs/data-grid/helpers.js.map +1 -1
- package/lib/cjs/data-grid/index.js +7 -1
- package/lib/cjs/data-grid/index.js.map +1 -1
- package/lib/cjs/modal/Modal.js +13 -7
- package/lib/cjs/modal/Modal.js.map +1 -1
- package/lib/esm/banner/Banner.js +1 -1
- package/lib/esm/banner/Banner.js.map +1 -1
- package/lib/esm/data-grid/Components.js +49 -64
- package/lib/esm/data-grid/Components.js.map +1 -1
- package/lib/esm/data-grid/DataGrid.js +5 -6
- package/lib/esm/data-grid/DataGrid.js.map +1 -1
- package/lib/esm/data-grid/DataGridContext.js.map +1 -1
- package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js +506 -0
- package/lib/esm/data-grid/data-grid-nav/data-grid-nav.js.map +1 -0
- package/lib/esm/data-grid/data-grid-nav/helpers.js +45 -0
- package/lib/esm/data-grid/data-grid-nav/helpers.js.map +1 -0
- package/lib/esm/data-grid/data-grid-nav/index.js +74 -0
- package/lib/esm/data-grid/data-grid-nav/index.js.map +1 -0
- package/lib/esm/data-grid/data-grid-nav/keys.js +39 -0
- package/lib/esm/data-grid/data-grid-nav/keys.js.map +1 -0
- package/lib/esm/data-grid/data-grid-nav/selectors.js +28 -0
- package/lib/esm/data-grid/data-grid-nav/selectors.js.map +1 -0
- package/lib/esm/data-grid/helpers.js +45 -0
- package/lib/esm/data-grid/helpers.js.map +1 -1
- package/lib/esm/data-grid/index.js +2 -0
- package/lib/esm/data-grid/index.js.map +1 -1
- package/lib/esm/modal/Modal.js +13 -7
- package/lib/esm/modal/Modal.js.map +1 -1
- package/lib/types/data-grid/Components.d.ts +8 -5
- package/lib/types/data-grid/DataGrid.d.ts +2 -4
- package/lib/types/data-grid/DataGridContext.d.ts +2 -0
- package/lib/types/data-grid/data-grid-nav/data-grid-nav.d.ts +94 -0
- package/lib/types/data-grid/data-grid-nav/helpers.d.ts +26 -0
- package/lib/types/data-grid/data-grid-nav/index.d.ts +29 -0
- package/lib/types/data-grid/data-grid-nav/keys.d.ts +37 -0
- package/lib/types/data-grid/data-grid-nav/selectors.d.ts +27 -0
- package/lib/types/data-grid/helpers.d.ts +11 -1
- package/lib/types/data-grid/index.d.ts +2 -0
- package/package.json +2 -4
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridNav = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
const helpers_1 = require("./helpers");
|
|
25
|
+
const keys_1 = require("./keys");
|
|
26
|
+
const selectors_1 = require("./selectors");
|
|
27
|
+
class DataGridNav {
|
|
28
|
+
constructor(config = {}) {
|
|
29
|
+
this.keys = [];
|
|
30
|
+
this.debugLog = (functionName, message) => {
|
|
31
|
+
if (this.debug)
|
|
32
|
+
console.info(`[${functionName}]: ${message}`);
|
|
33
|
+
};
|
|
34
|
+
const { selectors = {}, pageUpDown, isDebug = false } = config;
|
|
35
|
+
this.selectors = Object.assign(Object.assign({}, selectors_1.Selectors), selectors);
|
|
36
|
+
this.pageUpDown = pageUpDown;
|
|
37
|
+
this.keys = [];
|
|
38
|
+
this.debug = isDebug;
|
|
39
|
+
this.disabled = false;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Disables the keyboard listener in cases
|
|
43
|
+
* that elements inside the grid need to use
|
|
44
|
+
* arrows keys etc., like select dropdowns
|
|
45
|
+
*/
|
|
46
|
+
disable() {
|
|
47
|
+
this.disabled = true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enables the keyboard listeners
|
|
51
|
+
*/
|
|
52
|
+
enable() {
|
|
53
|
+
this.disabled = false;
|
|
54
|
+
}
|
|
55
|
+
isFocusable(el) {
|
|
56
|
+
return el instanceof HTMLElement || el instanceof SVGElement;
|
|
57
|
+
}
|
|
58
|
+
focusParentCell(el) {
|
|
59
|
+
const cell = el.closest(this.selectors.Cell);
|
|
60
|
+
if (cell && this.isFocusable(cell)) {
|
|
61
|
+
cell.focus();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Used as a keyboard listener for key up */
|
|
65
|
+
tableKeyUp() {
|
|
66
|
+
// TODO: have a cleanup as user can press key
|
|
67
|
+
// and then move to another tab, and get back to the same tab
|
|
68
|
+
// so this will not be empty (the bug exists with .pop)
|
|
69
|
+
this.keys = [];
|
|
70
|
+
}
|
|
71
|
+
/** Used as a keyboard listener for key down */
|
|
72
|
+
tableKeyDown(e) {
|
|
73
|
+
var _a;
|
|
74
|
+
this.debugLog('tableKeyDown', `Key pressed: ${e.key}`);
|
|
75
|
+
if (this.disabled) {
|
|
76
|
+
this.debugLog('tableKeyDown', 'interaction is disabled');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Avoid page scrolling etc.
|
|
81
|
+
* Enable default behavior for:
|
|
82
|
+
* Tab, Shift + Tab
|
|
83
|
+
* TODO: Actually it will be better to just prevent
|
|
84
|
+
* in ArrowKeys and PageKeys maybe?
|
|
85
|
+
* Or should the consumer stop propagation?!
|
|
86
|
+
* Cannot work with preventDefault as it will
|
|
87
|
+
* first capture the event from an input in cell for example
|
|
88
|
+
*/
|
|
89
|
+
if (keys_1.Keys.ArrowDown === e.key ||
|
|
90
|
+
keys_1.Keys.ArrowUp === e.key ||
|
|
91
|
+
keys_1.Keys.ArrowLeft === e.key ||
|
|
92
|
+
keys_1.Keys.ArrowRight === e.key) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Add key to the stack if it's
|
|
97
|
+
* not the same with the last (long press)
|
|
98
|
+
*/
|
|
99
|
+
if (this.keys.length === 0 || this.keys[this.keys.length - 1] !== e.key) {
|
|
100
|
+
this.keys.push(e.key);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Need to check if we are inside a grid cell
|
|
104
|
+
* or not to enable/disable Grid Navigation
|
|
105
|
+
*/
|
|
106
|
+
if (!(e.target instanceof Element))
|
|
107
|
+
return;
|
|
108
|
+
const cell = (_a = e.target.parentElement) === null || _a === void 0 ? void 0 : _a.closest(`${this.selectors.Cell},${this.selectors.Row}`);
|
|
109
|
+
if (!cell) {
|
|
110
|
+
this.debugLog('tableKeyDown', 'cell not found');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (cell.matches(this.selectors.Cell)) {
|
|
114
|
+
this.debugLog('tableKeyDown', 'event captured in cell');
|
|
115
|
+
this.cellNavigation(e);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.debugLog('tableKeyDown', 'event captured in grid');
|
|
119
|
+
this.gridNavigation(e);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Handles the navigation inside a cell
|
|
124
|
+
*/
|
|
125
|
+
cellNavigation(e) {
|
|
126
|
+
if (!(e.target instanceof Element))
|
|
127
|
+
return;
|
|
128
|
+
const cell = e.target.closest(this.selectors.Cell);
|
|
129
|
+
if (!cell) {
|
|
130
|
+
this.debugLog('cellNavigation', 'cell not found');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (this.getValidFocusableChild(cell)) {
|
|
134
|
+
this.debugLog('cellNavigation', 'valid focusable child found');
|
|
135
|
+
this.gridNavigation(e);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const focusableWidgets = cell
|
|
139
|
+
? [...cell.querySelectorAll(this.selectors.Focusable)]
|
|
140
|
+
: [];
|
|
141
|
+
const widgetIdx = focusableWidgets.findIndex((el) => el === e.target);
|
|
142
|
+
/**
|
|
143
|
+
* Keys: Escape
|
|
144
|
+
* Restore grid navigation
|
|
145
|
+
*/
|
|
146
|
+
if (e.key === keys_1.Keys.Escape && this.isFocusable(cell)) {
|
|
147
|
+
cell.focus();
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Keys: ArrowRight, ArrowDown
|
|
154
|
+
* Move to the next focusable cell, or the first one
|
|
155
|
+
*
|
|
156
|
+
* Arrow Down disabled:
|
|
157
|
+
* https://github.com/w3c/aria-practices/issues/2739#issuecomment-1613538972
|
|
158
|
+
*/
|
|
159
|
+
if (e.key === keys_1.Keys.ArrowRight || e.key === keys_1.Keys.ArrowDown) {
|
|
160
|
+
const nextFocusable = widgetIdx === focusableWidgets.length - 1 ? 0 : widgetIdx + 1;
|
|
161
|
+
const widgetToFocus = focusableWidgets[nextFocusable];
|
|
162
|
+
if (this.isFocusable(widgetToFocus)) {
|
|
163
|
+
widgetToFocus.focus();
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Keys: ArrowLeft, ArrowUp
|
|
169
|
+
* Move to the previous focusable cell, or the last one
|
|
170
|
+
*
|
|
171
|
+
* Arrow Up disabled:
|
|
172
|
+
* https://github.com/w3c/aria-practices/issues/2739#issuecomment-1613538972
|
|
173
|
+
*/
|
|
174
|
+
if (e.key === keys_1.Keys.ArrowLeft || e.key === keys_1.Keys.ArrowUp) {
|
|
175
|
+
const previousFocusable = widgetIdx === 0 ? focusableWidgets.length - 1 : widgetIdx - 1;
|
|
176
|
+
const widgetToFocus = focusableWidgets[previousFocusable];
|
|
177
|
+
if (this.isFocusable(widgetToFocus)) {
|
|
178
|
+
widgetToFocus.focus();
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the valid focusable child of a cell
|
|
185
|
+
* @return {FocusableElement | null} - The valid focusable child, or null if there are none or multiple focusable children
|
|
186
|
+
*/
|
|
187
|
+
getValidFocusableChild(el) {
|
|
188
|
+
const focusableChildren = [
|
|
189
|
+
...el.querySelectorAll(this.selectors.Focusable),
|
|
190
|
+
];
|
|
191
|
+
if (focusableChildren.length === 1 &&
|
|
192
|
+
(0, helpers_1.isValidInteractiveElement)(focusableChildren[0]) &&
|
|
193
|
+
this.isFocusable(focusableChildren[0])) {
|
|
194
|
+
return focusableChildren[0];
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Handles the navigation outside a cell
|
|
200
|
+
* on the grid level
|
|
201
|
+
*/
|
|
202
|
+
gridNavigation(e) {
|
|
203
|
+
var _a;
|
|
204
|
+
if (!(e.target instanceof Element))
|
|
205
|
+
return;
|
|
206
|
+
if (this.keys.length === 1) {
|
|
207
|
+
/**
|
|
208
|
+
* Keys: Enter
|
|
209
|
+
* Should move focus inside the cell to the first focusable element:
|
|
210
|
+
* https://www.w3.org/WAI/ARIA/apg/patterns/grid/#gridNav_inside
|
|
211
|
+
*/
|
|
212
|
+
if (e.key === keys_1.Keys.Enter) {
|
|
213
|
+
const cell = e.target.querySelector(this.selectors.Focusable);
|
|
214
|
+
if (cell && this.isFocusable(cell)) {
|
|
215
|
+
// Enter can trigger child elements:
|
|
216
|
+
// Source: https://www.reddit.com/r/learnjavascript/comments/14kpj24/wrong_keydown_listener_is_called_with_focus/
|
|
217
|
+
// If the e.preventDefault causes issues, we can offset the execution with setTimeout
|
|
218
|
+
cell.focus();
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Keys: ArrowLeft, ArrowRight
|
|
224
|
+
* Should move focus to the next/previous cell
|
|
225
|
+
*/
|
|
226
|
+
if (e.key === keys_1.Keys.ArrowLeft || e.key === keys_1.Keys.ArrowRight) {
|
|
227
|
+
const direction = e.key === keys_1.Keys.ArrowLeft ? 'prev' : 'next';
|
|
228
|
+
// Get the closest cell we are currently in
|
|
229
|
+
const cell = e.target.closest(this.selectors.Cell);
|
|
230
|
+
if (cell && cell instanceof Element) {
|
|
231
|
+
const closeFocusable = this.findUntil(direction, cell, this.selectors.Cell);
|
|
232
|
+
if (closeFocusable) {
|
|
233
|
+
const focusableChild = this.getValidFocusableChild(closeFocusable);
|
|
234
|
+
const toFocus = focusableChild !== null && focusableChild !== void 0 ? focusableChild : closeFocusable;
|
|
235
|
+
toFocus.focus();
|
|
236
|
+
toFocus.scrollIntoView({
|
|
237
|
+
block: 'nearest',
|
|
238
|
+
inline: 'nearest',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Keys: Up,Down
|
|
245
|
+
* Should move focus to the same column of the next/previous row
|
|
246
|
+
*/
|
|
247
|
+
if (e.key === keys_1.Keys.ArrowDown || e.key === keys_1.Keys.ArrowUp) {
|
|
248
|
+
this.verticalCellNavigation(e);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Keys: PageUp, PageDown
|
|
253
|
+
* Should move focus to the first/last row
|
|
254
|
+
* or a predefined number of rows if user provides a value
|
|
255
|
+
*/
|
|
256
|
+
if (e.key === keys_1.Keys.PageUp || e.key === keys_1.Keys.PageDown) {
|
|
257
|
+
this.pageCellNavigation(e);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Keys: Home, End
|
|
262
|
+
* Should move focus to the first/last cell of the current row
|
|
263
|
+
*/
|
|
264
|
+
if (e.key === keys_1.Keys.Home || e.key === keys_1.Keys.End) {
|
|
265
|
+
const row = e.target.closest(this.selectors.Row);
|
|
266
|
+
const rowChildren = [...((row === null || row === void 0 ? void 0 : row.children) || [])];
|
|
267
|
+
if (e.key === 'End')
|
|
268
|
+
rowChildren.reverse();
|
|
269
|
+
this.focusOnFirstCell(rowChildren);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
/**
|
|
274
|
+
* Keys: Control + Home, Control + End
|
|
275
|
+
* Should move focus to the first/last cell of the first/last row
|
|
276
|
+
*/
|
|
277
|
+
const [firstKey, secondKey] = this.keys;
|
|
278
|
+
if (firstKey === 'Control' &&
|
|
279
|
+
(secondKey === keys_1.Keys.Home || secondKey === keys_1.Keys.End)) {
|
|
280
|
+
const row = e.target.closest(this.selectors.Row);
|
|
281
|
+
const siblings = (_a = row.parentElement) === null || _a === void 0 ? void 0 : _a.children;
|
|
282
|
+
if (!siblings) {
|
|
283
|
+
this.debugLog('cellNavigation', 'siblings not found');
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const rowToFocus = secondKey === keys_1.Keys.Home ? siblings[0] : siblings[siblings.length - 1];
|
|
287
|
+
const rowChildren = [...((rowToFocus === null || rowToFocus === void 0 ? void 0 : rowToFocus.children) || [])];
|
|
288
|
+
if (secondKey === keys_1.Keys.End)
|
|
289
|
+
rowChildren.reverse();
|
|
290
|
+
this.focusOnFirstCell(rowChildren);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
pageCellNavigation(e) {
|
|
295
|
+
var _a;
|
|
296
|
+
if (!(e.target instanceof Element))
|
|
297
|
+
return;
|
|
298
|
+
const row = e.target.closest(this.selectors.Row);
|
|
299
|
+
const cell = e.target.closest(this.selectors.Cell);
|
|
300
|
+
if (row && cell) {
|
|
301
|
+
const position = this.getColumnIndex(cell);
|
|
302
|
+
if (position === undefined) {
|
|
303
|
+
this.debugLog('cellNavigation', 'position not found');
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const direction = e.key === keys_1.Keys.PageUp ? 'prev' : 'next';
|
|
307
|
+
const siblings = (_a = row.parentElement) === null || _a === void 0 ? void 0 : _a.children;
|
|
308
|
+
if (!siblings) {
|
|
309
|
+
this.debugLog('cellNavigation', 'siblings not found');
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
// If pageUpDown is defined, we should move that number of rows, or to the closest possible
|
|
313
|
+
let destinationRow;
|
|
314
|
+
if (this.pageUpDown) {
|
|
315
|
+
const methodClbk = direction === 'prev' ? 'previousSibling' : 'nextSibling';
|
|
316
|
+
let sibling = row[methodClbk];
|
|
317
|
+
if (sibling === null)
|
|
318
|
+
return;
|
|
319
|
+
let lastVisitedSibling = sibling;
|
|
320
|
+
for (let i = 0; i < this.pageUpDown - 1 && sibling; i++) {
|
|
321
|
+
sibling = sibling[methodClbk];
|
|
322
|
+
if (sibling) {
|
|
323
|
+
lastVisitedSibling = sibling;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
destinationRow = sibling ? sibling : lastVisitedSibling;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
destinationRow =
|
|
330
|
+
direction === 'prev' ? siblings[0] : siblings[siblings.length - 1];
|
|
331
|
+
}
|
|
332
|
+
if (!destinationRow || !(destinationRow instanceof Element))
|
|
333
|
+
return;
|
|
334
|
+
const child = destinationRow.children[position];
|
|
335
|
+
if (child && this.isFocusable(child)) {
|
|
336
|
+
const focusableGrandChild = this.getValidFocusableChild(child);
|
|
337
|
+
if (focusableGrandChild) {
|
|
338
|
+
focusableGrandChild.focus();
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
child.focus();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
verticalCellNavigation(e) {
|
|
347
|
+
var _a, _b, _c, _d, _e;
|
|
348
|
+
if (!(e.target instanceof Element))
|
|
349
|
+
return;
|
|
350
|
+
const row = e.target.closest(this.selectors.Row);
|
|
351
|
+
const cell = e.target.closest(this.selectors.Cell);
|
|
352
|
+
if (row && cell) {
|
|
353
|
+
const cellPosition = this.getColumnIndex(cell);
|
|
354
|
+
const rowPosition = this.getRowIndex(row);
|
|
355
|
+
this.debugLog('gridNavigation', `Initial row position: ${rowPosition}`);
|
|
356
|
+
this.debugLog('gridNavigation', `Initial cell position: ${cellPosition}`);
|
|
357
|
+
if (cellPosition === undefined || rowPosition === undefined) {
|
|
358
|
+
this.debugLog('verticalCellNavigation', 'row or cell position not found');
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const direction = e.key === keys_1.Keys.ArrowUp ? 'prev' : 'next';
|
|
362
|
+
/** Find previous rowgroup and focus on the proper cell */
|
|
363
|
+
if (rowPosition === 0 && direction === 'prev') {
|
|
364
|
+
const currentRowGroup = (_a = row.parentElement) === null || _a === void 0 ? void 0 : _a.closest(this.selectors.RowGroup);
|
|
365
|
+
const siblingRowGroups = [
|
|
366
|
+
...(((_b = currentRowGroup === null || currentRowGroup === void 0 ? void 0 : currentRowGroup.parentElement) === null || _b === void 0 ? void 0 : _b.children) || []),
|
|
367
|
+
];
|
|
368
|
+
const currentRowGroupIdx = siblingRowGroups.findIndex((el) => el === currentRowGroup);
|
|
369
|
+
if (currentRowGroupIdx !== 0) {
|
|
370
|
+
const previousRowGroup = siblingRowGroups[currentRowGroupIdx - 1];
|
|
371
|
+
const rows = [
|
|
372
|
+
...previousRowGroup.querySelectorAll(this.selectors.Row),
|
|
373
|
+
];
|
|
374
|
+
const child = rows[rows.length - 1].children[cellPosition];
|
|
375
|
+
if (child && this.isFocusable(child)) {
|
|
376
|
+
const focusableGrandChild = this.getValidFocusableChild(child);
|
|
377
|
+
if (focusableGrandChild) {
|
|
378
|
+
focusableGrandChild.focus();
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
child.focus();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const siblingRows = [
|
|
388
|
+
...(((_c = row.parentElement) === null || _c === void 0 ? void 0 : _c.querySelectorAll(this.selectors.Row)) || []),
|
|
389
|
+
];
|
|
390
|
+
/** Find next rowgroup and focus on the proper cell */
|
|
391
|
+
if (rowPosition === siblingRows.length - 1 && direction === 'next') {
|
|
392
|
+
const currentRowGroup = (_d = row.parentElement) === null || _d === void 0 ? void 0 : _d.closest(this.selectors.RowGroup);
|
|
393
|
+
const siblingRowGroups = [
|
|
394
|
+
...(((_e = currentRowGroup === null || currentRowGroup === void 0 ? void 0 : currentRowGroup.parentElement) === null || _e === void 0 ? void 0 : _e.children) || []),
|
|
395
|
+
];
|
|
396
|
+
const currentRowGroupIdx = siblingRowGroups.findIndex((el) => el === currentRowGroup);
|
|
397
|
+
if (currentRowGroupIdx !== siblingRowGroups.length - 1) {
|
|
398
|
+
const nextRowGroup = siblingRowGroups[currentRowGroupIdx + 1];
|
|
399
|
+
const rows = [...nextRowGroup.querySelectorAll(this.selectors.Row)];
|
|
400
|
+
const child = rows[0].children[cellPosition];
|
|
401
|
+
if (child && this.isFocusable(child)) {
|
|
402
|
+
const focusableGrandChild = this.getValidFocusableChild(child);
|
|
403
|
+
if (focusableGrandChild) {
|
|
404
|
+
focusableGrandChild.focus();
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
child.focus();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
/** Navigation in the same rowgroup */
|
|
415
|
+
const destinationRow = this.findUntil(direction, row, this.selectors.Row);
|
|
416
|
+
if (!destinationRow)
|
|
417
|
+
return;
|
|
418
|
+
const child = destinationRow.children[cellPosition];
|
|
419
|
+
if (child && this.isFocusable(child)) {
|
|
420
|
+
const focusableGrandChild = this.getValidFocusableChild(child);
|
|
421
|
+
if (focusableGrandChild) {
|
|
422
|
+
focusableGrandChild.focus();
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
child.focus();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Sending a row `Element` and then the first cell will be focused.
|
|
432
|
+
*
|
|
433
|
+
* If you want to focus the last cell then the row children can be passed in
|
|
434
|
+
* reversed order
|
|
435
|
+
*/
|
|
436
|
+
focusOnFirstCell(el) {
|
|
437
|
+
for (let i = 0; i < el.length; i++) {
|
|
438
|
+
const child = el[i];
|
|
439
|
+
if (this.isFocusable(child)) {
|
|
440
|
+
child.focus();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Get the column index of a `cell` based on the first `row` parent.
|
|
447
|
+
* `cellIndex` could be used, but it's not supported in HTML tables.
|
|
448
|
+
*/
|
|
449
|
+
getColumnIndex(cell) {
|
|
450
|
+
var _a;
|
|
451
|
+
let position = 0;
|
|
452
|
+
const siblings = (_a = cell === null || cell === void 0 ? void 0 : cell.parentNode) === null || _a === void 0 ? void 0 : _a.children;
|
|
453
|
+
if (!siblings)
|
|
454
|
+
return undefined;
|
|
455
|
+
while (cell !== siblings[position] && siblings[position] !== undefined) {
|
|
456
|
+
position++;
|
|
457
|
+
}
|
|
458
|
+
// Cell position find was not possible, maybe should log here
|
|
459
|
+
if (siblings[position] === undefined) {
|
|
460
|
+
this.debugLog('getColumnIndex', 'position finding was not successful');
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
463
|
+
return position;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Get the row index of a `row` based
|
|
467
|
+
* on its sibling rows
|
|
468
|
+
*/
|
|
469
|
+
getRowIndex(row) {
|
|
470
|
+
var _a;
|
|
471
|
+
let position = 0;
|
|
472
|
+
const siblings = (_a = row === null || row === void 0 ? void 0 : row.parentNode) === null || _a === void 0 ? void 0 : _a.children;
|
|
473
|
+
if (!siblings)
|
|
474
|
+
return undefined;
|
|
475
|
+
while (row !== siblings[position] && siblings[position] !== undefined) {
|
|
476
|
+
position++;
|
|
477
|
+
}
|
|
478
|
+
// Cell position find was not possible
|
|
479
|
+
if (siblings[position] === undefined) {
|
|
480
|
+
this.debugLog('getRowIndex', 'position finding was not successful');
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
return position;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Equivalent to prevUntil/nextUntil in jQuery
|
|
487
|
+
* https://api.jquery.com/prevUntil/
|
|
488
|
+
*/
|
|
489
|
+
findUntil(direction, el, matchSelector, exitSelector) {
|
|
490
|
+
let element = el;
|
|
491
|
+
const method = direction === 'next' ? 'nextSibling' : 'previousSibling';
|
|
492
|
+
while (element[method]) {
|
|
493
|
+
const sibling = element[method];
|
|
494
|
+
if (!sibling)
|
|
495
|
+
return null;
|
|
496
|
+
if (exitSelector &&
|
|
497
|
+
sibling instanceof Element &&
|
|
498
|
+
sibling.matches(exitSelector)) {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
if (sibling instanceof Element && sibling.matches(matchSelector)) {
|
|
502
|
+
return sibling;
|
|
503
|
+
}
|
|
504
|
+
element = sibling;
|
|
505
|
+
}
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
exports.DataGridNav = DataGridNav;
|
|
510
|
+
//# sourceMappingURL=data-grid-nav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-grid-nav.js","sourceRoot":"","sources":["../../../../src/data-grid/data-grid-nav/data-grid-nav.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uCAAsD;AACtD,iCAA8B;AAC9B,2CAAwC;AAexC,MAAa,WAAW;IAStB,YAAY,SAAiB,EAAE;QANvB,SAAI,GAAa,EAAE,CAAC;QAepB,aAAQ,GAAG,CAAC,YAAoB,EAAE,OAAe,EAAE,EAAE;YAC3D,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,YAAY,MAAM,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC;QAVA,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC/D,IAAI,CAAC,SAAS,mCAAQ,qBAAS,GAAK,SAAS,CAAE,CAAC;QAChD,IAAI,CAAC,UAA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QAExE,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAC1B,IACE,YAAY;gBACZ,OAAO,YAAY,OAAO;gBAC1B,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAC7B,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,OAAO,YAAY,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACjE,OAAO,OAA2B,CAAC;YACrC,CAAC;YAED,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAziBD,kCAyiBC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.isValidInteractiveElement = void 0;
|
|
24
|
+
/**
|
|
25
|
+
* This function checks that an element is interactive and of a type that doesn't disrupt grid navigation.
|
|
26
|
+
* @param element the element to check
|
|
27
|
+
* @returns true if the element is an interactive element that doesn't disrupt grid navigation
|
|
28
|
+
*/
|
|
29
|
+
const isValidInteractiveElement = (element) => {
|
|
30
|
+
if (!(element instanceof HTMLElement))
|
|
31
|
+
return false;
|
|
32
|
+
const interactiveTags = new Set(['A', 'BUTTON', 'DETAILS']);
|
|
33
|
+
const interactiveInputTypes = new Set([
|
|
34
|
+
'checkbox',
|
|
35
|
+
'radio',
|
|
36
|
+
'submit',
|
|
37
|
+
'reset',
|
|
38
|
+
]);
|
|
39
|
+
if (interactiveTags.has(element.tagName)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (element.tagName === 'INPUT') {
|
|
43
|
+
const inputType = element.type;
|
|
44
|
+
return interactiveInputTypes.has(inputType);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
exports.isValidInteractiveElement = isValidInteractiveElement;
|
|
49
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/data-grid/data-grid-nav/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CAAC,OAAgB,EAAW,EAAE;IACrE,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAC5D,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;QACpC,UAAU;QACV,OAAO;QACP,QAAQ;QACR,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,SAAS,GAAI,OAA4B,CAAC,IAAI,CAAC;QACrD,OAAO,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AArBW,QAAA,yBAAyB,6BAqBpC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTableNav = useTableNav;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
const react_1 = require("react");
|
|
25
|
+
const data_grid_nav_1 = require("./data-grid-nav");
|
|
26
|
+
function useTableNav(options) {
|
|
27
|
+
// Store the actual class instance in a ref so we only create it once
|
|
28
|
+
const instanceRef = (0, react_1.useRef)(null);
|
|
29
|
+
if (instanceRef.current === null) {
|
|
30
|
+
instanceRef.current = new data_grid_nav_1.DataGridNav(options);
|
|
31
|
+
}
|
|
32
|
+
// A piece of state to force a re-render when you want to react to instance changes
|
|
33
|
+
const [, setVersion] = (0, react_1.useState)(0);
|
|
34
|
+
const forceUpdate = (0, react_1.useCallback)(() => setVersion((v) => v + 1), []);
|
|
35
|
+
// Wrap the instance in a proxy that intercepts reads/writes
|
|
36
|
+
const proxiedInstance = (0, react_1.useMemo)(() => {
|
|
37
|
+
const handler = {
|
|
38
|
+
get(target, prop, receiver) {
|
|
39
|
+
const value = Reflect.get(target, prop, receiver);
|
|
40
|
+
// If it's a function (a class method), we can intercept calls:
|
|
41
|
+
if (typeof value === 'function') {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
return (...args) => {
|
|
44
|
+
// Call the original method
|
|
45
|
+
const result = value.apply(target, args);
|
|
46
|
+
// Example: force re-render if the method is known to change internal state
|
|
47
|
+
// or if you want to force re-render after *every* method call, remove the condition
|
|
48
|
+
if (['enable', 'disable'].includes(String(prop))) {
|
|
49
|
+
forceUpdate();
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Otherwise, it's a property. Just return it.
|
|
55
|
+
return value;
|
|
56
|
+
},
|
|
57
|
+
// Trap for property assignments, so React can re-render on changes
|
|
58
|
+
set(target, prop, newValue, receiver) {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
60
|
+
const result = Reflect.set(target, prop, newValue, receiver);
|
|
61
|
+
// Force re-render after setting *any* property
|
|
62
|
+
forceUpdate();
|
|
63
|
+
return result;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
return new Proxy(instanceRef.current, handler);
|
|
67
|
+
// We only want to create a new Proxy if the instanceRef or forceUpdate changes
|
|
68
|
+
}, [forceUpdate]);
|
|
69
|
+
return {
|
|
70
|
+
listeners: {
|
|
71
|
+
onKeyDown: (e) => proxiedInstance.tableKeyDown(e.nativeEvent),
|
|
72
|
+
onKeyUp: () => proxiedInstance.tableKeyUp(),
|
|
73
|
+
},
|
|
74
|
+
tableNav: proxiedInstance,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/data-grid-nav/index.tsx"],"names":[],"mappings":";;AAuBA,kCA2DC;AAlFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iCAAsE;AACtE,mDAAsD;AAEtD,SAAgB,WAAW,CAAC,OAAgB;IAC1C,qEAAqE;IACrE,MAAM,WAAW,GAAG,IAAA,cAAM,EAAqB,IAAI,CAAC,CAAC;IACrD,IAAI,WAAW,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACjC,WAAW,CAAC,OAAO,GAAG,IAAI,2BAAW,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,mFAAmF;IACnF,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpE,4DAA4D;IAC5D,MAAM,eAAe,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACnC,MAAM,OAAO,GAA8B;YACzC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;gBACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAElD,+DAA+D;gBAC/D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;oBAChC,8DAA8D;oBAC9D,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;wBACxB,2BAA2B;wBAC3B,MAAM,MAAM,GAAG,KAAK,CAAC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