@1771technologies/lytenyte-pro 1.0.12 → 1.0.13

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.
Files changed (57) hide show
  1. package/dist/+types.d.ts +21 -2
  2. package/dist/__play__/grid-navigation/cell-spans-large.play.d.ts +3 -0
  3. package/dist/__play__/grid-navigation/cell-spans-large.play.js +26 -0
  4. package/dist/__play__/grid-navigation/cell-spans-with-pins.play.d.ts +3 -0
  5. package/dist/__play__/grid-navigation/cell-spans-with-pins.play.js +27 -0
  6. package/dist/__play__/grid-navigation/cell-spans.play.d.ts +3 -0
  7. package/dist/__play__/grid-navigation/cell-spans.play.js +52 -0
  8. package/dist/__play__/grid-navigation/cell-with-tabbables.play.d.ts +3 -0
  9. package/dist/__play__/grid-navigation/cell-with-tabbables.play.js +47 -0
  10. package/dist/__play__/grid-navigation/column-groups.play.d.ts +3 -0
  11. package/dist/__play__/grid-navigation/column-groups.play.js +24 -0
  12. package/dist/__play__/grid-navigation/full-width-rows.play.d.ts +6 -0
  13. package/dist/__play__/grid-navigation/full-width-rows.play.js +67 -0
  14. package/dist/__play__/grid-navigation/horizontal-navigation.pt.d.ts +1 -0
  15. package/dist/__play__/grid-navigation/horizontal-navigation.pt.js +877 -0
  16. package/dist/__play__/grid-navigation/normal-layout.play.d.ts +10 -0
  17. package/dist/__play__/grid-navigation/normal-layout.play.js +72 -0
  18. package/dist/__play__/grid-navigation/pinned-gap-layout.play.d.ts +3 -0
  19. package/dist/__play__/grid-navigation/pinned-gap-layout.play.js +11 -0
  20. package/dist/__play__/grid-navigation/row-detail-with-spans.play.d.ts +6 -0
  21. package/dist/__play__/grid-navigation/row-detail-with-spans.play.js +79 -0
  22. package/dist/__play__/grid-navigation/row-detail.play.d.ts +6 -0
  23. package/dist/__play__/grid-navigation/row-detail.play.js +78 -0
  24. package/dist/__play__/grid-navigation/row-detail.pt.d.ts +1 -0
  25. package/dist/__play__/grid-navigation/row-detail.pt.js +68 -0
  26. package/dist/__play__/grid-navigation/vertical-navigation.pt.d.ts +1 -0
  27. package/dist/__play__/grid-navigation/vertical-navigation.pt.js +176 -0
  28. package/dist/__play__/test-utils/bank-data-smaller.d.ts +19 -0
  29. package/dist/__play__/test-utils/bank-data-smaller.js +252 -0
  30. package/dist/__play__/test-utils/row-handler.d.ts +6 -0
  31. package/dist/__play__/test-utils/row-handler.js +33 -0
  32. package/dist/cells/+types.cell.d.ts +1 -1
  33. package/dist/cells/cell-default.d.ts +1 -1
  34. package/dist/cells/cell-editor.js +19 -12
  35. package/dist/cells/cell-spacer.js +9 -4
  36. package/dist/cells/cell.js +4 -3
  37. package/dist/context.d.ts +3 -3
  38. package/dist/header/use-header-cell-renderer.js +1 -0
  39. package/dist/icons/index.js +1 -3
  40. package/dist/root/root.js +39 -56
  41. package/dist/rows/row/context.d.ts +2 -1
  42. package/dist/rows/row/context.js +1 -0
  43. package/dist/rows/row/row.d.ts +1 -1
  44. package/dist/rows/row/row.js +1 -1
  45. package/dist/rows/row/use-row-context-value.d.ts +2 -2
  46. package/dist/rows/row/use-row-context-value.js +3 -2
  47. package/dist/rows/row-detail-row.js +4 -87
  48. package/dist/rows/row-full-width.js +1 -1
  49. package/dist/state/api/cell-root.js +4 -3
  50. package/dist/state/api/focus-cell.d.ts +1 -1
  51. package/dist/state/api/focus-cell.js +19 -12
  52. package/dist/state/helpers/column-marker.js +2 -0
  53. package/dist/state/helpers/get-span-callback.js +1 -1
  54. package/dist/state/helpers/row-layout/row-layout.js +8 -28
  55. package/dist/state/use-lytenyte.js +3 -1
  56. package/dist/viewport/viewport.js +22 -15
  57. package/package.json +7 -7
@@ -0,0 +1,877 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { expect, test } from "vitest";
3
+ import { render } from "vitest-browser-react";
4
+ import NormalLayout from "./normal-layout.play.js";
5
+ import PinGapped from "./pinned-gap-layout.play.js";
6
+ import { userEvent } from "@vitest/browser/context";
7
+ import { getCellQuery } from "@1771technologies/lytenyte-shared";
8
+ import { wait } from "@1771technologies/lytenyte-js-utils";
9
+ import CellSpans from "./cell-spans.play.js";
10
+ import CellWithTabbables from "./cell-with-tabbables.play.js";
11
+ import FullWidthRows from "./full-width-rows.play.js";
12
+ import CellSpansLarge from "./cell-spans-large.play.js";
13
+ import CellSpansWithPins from "./cell-spans-with-pins.play.js";
14
+ import ColumnGroups from "./column-groups.play.js";
15
+ test("when the grid is rendered tabbing through show skip cells inside", async () => {
16
+ const screen = render(_jsx(NormalLayout, {}));
17
+ const start = screen.getByText("Top Capture");
18
+ await expect.element(start).toBeVisible();
19
+ start.element().focus();
20
+ await expect.element(start).toHaveFocus();
21
+ await userEvent.keyboard("{Tab}");
22
+ const grid = screen.getByRole("grid");
23
+ await expect.element(grid).toHaveFocus();
24
+ await userEvent.keyboard("{Tab}");
25
+ await expect.element(screen.getByText("Bottom Capture")).toHaveFocus();
26
+ await userEvent.keyboard("{Shift>}{Tab}{/Shift}");
27
+ await expect.element(grid).toHaveFocus();
28
+ await userEvent.keyboard("{Shift>}{Tab}{/Shift}");
29
+ await expect.element(start).toHaveFocus();
30
+ await userEvent.keyboard("{Tab}");
31
+ await userEvent.keyboard("{Tab}");
32
+ await wait(100);
33
+ await expect.element(screen.getByText("Bottom Capture")).toHaveFocus();
34
+ });
35
+ test("when a cell is focused, we can navigate to the start and end", async () => {
36
+ const screen = render(_jsx(NormalLayout, {}));
37
+ const grid = screen.getByRole("grid");
38
+ await expect.element(grid).toBeVisible();
39
+ await wait(); // Give the grid a moment to render
40
+ const ourFirstCell = document.querySelector(getCellQuery("x", 2, 0));
41
+ ourFirstCell.focus();
42
+ await expect.element(ourFirstCell).toHaveFocus();
43
+ const expected = [
44
+ "35",
45
+ "management",
46
+ "1350",
47
+ "tertiary",
48
+ "single",
49
+ "no",
50
+ "yes",
51
+ "no",
52
+ "cellular",
53
+ "16",
54
+ "apr",
55
+ "185",
56
+ "1",
57
+ "330",
58
+ "1",
59
+ "failure",
60
+ "no",
61
+ ];
62
+ for (const ex of expected) {
63
+ await expect.element(document.activeElement).toHaveTextContent(ex);
64
+ await userEvent.keyboard("{ArrowRight}");
65
+ await wait();
66
+ }
67
+ // Pressing arrow right again should result in a no op
68
+ await userEvent.keyboard("{ArrowRight}");
69
+ await expect.element(document.activeElement).toHaveTextContent(expected.at(-1));
70
+ // Now go in reverse
71
+ for (const ex of expected.toReversed()) {
72
+ await expect.element(document.activeElement).toHaveTextContent(ex);
73
+ await userEvent.keyboard("{ArrowLeft}");
74
+ await wait();
75
+ }
76
+ });
77
+ test("when a cell is focused, we can navigate to the start and end in rtl", async () => {
78
+ const screen = render(_jsx(NormalLayout, { rtl: true }));
79
+ const grid = screen.getByRole("grid");
80
+ await expect.element(grid).toBeVisible();
81
+ await wait(); // Give the grid a moment to render
82
+ const ourFirstCell = document.querySelector(getCellQuery("x", 2, 0));
83
+ await wait(100);
84
+ ourFirstCell.focus();
85
+ await expect.element(ourFirstCell).toHaveFocus();
86
+ const expected = [
87
+ "35",
88
+ "management",
89
+ "1350",
90
+ "tertiary",
91
+ "single",
92
+ "no",
93
+ "yes",
94
+ "no",
95
+ "cellular",
96
+ "16",
97
+ "apr",
98
+ "185",
99
+ "1",
100
+ "330",
101
+ "1",
102
+ "failure",
103
+ "no",
104
+ ];
105
+ for (const ex of expected) {
106
+ await expect.element(document.activeElement).toHaveTextContent(ex);
107
+ await userEvent.keyboard("{ArrowLeft}");
108
+ await wait();
109
+ }
110
+ // Pressing arrow right again should result in a no op
111
+ await userEvent.keyboard("{ArrowLeft}");
112
+ await expect.element(document.activeElement).toHaveTextContent(expected.at(-1));
113
+ // Now go in reverse
114
+ for (const ex of expected.toReversed()) {
115
+ await expect.element(document.activeElement).toHaveTextContent(ex);
116
+ await userEvent.keyboard("{ArrowRight}");
117
+ await wait();
118
+ }
119
+ });
120
+ test("when there columns pinned left and right and there is a gap the navigation should still work", async () => {
121
+ const screen = render(_jsx(PinGapped, { rtl: true }));
122
+ const grid = screen.getByRole("grid");
123
+ await expect.element(grid).toBeVisible();
124
+ await wait(); // Give the grid a moment to render
125
+ const ourFirstCell = document.querySelector(getCellQuery("x", 2, 0));
126
+ ourFirstCell.focus();
127
+ await expect.element(ourFirstCell).toHaveFocus();
128
+ const expected = ["35", "management", "single", "yes"];
129
+ for (const ex of expected) {
130
+ await expect.element(document.activeElement).toHaveTextContent(ex);
131
+ await userEvent.keyboard("{ArrowLeft}");
132
+ await wait();
133
+ }
134
+ // Pressing arrow right again should result in a no op
135
+ await userEvent.keyboard("{ArrowLeft}");
136
+ await expect.element(document.activeElement).toHaveTextContent(expected.at(-1));
137
+ // Now go in reverse
138
+ for (const ex of expected.toReversed()) {
139
+ await expect.element(document.activeElement).toHaveTextContent(ex);
140
+ await userEvent.keyboard("{ArrowRight}");
141
+ await wait();
142
+ }
143
+ });
144
+ test("when there are column spans the grid should be able to navigate across the cells", async () => {
145
+ const screen = render(_jsx(CellSpans, {}));
146
+ const grid = screen.getByRole("grid");
147
+ await expect.element(grid).toBeVisible();
148
+ await wait(); // Give the grid a moment to render
149
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
150
+ await wait();
151
+ let expected = [
152
+ "30",
153
+ "primary",
154
+ "married",
155
+ "no",
156
+ "no",
157
+ "cellular",
158
+ "19",
159
+ "oct",
160
+ "79",
161
+ "1",
162
+ "-1",
163
+ "0",
164
+ "unknown",
165
+ ];
166
+ const verify = async () => {
167
+ for (const ex of expected) {
168
+ await expect.element(document.activeElement).toHaveTextContent(ex);
169
+ await userEvent.keyboard("{ArrowRight}");
170
+ await wait(80);
171
+ }
172
+ for (const ex of expected.toReversed()) {
173
+ await expect.element(document.activeElement).toHaveTextContent(ex);
174
+ await userEvent.keyboard("{ArrowLeft}");
175
+ await wait(80);
176
+ }
177
+ };
178
+ await verify();
179
+ document.querySelector(getCellQuery("x", 2, 0)).focus();
180
+ expected = [
181
+ "35",
182
+ "management",
183
+ "single",
184
+ "no",
185
+ "yes",
186
+ "cellular",
187
+ "16",
188
+ "apr",
189
+ "185",
190
+ "1",
191
+ "330",
192
+ "1",
193
+ "failure",
194
+ ];
195
+ await verify();
196
+ document.querySelector(getCellQuery("x", 4, 0)).focus();
197
+ expected = [
198
+ "59",
199
+ "blue-collar",
200
+ "0",
201
+ "secondary",
202
+ "no",
203
+ "yes",
204
+ "unknown",
205
+ "5",
206
+ "may",
207
+ "226",
208
+ "1",
209
+ "-1",
210
+ "0",
211
+ "unknown",
212
+ ];
213
+ await verify();
214
+ document.querySelector(getCellQuery("x", 5, 0)).focus();
215
+ expected = [
216
+ "35",
217
+ "management",
218
+ "747",
219
+ "secondary",
220
+ "no",
221
+ "no",
222
+ "cellular",
223
+ "23",
224
+ "feb",
225
+ "141",
226
+ "2",
227
+ "176",
228
+ "3",
229
+ "failure",
230
+ ];
231
+ await verify();
232
+ document.querySelector(getCellQuery("x", 6, 0)).focus();
233
+ expected = [
234
+ "36",
235
+ "self-employed",
236
+ "307",
237
+ "secondary",
238
+ "no",
239
+ "yes",
240
+ "cellular",
241
+ "14",
242
+ "may",
243
+ "341",
244
+ "1",
245
+ "330",
246
+ "2",
247
+ "other",
248
+ ];
249
+ await verify();
250
+ document.querySelector(getCellQuery("x", 8, 0)).focus();
251
+ expected = [
252
+ "41",
253
+ "entrepreneur",
254
+ "221",
255
+ "tertiary",
256
+ "married",
257
+ "no",
258
+ "yes",
259
+ "unknown",
260
+ "14",
261
+ "may",
262
+ "57",
263
+ "2",
264
+ "-1",
265
+ "0",
266
+ "unknown",
267
+ ];
268
+ await verify();
269
+ document.querySelector(getCellQuery("x", 9, 0)).focus();
270
+ expected = [
271
+ "43",
272
+ "service",
273
+ "-88",
274
+ "tertiary",
275
+ "married",
276
+ "no",
277
+ "yes",
278
+ "cellular",
279
+ "17",
280
+ "apr",
281
+ "313",
282
+ "1",
283
+ "147",
284
+ "2",
285
+ "failure",
286
+ ];
287
+ await verify();
288
+ document.querySelector(getCellQuery("x", 10, 0)).focus();
289
+ expected = [
290
+ "39",
291
+ "service",
292
+ "9374",
293
+ "tertiary",
294
+ "married",
295
+ "no",
296
+ "yes",
297
+ "unknown",
298
+ "20",
299
+ "may",
300
+ "273",
301
+ "1",
302
+ "-1",
303
+ "0",
304
+ "unknown",
305
+ ];
306
+ await verify();
307
+ await userEvent.keyboard("{Control>}{ArrowRight}{/Control}");
308
+ await wait(100);
309
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
310
+ await userEvent.keyboard("{Control>}{ArrowLeft}{/Control}");
311
+ await wait(100);
312
+ await expect.element(document.activeElement).toHaveTextContent("39");
313
+ document.querySelector(getCellQuery("x", 12, 0)).focus();
314
+ expected = [
315
+ "36",
316
+ "tertiary",
317
+ "no",
318
+ "no",
319
+ "cellular",
320
+ "13",
321
+ "aug",
322
+ "328",
323
+ "2",
324
+ "-1",
325
+ "0",
326
+ "unknown",
327
+ ];
328
+ await verify();
329
+ document.querySelector(getCellQuery("x", 13, 0)).focus();
330
+ expected = [
331
+ "20",
332
+ "student",
333
+ "502",
334
+ "tertiary",
335
+ "no",
336
+ "no",
337
+ "cellular",
338
+ "30",
339
+ "apr",
340
+ "261",
341
+ "1",
342
+ "-1",
343
+ "0",
344
+ "unknown",
345
+ ];
346
+ await verify();
347
+ });
348
+ test("when there are column spans the grid should be able to navigate across the cells rlt", async () => {
349
+ const screen = render(_jsx(CellSpans, { rtl: true }));
350
+ const grid = screen.getByRole("grid");
351
+ await expect.element(grid).toBeVisible();
352
+ await wait(100); // Give the grid a moment to render
353
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
354
+ await wait();
355
+ let expected = [
356
+ "30",
357
+ "primary",
358
+ "married",
359
+ "no",
360
+ "no",
361
+ "cellular",
362
+ "19",
363
+ "oct",
364
+ "79",
365
+ "1",
366
+ "-1",
367
+ "0",
368
+ "unknown",
369
+ ];
370
+ const verify = async () => {
371
+ for (const ex of expected) {
372
+ await expect.element(document.activeElement).toHaveTextContent(ex);
373
+ await userEvent.keyboard("{ArrowLeft}");
374
+ await wait(80);
375
+ }
376
+ for (const ex of expected.toReversed()) {
377
+ await expect.element(document.activeElement).toHaveTextContent(ex);
378
+ await userEvent.keyboard("{ArrowRight}");
379
+ await wait(80);
380
+ }
381
+ };
382
+ await verify();
383
+ document.querySelector(getCellQuery("x", 2, 0)).focus();
384
+ expected = [
385
+ "35",
386
+ "management",
387
+ "single",
388
+ "no",
389
+ "yes",
390
+ "cellular",
391
+ "16",
392
+ "apr",
393
+ "185",
394
+ "1",
395
+ "330",
396
+ "1",
397
+ "failure",
398
+ ];
399
+ await verify();
400
+ document.querySelector(getCellQuery("x", 4, 0)).focus();
401
+ expected = [
402
+ "59",
403
+ "blue-collar",
404
+ "0",
405
+ "secondary",
406
+ "no",
407
+ "yes",
408
+ "unknown",
409
+ "5",
410
+ "may",
411
+ "226",
412
+ "1",
413
+ "-1",
414
+ "0",
415
+ "unknown",
416
+ ];
417
+ await verify();
418
+ document.querySelector(getCellQuery("x", 5, 0)).focus();
419
+ expected = [
420
+ "35",
421
+ "management",
422
+ "747",
423
+ "secondary",
424
+ "no",
425
+ "no",
426
+ "cellular",
427
+ "23",
428
+ "feb",
429
+ "141",
430
+ "2",
431
+ "176",
432
+ "3",
433
+ "failure",
434
+ ];
435
+ await verify();
436
+ document.querySelector(getCellQuery("x", 6, 0)).focus();
437
+ expected = [
438
+ "36",
439
+ "self-employed",
440
+ "307",
441
+ "secondary",
442
+ "no",
443
+ "yes",
444
+ "cellular",
445
+ "14",
446
+ "may",
447
+ "341",
448
+ "1",
449
+ "330",
450
+ "2",
451
+ "other",
452
+ ];
453
+ await verify();
454
+ document.querySelector(getCellQuery("x", 8, 0)).focus();
455
+ expected = [
456
+ "41",
457
+ "entrepreneur",
458
+ "221",
459
+ "tertiary",
460
+ "married",
461
+ "no",
462
+ "yes",
463
+ "unknown",
464
+ "14",
465
+ "may",
466
+ "57",
467
+ "2",
468
+ "-1",
469
+ "0",
470
+ "unknown",
471
+ ];
472
+ await verify();
473
+ document.querySelector(getCellQuery("x", 9, 0)).focus();
474
+ expected = [
475
+ "43",
476
+ "service",
477
+ "-88",
478
+ "tertiary",
479
+ "married",
480
+ "no",
481
+ "yes",
482
+ "cellular",
483
+ "17",
484
+ "apr",
485
+ "313",
486
+ "1",
487
+ "147",
488
+ "2",
489
+ "failure",
490
+ ];
491
+ await verify();
492
+ document.querySelector(getCellQuery("x", 10, 0)).focus();
493
+ expected = [
494
+ "39",
495
+ "service",
496
+ "9374",
497
+ "tertiary",
498
+ "married",
499
+ "no",
500
+ "yes",
501
+ "unknown",
502
+ "20",
503
+ "may",
504
+ "273",
505
+ "1",
506
+ "-1",
507
+ "0",
508
+ "unknown",
509
+ ];
510
+ await verify();
511
+ await userEvent.keyboard("{Control>}{ArrowLeft}{/Control}");
512
+ await wait(100);
513
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
514
+ await userEvent.keyboard("{Control>}{ArrowRight}{/Control}");
515
+ await wait(100);
516
+ await expect.element(document.activeElement).toHaveTextContent("39");
517
+ document.querySelector(getCellQuery("x", 12, 0)).focus();
518
+ expected = [
519
+ "36",
520
+ "tertiary",
521
+ "no",
522
+ "no",
523
+ "cellular",
524
+ "13",
525
+ "aug",
526
+ "328",
527
+ "2",
528
+ "-1",
529
+ "0",
530
+ "unknown",
531
+ ];
532
+ await verify();
533
+ document.querySelector(getCellQuery("x", 13, 0)).focus();
534
+ expected = [
535
+ "20",
536
+ "student",
537
+ "502",
538
+ "tertiary",
539
+ "no",
540
+ "no",
541
+ "cellular",
542
+ "30",
543
+ "apr",
544
+ "261",
545
+ "1",
546
+ "-1",
547
+ "0",
548
+ "unknown",
549
+ ];
550
+ await verify();
551
+ });
552
+ test("when cells have interactive elements they should be navigable", async () => {
553
+ const screen = render(_jsx(CellWithTabbables, {}));
554
+ const grid = screen.getByRole("grid");
555
+ await expect.element(grid).toBeVisible();
556
+ await wait(); // Give the grid a moment to render
557
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
558
+ await wait();
559
+ await userEvent.keyboard("{ArrowRight}");
560
+ await expect.element(document.activeElement).toHaveTextContent("A");
561
+ await userEvent.keyboard("{ArrowRight}");
562
+ await expect.element(document.activeElement).toHaveTextContent("B");
563
+ await userEvent.keyboard("{ArrowRight}");
564
+ await expect.element(document.activeElement).toHaveTextContent("C");
565
+ await userEvent.keyboard("{ArrowRight}");
566
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
567
+ await userEvent.keyboard("{ArrowRight}");
568
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
569
+ await userEvent.keyboard("{ArrowRight}");
570
+ await expect.element(document.activeElement).toHaveTextContent("Next");
571
+ await userEvent.keyboard("{ArrowRight}");
572
+ await expect.element(document.activeElement).toHaveTextContent("married");
573
+ await userEvent.keyboard("{ArrowLeft}");
574
+ await expect.element(document.activeElement).toHaveTextContent("Next");
575
+ await userEvent.keyboard("{ArrowLeft}");
576
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
577
+ await userEvent.keyboard("{ArrowLeft}");
578
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
579
+ await userEvent.keyboard("{ArrowLeft}");
580
+ await expect.element(document.activeElement).toHaveTextContent("C");
581
+ await userEvent.keyboard("{ArrowLeft}");
582
+ await expect.element(document.activeElement).toHaveTextContent("B");
583
+ await userEvent.keyboard("{ArrowLeft}");
584
+ await expect.element(document.activeElement).toHaveTextContent("A");
585
+ await userEvent.keyboard("{ArrowLeft}");
586
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
587
+ document.querySelector(getCellQuery("x", 5, 2)).focus();
588
+ await expect.element(document.activeElement).toHaveTextContent("747");
589
+ await userEvent.keyboard("{ArrowRight}");
590
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
591
+ await userEvent.keyboard("{ArrowRight}");
592
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
593
+ document.activeElement.nextElementSibling.focus();
594
+ await expect.element(document.activeElement).toHaveTextContent("Not Tabbable");
595
+ await userEvent.keyboard("{ArrowRight}");
596
+ await expect.element(document.activeElement).toHaveTextContent("Next");
597
+ document.activeElement.previousElementSibling.focus();
598
+ await expect.element(document.activeElement).toHaveTextContent("Not Tabbable");
599
+ await userEvent.keyboard("{ArrowLeft}");
600
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
601
+ });
602
+ test("when cells have interactive elements they should be navigable rtl", async () => {
603
+ const screen = render(_jsx(CellWithTabbables, { rtl: true }));
604
+ const grid = screen.getByRole("grid");
605
+ await expect.element(grid).toBeVisible();
606
+ await wait(); // Give the grid a moment to render
607
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
608
+ await wait();
609
+ await userEvent.keyboard("{ArrowLeft}");
610
+ await expect.element(document.activeElement).toHaveTextContent("A");
611
+ await userEvent.keyboard("{ArrowLeft}");
612
+ await expect.element(document.activeElement).toHaveTextContent("B");
613
+ await userEvent.keyboard("{ArrowLeft}");
614
+ await expect.element(document.activeElement).toHaveTextContent("C");
615
+ await userEvent.keyboard("{ArrowLeft}");
616
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
617
+ await userEvent.keyboard("{ArrowLeft}");
618
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
619
+ await userEvent.keyboard("{ArrowLeft}");
620
+ await expect.element(document.activeElement).toHaveTextContent("Next");
621
+ await userEvent.keyboard("{ArrowLeft}");
622
+ await expect.element(document.activeElement).toHaveTextContent("married");
623
+ await userEvent.keyboard("{ArrowRight}");
624
+ await expect.element(document.activeElement).toHaveTextContent("Next");
625
+ await userEvent.keyboard("{ArrowRight}");
626
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
627
+ await userEvent.keyboard("{ArrowRight}");
628
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
629
+ await userEvent.keyboard("{ArrowRight}");
630
+ await expect.element(document.activeElement).toHaveTextContent("C");
631
+ await userEvent.keyboard("{ArrowRight}");
632
+ await expect.element(document.activeElement).toHaveTextContent("B");
633
+ await userEvent.keyboard("{ArrowRight}");
634
+ await expect.element(document.activeElement).toHaveTextContent("A");
635
+ await userEvent.keyboard("{ArrowRight}");
636
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
637
+ document.querySelector(getCellQuery("x", 5, 2)).focus();
638
+ await expect.element(document.activeElement).toHaveTextContent("747");
639
+ await userEvent.keyboard("{ArrowLeft}");
640
+ await expect.element(document.activeElement).toHaveTextContent("PrevNot TabbableNext");
641
+ await userEvent.keyboard("{ArrowLeft}");
642
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
643
+ document.activeElement.nextElementSibling.focus();
644
+ await expect.element(document.activeElement).toHaveTextContent("Not Tabbable");
645
+ await userEvent.keyboard("{ArrowLeft}");
646
+ await expect.element(document.activeElement).toHaveTextContent("Next");
647
+ document.activeElement.previousElementSibling.focus();
648
+ await expect.element(document.activeElement).toHaveTextContent("Not Tabbable");
649
+ await userEvent.keyboard("{ArrowRight}");
650
+ await expect.element(document.activeElement).toHaveTextContent("Prev");
651
+ });
652
+ test("full width row navigation should correctly handle the tabbables", async () => {
653
+ const screen = render(_jsx(FullWidthRows, {}));
654
+ const grid = screen.getByRole("grid");
655
+ await expect.element(grid).toBeVisible();
656
+ await wait(); // Give the grid a moment to render
657
+ document.querySelector(`[data-ln-gridid="x"][data-ln-rowtype="full-width"][data-ln-rowindex="2"] > div `).focus();
658
+ await wait();
659
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
660
+ await userEvent.keyboard("{ArrowLeft}");
661
+ await wait();
662
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
663
+ await userEvent.keyboard("{ArrowRight}");
664
+ await wait();
665
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
666
+ document.querySelector(`[data-ln-gridid="x"][data-ln-rowtype="full-width"][data-ln-rowindex="4"] > div `).focus();
667
+ await wait();
668
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
669
+ await userEvent.keyboard("{ArrowRight}");
670
+ await expect.element(document.activeElement).toHaveTextContent("A");
671
+ await userEvent.keyboard("{ArrowRight}");
672
+ await expect.element(document.activeElement).toHaveTextContent("B");
673
+ await userEvent.keyboard("{ArrowRight}");
674
+ await expect.element(document.activeElement).toHaveTextContent("C");
675
+ await userEvent.keyboard("{ArrowRight}");
676
+ await expect.element(document.activeElement).toHaveTextContent("A");
677
+ await userEvent.keyboard("{ArrowLeft}");
678
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
679
+ await userEvent.keyboard("{ArrowLeft}");
680
+ await expect.element(document.activeElement).toHaveTextContent("C");
681
+ });
682
+ test("full width row navigation should correctly handle the tabbables rtl", async () => {
683
+ const screen = render(_jsx(FullWidthRows, { rtl: true }));
684
+ const grid = screen.getByRole("grid");
685
+ await expect.element(grid).toBeVisible();
686
+ await wait(); // Give the grid a moment to render
687
+ document.querySelector(`[data-ln-gridid="x"][data-ln-rowtype="full-width"][data-ln-rowindex="2"] > div `).focus();
688
+ await wait();
689
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
690
+ await userEvent.keyboard("{ArrowRight}");
691
+ await wait();
692
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
693
+ await userEvent.keyboard("{ArrowLeft}");
694
+ await wait();
695
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
696
+ document.querySelector(`[data-ln-gridid="x"][data-ln-rowtype="full-width"][data-ln-rowindex="4"] > div `).focus();
697
+ await wait();
698
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
699
+ await userEvent.keyboard("{ArrowLeft}");
700
+ await expect.element(document.activeElement).toHaveTextContent("A");
701
+ await userEvent.keyboard("{ArrowLeft}");
702
+ await expect.element(document.activeElement).toHaveTextContent("B");
703
+ await userEvent.keyboard("{ArrowLeft}");
704
+ await expect.element(document.activeElement).toHaveTextContent("C");
705
+ await userEvent.keyboard("{ArrowLeft}");
706
+ await expect.element(document.activeElement).toHaveTextContent("A");
707
+ await userEvent.keyboard("{ArrowRight}");
708
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
709
+ await userEvent.keyboard("{ArrowRight}");
710
+ await expect.element(document.activeElement).toHaveTextContent("C");
711
+ });
712
+ test("when a column span is large navigation should still work", async () => {
713
+ const screen = render(_jsx(CellSpansLarge, {}));
714
+ const grid = screen.getByRole("grid");
715
+ await expect.element(grid).toBeVisible();
716
+ await wait(); // Give the grid a moment to render
717
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
718
+ await wait(100);
719
+ await expect.element(document.activeElement).toHaveTextContent("30");
720
+ await userEvent.keyboard("{ArrowRight}");
721
+ await expect.element(document.activeElement).toHaveTextContent("-1");
722
+ await userEvent.keyboard("{ArrowRight}");
723
+ await expect.element(document.activeElement).toHaveTextContent("0");
724
+ await userEvent.keyboard("{ArrowRight}");
725
+ await wait(100);
726
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
727
+ await userEvent.keyboard("{ArrowLeft}");
728
+ await wait(100);
729
+ await expect.element(document.activeElement).toHaveTextContent("0");
730
+ await userEvent.keyboard("{ArrowLeft}");
731
+ await expect.element(document.activeElement).toHaveTextContent("-1");
732
+ await userEvent.keyboard("{ArrowLeft}");
733
+ await expect.element(document.activeElement).toHaveTextContent("30");
734
+ });
735
+ test("when a column span is large navigation should still work rtl", async () => {
736
+ const screen = render(_jsx(CellSpansLarge, { rtl: true }));
737
+ const grid = screen.getByRole("grid");
738
+ await expect.element(grid).toBeVisible();
739
+ await wait(); // Give the grid a moment to render
740
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
741
+ await wait();
742
+ await expect.element(document.activeElement).toHaveTextContent("30");
743
+ await userEvent.keyboard("{ArrowLeft}");
744
+ await expect.element(document.activeElement).toHaveTextContent("-1");
745
+ await userEvent.keyboard("{ArrowLeft}");
746
+ await expect.element(document.activeElement).toHaveTextContent("0");
747
+ await userEvent.keyboard("{ArrowLeft}");
748
+ await wait(100);
749
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
750
+ await userEvent.keyboard("{ArrowRight}");
751
+ await wait(100);
752
+ await expect.element(document.activeElement).toHaveTextContent("0");
753
+ await userEvent.keyboard("{ArrowRight}");
754
+ await expect.element(document.activeElement).toHaveTextContent("-1");
755
+ await userEvent.keyboard("{ArrowRight}");
756
+ await expect.element(document.activeElement).toHaveTextContent("30");
757
+ });
758
+ test("when the columns are pinned should be navigate across them", async () => {
759
+ const screen = render(_jsx(CellSpansWithPins, {}));
760
+ const grid = screen.getByRole("grid");
761
+ await expect.element(grid).toBeVisible();
762
+ await wait(); // Give the grid a moment to render
763
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
764
+ await wait();
765
+ const expected = ["30", "no", "no", "oct", "79", "1", "-1", "0", "unknown", "cellular", "19"];
766
+ for (const ex of expected) {
767
+ await expect.element(document.activeElement).toHaveTextContent(ex);
768
+ await userEvent.keyboard("{ArrowRight}");
769
+ await wait();
770
+ }
771
+ for (const ex of expected.toReversed()) {
772
+ await expect.element(document.activeElement).toHaveTextContent(ex);
773
+ await userEvent.keyboard("{ArrowLeft}");
774
+ await wait();
775
+ }
776
+ await userEvent.keyboard("{Control>}{ArrowRight}{/Control}");
777
+ await wait(100);
778
+ await expect.element(document.activeElement).toHaveTextContent("19");
779
+ await userEvent.keyboard("{Control>}{ArrowLeft}{/Control}");
780
+ await wait(100);
781
+ await expect.element(document.activeElement).toHaveTextContent("30");
782
+ });
783
+ test("when the columns are pinned should be navigate across them", async () => {
784
+ const screen = render(_jsx(CellSpansWithPins, { rtl: true }));
785
+ const grid = screen.getByRole("grid");
786
+ await expect.element(grid).toBeVisible();
787
+ await wait(); // Give the grid a moment to render
788
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
789
+ await wait();
790
+ const expected = ["30", "no", "no", "oct", "79", "1", "-1", "0", "unknown", "cellular", "19"];
791
+ for (const ex of expected) {
792
+ await expect.element(document.activeElement).toHaveTextContent(ex);
793
+ await userEvent.keyboard("{ArrowLeft}");
794
+ await wait();
795
+ }
796
+ for (const ex of expected.toReversed()) {
797
+ await expect.element(document.activeElement).toHaveTextContent(ex);
798
+ await userEvent.keyboard("{ArrowRight}");
799
+ await wait();
800
+ }
801
+ await userEvent.keyboard("{Control>}{ArrowLeft}{/Control}");
802
+ await expect.element(document.activeElement).toHaveTextContent("19");
803
+ await userEvent.keyboard("{Control>}{ArrowRight}{/Control}");
804
+ await wait(100);
805
+ await expect.element(document.activeElement).toHaveTextContent("30");
806
+ });
807
+ test("when the floating cell is focused should be to navigate through it", async () => {
808
+ const screen = render(_jsx(ColumnGroups, {}));
809
+ const grid = screen.getByRole("grid");
810
+ await expect.element(grid).toBeVisible();
811
+ await wait(); // Give the grid a moment to render
812
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
813
+ await wait();
814
+ await userEvent.keyboard("{ArrowUp}");
815
+ await expect.element(document.activeElement).toHaveTextContent("age");
816
+ await userEvent.keyboard("{ArrowRight}");
817
+ await expect.element(document.activeElement).toHaveTextContent("marital");
818
+ await userEvent.keyboard("{ArrowRight}");
819
+ await expect.element(document.activeElement).toHaveTextContent("default");
820
+ await userEvent.keyboard("{ArrowRight}");
821
+ await expect.element(document.activeElement).toHaveTextContent("housing");
822
+ await userEvent.keyboard("{ArrowLeft}");
823
+ await expect.element(document.activeElement).toHaveTextContent("default");
824
+ await userEvent.keyboard("{ArrowLeft}");
825
+ await expect.element(document.activeElement).toHaveTextContent("marital");
826
+ });
827
+ test("when the header is focused should be to navigate through it", async () => {
828
+ const screen = render(_jsx(ColumnGroups, {}));
829
+ const grid = screen.getByRole("grid");
830
+ await expect.element(grid).toBeVisible();
831
+ await wait(); // Give the grid a moment to render
832
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
833
+ await wait();
834
+ await userEvent.keyboard("{ArrowUp}");
835
+ await wait();
836
+ await userEvent.keyboard("{ArrowUp}");
837
+ await expect.element(document.activeElement).toHaveTextContent("age");
838
+ await userEvent.keyboard("{ArrowRight}");
839
+ await expect.element(document.activeElement).toHaveTextContent("marital");
840
+ await userEvent.keyboard("{ArrowRight}");
841
+ await expect.element(document.activeElement).toHaveTextContent("default");
842
+ await userEvent.keyboard("{ArrowRight}");
843
+ await expect.element(document.activeElement).toHaveTextContent("housing");
844
+ await userEvent.keyboard("{ArrowLeft}");
845
+ await expect.element(document.activeElement).toHaveTextContent("default");
846
+ await userEvent.keyboard("{ArrowLeft}");
847
+ await expect.element(document.activeElement).toHaveTextContent("marital");
848
+ });
849
+ test("when the header group is focused should be able to navigate through", async () => {
850
+ const screen = render(_jsx(ColumnGroups, {}));
851
+ const grid = screen.getByRole("grid");
852
+ await expect.element(grid).toBeVisible();
853
+ await wait(); // Give the grid a moment to render
854
+ document.querySelector(getCellQuery("x", 0, 0)).focus();
855
+ await wait();
856
+ await userEvent.keyboard("{ArrowUp}");
857
+ await userEvent.keyboard("{ArrowUp}");
858
+ await userEvent.keyboard("{ArrowUp}");
859
+ await expect.element(document.activeElement).toHaveTextContent("A-->B");
860
+ await userEvent.keyboard("{ArrowUp}");
861
+ await expect.element(document.activeElement).toHaveTextContent("A");
862
+ await userEvent.keyboard("{ArrowRight}");
863
+ await expect.element(document.activeElement).toHaveTextContent("T");
864
+ await userEvent.keyboard("{ArrowDown}");
865
+ await expect.element(document.activeElement).toHaveTextContent("default");
866
+ await userEvent.keyboard("{ArrowLeft}");
867
+ await expect.element(document.activeElement).toHaveTextContent("marital");
868
+ await userEvent.keyboard("{ArrowRight}");
869
+ await userEvent.keyboard("{ArrowRight}");
870
+ await userEvent.keyboard("{ArrowRight}");
871
+ await userEvent.keyboard("{ArrowRight}");
872
+ await expect.element(document.activeElement).toHaveTextContent("contact");
873
+ await userEvent.keyboard("{ArrowUp}");
874
+ await expect.element(document.activeElement).toHaveTextContent("A-->B-->C");
875
+ await userEvent.keyboard("{ArrowRight}");
876
+ await expect.element(document.activeElement).toHaveTextContent("day");
877
+ });