@1771technologies/lytenyte-pro 1.0.12 → 1.0.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.
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 +3 -22
  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,10 @@
1
+ import "./navigation.css";
2
+ import type { Column } from "../../+types.js";
3
+ export default function BasicRendering({ rtl, columns, pinTop, center, pinBot, floatingRow, }: {
4
+ rtl?: boolean;
5
+ columns?: Column<any>[];
6
+ center?: number;
7
+ pinTop?: number;
8
+ pinBot?: number;
9
+ floatingRow?: boolean;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import "./navigation.css";
3
+ import { useLyteNyte } from "../../state/use-lytenyte.js";
4
+ import { bankDataSmall } from "../test-utils/bank-data-smaller.js";
5
+ import { Root } from "../../root/root.js";
6
+ import { Viewport } from "../../viewport/viewport.js";
7
+ import { Header } from "../../header/header.js";
8
+ import { HeaderRow } from "../../header/header-row.js";
9
+ import { HeaderGroupCell } from "../../header/header-group-cell.js";
10
+ import { HeaderCell } from "../../header/header-cell.js";
11
+ import { RowsContainer } from "../../rows/rows-container.js";
12
+ import { RowsBottom, RowsCenter, RowsTop } from "../../rows/rows-sections.js";
13
+ import { RowHandler } from "../test-utils/row-handler.js";
14
+ import { useClientRowDataSource } from "../../row-data-source-client/use-client-data-source.js";
15
+ const baseColumns = [
16
+ { id: "age" },
17
+ { id: "job" },
18
+ { id: "balance" },
19
+ { id: "education" },
20
+ { id: "marital" },
21
+ { id: "default" },
22
+ { id: "housing" },
23
+ { id: "loan" },
24
+ { id: "contact" },
25
+ { id: "day" },
26
+ { id: "month" },
27
+ { id: "duration" },
28
+ { id: "campaign" },
29
+ { id: "pdays" },
30
+ { id: "previous" },
31
+ { id: "poutcome" },
32
+ { id: "y" },
33
+ ];
34
+ export default function BasicRendering({ rtl, columns, pinTop, center, pinBot, floatingRow, }) {
35
+ const ds = useClientRowDataSource({
36
+ data: center ? bankDataSmall.slice(0, center) : bankDataSmall,
37
+ topData: pinTop ? bankDataSmall.slice(0, pinTop) : [],
38
+ bottomData: pinBot ? bankDataSmall.slice(0, pinBot) : [],
39
+ });
40
+ const g = useLyteNyte({
41
+ gridId: "x",
42
+ columns: columns ?? baseColumns,
43
+ rowDataSource: ds,
44
+ rtl: rtl,
45
+ floatingRowEnabled: floatingRow,
46
+ });
47
+ const view = g.view.useValue();
48
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, onClick: () => { }, children: "Top Capture" }), _jsx("div", { style: { width: "100%", height: "90vh", border: "1px solid black" }, children: _jsx(Root, { grid: g, children: _jsxs(Viewport, { children: [_jsx(Header, { children: view.header.layout.map((row, i) => {
49
+ return (_jsx(HeaderRow, { headerRowIndex: i, children: row.map((c) => {
50
+ if (c.kind === "group") {
51
+ return (_jsx(HeaderGroupCell, { cell: c, style: {
52
+ paddingInline: "16px",
53
+ background: "light-dark(rgb(200,200,200),rgb(57, 39, 39))",
54
+ color: "light-dark(black,white)",
55
+ display: "flex",
56
+ alignItems: "center",
57
+ borderBottom: "1px solid light-dark(gray, #444242)",
58
+ borderRight: "1px solid light-dark(gray, #444242)",
59
+ } }, c.idOccurrence));
60
+ }
61
+ return (_jsx(HeaderCell, { cell: c, style: {
62
+ paddingInline: "16px",
63
+ background: "light-dark(rgb(200,200,200),rgb(57, 39, 39))",
64
+ color: "light-dark(black,white)",
65
+ display: "flex",
66
+ alignItems: "center",
67
+ borderBottom: "1px solid light-dark(gray, #444242)",
68
+ borderRight: "1px solid light-dark(gray, #444242)",
69
+ } }, c.column.id));
70
+ }) }, i));
71
+ }) }), _jsxs(RowsContainer, { children: [_jsx(RowsTop, { children: _jsx(RowHandler, { rows: view.rows.top, withStyles: true, pinned: true }) }), _jsx(RowsCenter, { children: _jsx(RowHandler, { rows: view.rows.center, withStyles: true }) }), _jsx(RowsBottom, { children: _jsx(RowHandler, { rows: view.rows.bottom, withStyles: true, pinned: true }) })] })] }) }) }), _jsx("button", { tabIndex: 0, onClick: () => { }, children: "Bottom Capture" })] }));
72
+ }
@@ -0,0 +1,3 @@
1
+ export default function PinnedGapLayout({ rtl }: {
2
+ rtl?: boolean;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import NormalLayout from "./normal-layout.play.js";
3
+ const baseColumns = [
4
+ { id: "age", pin: "start" },
5
+ { id: "job" },
6
+ { id: "marital" },
7
+ { id: "housing", pin: "end" },
8
+ ];
9
+ export default function PinnedGapLayout({ rtl }) {
10
+ return _jsx(NormalLayout, { columns: baseColumns, rtl: rtl });
11
+ }
@@ -0,0 +1,6 @@
1
+ import "./navigation.css";
2
+ import type { Column } from "../../+types.js";
3
+ export default function RowDetailWithSpans({ rtl, columns, }: {
4
+ rtl?: boolean;
5
+ columns?: Column<any>[];
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,79 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import "./navigation.css";
3
+ import { useLyteNyte } from "../../state/use-lytenyte.js";
4
+ import { bankDataSmall } from "../test-utils/bank-data-smaller.js";
5
+ import { Root } from "../../root/root.js";
6
+ import { Viewport } from "../../viewport/viewport.js";
7
+ import { Header } from "../../header/header.js";
8
+ import { HeaderRow } from "../../header/header-row.js";
9
+ import { HeaderGroupCell } from "../../header/header-group-cell.js";
10
+ import { HeaderCell } from "../../header/header-cell.js";
11
+ import { RowsContainer } from "../../rows/rows-container.js";
12
+ import { RowsBottom, RowsCenter, RowsTop } from "../../rows/rows-sections.js";
13
+ import { RowHandler } from "../test-utils/row-handler.js";
14
+ import { useClientRowDataSource } from "../../row-data-source-client/use-client-data-source.js";
15
+ const baseColumns = [
16
+ { id: "age" },
17
+ {
18
+ id: "job",
19
+ rowSpan: (c) => {
20
+ if (c.rowIndex === 0)
21
+ return 5;
22
+ return 1;
23
+ },
24
+ },
25
+ { id: "balance" },
26
+ { id: "education" },
27
+ { id: "marital" },
28
+ { id: "default" },
29
+ { id: "housing" },
30
+ { id: "loan" },
31
+ { id: "contact" },
32
+ { id: "day" },
33
+ { id: "month" },
34
+ { id: "duration" },
35
+ { id: "campaign" },
36
+ { id: "pdays" },
37
+ { id: "previous" },
38
+ { id: "poutcome" },
39
+ { id: "y" },
40
+ ];
41
+ export default function RowDetailWithSpans({ rtl, columns, }) {
42
+ const ds = useClientRowDataSource({
43
+ data: bankDataSmall,
44
+ });
45
+ const g = useLyteNyte({
46
+ gridId: "x",
47
+ columns: columns ?? baseColumns,
48
+ rowDataSource: ds,
49
+ rtl: rtl,
50
+ rowDetailExpansions: new Set(["2"]),
51
+ columnMarkerEnabled: true,
52
+ columnMarker: {
53
+ width: 60,
54
+ cellRenderer: (p) => {
55
+ return _jsx("button", { onClick: () => p.grid.api.rowDetailToggle(p.row), children: "X" });
56
+ },
57
+ },
58
+ rowDetailRenderer: () => {
59
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, children: "Detail A" }), _jsx("button", { tabIndex: 0, children: "Detail B" })] }));
60
+ },
61
+ });
62
+ const view = g.view.useValue();
63
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, onClick: () => { }, children: "Top Capture" }), _jsx("div", { style: { width: "100%", height: "90vh", border: "1px solid black" }, children: _jsx(Root, { grid: g, children: _jsxs(Viewport, { children: [_jsx(Header, { children: view.header.layout.map((row, i) => {
64
+ return (_jsx(HeaderRow, { headerRowIndex: i, children: row.map((c) => {
65
+ if (c.kind === "group") {
66
+ return _jsx(HeaderGroupCell, { cell: c }, c.idOccurrence);
67
+ }
68
+ return (_jsx(HeaderCell, { cell: c, style: {
69
+ paddingInline: "16px",
70
+ background: "light-dark(rgb(200,200,200),rgb(57, 39, 39))",
71
+ color: "light-dark(black,white)",
72
+ display: "flex",
73
+ alignItems: "center",
74
+ borderBottom: "1px solid light-dark(gray, #444242)",
75
+ borderRight: "1px solid light-dark(gray, #444242)",
76
+ } }, c.column.id));
77
+ }) }, i));
78
+ }) }), _jsxs(RowsContainer, { children: [_jsx(RowsTop, { children: _jsx(RowHandler, { rows: view.rows.top, withStyles: true, pinned: true }) }), _jsx(RowsCenter, { children: _jsx(RowHandler, { rows: view.rows.center, withStyles: true }) }), _jsx(RowsBottom, { children: _jsx(RowHandler, { rows: view.rows.bottom, withStyles: true, pinned: true }) })] })] }) }) }), _jsx("button", { tabIndex: 0, onClick: () => { }, children: "Bottom Capture" })] }));
79
+ }
@@ -0,0 +1,6 @@
1
+ import "./navigation.css";
2
+ import type { Column } from "../../+types.js";
3
+ export default function RowDetail({ rtl, columns }: {
4
+ rtl?: boolean;
5
+ columns?: Column<any>[];
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import "./navigation.css";
3
+ import { useLyteNyte } from "../../state/use-lytenyte.js";
4
+ import { bankDataSmall } from "../test-utils/bank-data-smaller.js";
5
+ import { Root } from "../../root/root.js";
6
+ import { Viewport } from "../../viewport/viewport.js";
7
+ import { Header } from "../../header/header.js";
8
+ import { HeaderRow } from "../../header/header-row.js";
9
+ import { HeaderGroupCell } from "../../header/header-group-cell.js";
10
+ import { HeaderCell } from "../../header/header-cell.js";
11
+ import { RowsContainer } from "../../rows/rows-container.js";
12
+ import { RowsBottom, RowsCenter, RowsTop } from "../../rows/rows-sections.js";
13
+ import { RowHandler } from "../test-utils/row-handler.js";
14
+ import { useClientRowDataSource } from "../../row-data-source-client/use-client-data-source.js";
15
+ const baseColumns = [
16
+ { id: "age" },
17
+ { id: "job" },
18
+ { id: "balance" },
19
+ { id: "education" },
20
+ { id: "marital" },
21
+ { id: "default" },
22
+ { id: "housing" },
23
+ { id: "loan" },
24
+ { id: "contact" },
25
+ { id: "day" },
26
+ { id: "month" },
27
+ { id: "duration" },
28
+ { id: "campaign" },
29
+ { id: "pdays" },
30
+ { id: "previous" },
31
+ { id: "poutcome" },
32
+ { id: "y" },
33
+ ];
34
+ export default function RowDetail({ rtl, columns }) {
35
+ const ds = useClientRowDataSource({
36
+ data: bankDataSmall,
37
+ });
38
+ const g = useLyteNyte({
39
+ gridId: "x",
40
+ columns: columns ?? baseColumns,
41
+ rowDataSource: ds,
42
+ rtl: rtl,
43
+ rowDetailExpansions: new Set(["2", "5"]),
44
+ columnMarkerEnabled: true,
45
+ columnMarker: {
46
+ width: 60,
47
+ cellRenderer: (p) => {
48
+ return _jsx("button", { onClick: () => p.grid.api.rowDetailToggle(p.row), children: "X" });
49
+ },
50
+ },
51
+ rowDetailRenderer: () => {
52
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, children: "Detail A" }), _jsx("button", { tabIndex: 0, children: "Detail B" })] }));
53
+ },
54
+ rowFullWidthPredicate: (r) => r.rowIndex === 2 || r.rowIndex == 4,
55
+ rowFullWidthRenderer: (r) => {
56
+ if (r.rowIndex === 2)
57
+ return _jsx("div", { children: "Nothing" });
58
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, children: "A" }), _jsx("button", { tabIndex: 0, children: "B" }), _jsx("button", { tabIndex: 0, children: "C" })] }));
59
+ },
60
+ });
61
+ const view = g.view.useValue();
62
+ return (_jsxs("div", { children: [_jsx("button", { tabIndex: 0, onClick: () => { }, children: "Top Capture" }), _jsx("div", { style: { width: "100%", height: "90vh", border: "1px solid black" }, children: _jsx(Root, { grid: g, children: _jsxs(Viewport, { children: [_jsx(Header, { children: view.header.layout.map((row, i) => {
63
+ return (_jsx(HeaderRow, { headerRowIndex: i, children: row.map((c) => {
64
+ if (c.kind === "group") {
65
+ return _jsx(HeaderGroupCell, { cell: c }, c.idOccurrence);
66
+ }
67
+ return (_jsx(HeaderCell, { cell: c, style: {
68
+ paddingInline: "16px",
69
+ background: "light-dark(rgb(200,200,200),rgb(57, 39, 39))",
70
+ color: "light-dark(black,white)",
71
+ display: "flex",
72
+ alignItems: "center",
73
+ borderBottom: "1px solid light-dark(gray, #444242)",
74
+ borderRight: "1px solid light-dark(gray, #444242)",
75
+ } }, c.column.id));
76
+ }) }, i));
77
+ }) }), _jsxs(RowsContainer, { children: [_jsx(RowsTop, { children: _jsx(RowHandler, { rows: view.rows.top, withStyles: true, pinned: true }) }), _jsx(RowsCenter, { children: _jsx(RowHandler, { rows: view.rows.center, withStyles: true }) }), _jsx(RowsBottom, { children: _jsx(RowHandler, { rows: view.rows.bottom, withStyles: true, pinned: true }) })] })] }) }) }), _jsx("button", { tabIndex: 0, onClick: () => { }, children: "Bottom Capture" })] }));
78
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { wait } from "@1771technologies/lytenyte-js-utils";
3
+ import { expect, test } from "vitest";
4
+ import { render } from "vitest-browser-react";
5
+ import RowDetail from "./row-detail.play.js";
6
+ import { getCellQuery } from "@1771technologies/lytenyte-shared";
7
+ import { userEvent } from "@vitest/browser/context";
8
+ import RowDetailWithSpans from "./row-detail-with-spans.play.js";
9
+ test("when row details are present it should be possible to navigate across them", async () => {
10
+ const screen = render(_jsx(RowDetail, {}));
11
+ const grid = screen.getByRole("grid");
12
+ await expect.element(grid).toBeVisible();
13
+ await wait(); // Give the grid a moment to render
14
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 0));
15
+ ourFirstCell.focus();
16
+ await expect.element(ourFirstCell).toHaveFocus();
17
+ await userEvent.keyboard("{ArrowDown}");
18
+ await wait();
19
+ await userEvent.keyboard("{ArrowDown}");
20
+ await wait();
21
+ await userEvent.keyboard("{ArrowDown}");
22
+ await wait();
23
+ await expect.element(document.activeElement).toHaveTextContent("Detail ADetail B");
24
+ await userEvent.keyboard("{ArrowLeft}");
25
+ await wait();
26
+ await expect.element(document.activeElement).toHaveTextContent("Detail B");
27
+ await userEvent.keyboard("{ArrowLeft}");
28
+ await wait();
29
+ await expect.element(document.activeElement).toHaveTextContent("Detail A");
30
+ await userEvent.keyboard("{ArrowDown}");
31
+ await wait();
32
+ await expect.element(document.activeElement).toHaveTextContent("X");
33
+ await userEvent.keyboard("{ArrowDown}");
34
+ await wait();
35
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
36
+ await userEvent.keyboard("{ArrowUp}");
37
+ await wait();
38
+ await expect.element(document.activeElement).toHaveTextContent("X");
39
+ await userEvent.keyboard("{ArrowUp}");
40
+ await wait();
41
+ await expect.element(document.activeElement).toHaveTextContent("Detail ADetail B");
42
+ await userEvent.keyboard("{ArrowDown}");
43
+ await wait();
44
+ await expect.element(document.activeElement).toHaveTextContent("X");
45
+ await userEvent.keyboard("{ArrowLeft}");
46
+ await wait();
47
+ await expect.element(document.activeElement).toHaveTextContent("X");
48
+ await userEvent.click(document.activeElement);
49
+ await wait();
50
+ await userEvent.keyboard("{ArrowDown}");
51
+ await expect.element(document.activeElement).toHaveTextContent("Detail ADetail B");
52
+ });
53
+ test("when there are row spans it should be cutoff when the detail is expanded", async () => {
54
+ const screen = render(_jsx(RowDetailWithSpans, {}));
55
+ const grid = screen.getByRole("grid");
56
+ await expect.element(grid).toBeVisible();
57
+ await wait(); // Give the grid a moment to render
58
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 2));
59
+ ourFirstCell.focus();
60
+ await expect.element(ourFirstCell).toHaveFocus();
61
+ await expect.element(document.activeElement).toHaveTextContent("unemployed");
62
+ await userEvent.keyboard("{ArrowDown}");
63
+ await wait();
64
+ await expect.element(document.activeElement).toHaveTextContent("management");
65
+ await userEvent.keyboard("{ArrowDown}");
66
+ await wait();
67
+ await expect.element(document.activeElement).toHaveTextContent("Detail ADetail B");
68
+ });
@@ -0,0 +1,176 @@
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 { wait } from "@1771technologies/lytenyte-js-utils";
6
+ import { getCellQuery } from "@1771technologies/lytenyte-shared";
7
+ import { userEvent } from "@vitest/browser/context";
8
+ import { bankDataSmall } from "../test-utils/bank-data-smaller.js";
9
+ import FullWidthRows from "./full-width-rows.play.js";
10
+ import CellSpans from "./cell-spans.play.js";
11
+ test("should be able to navigate up and down cells", async () => {
12
+ const screen = render(_jsx(NormalLayout, { center: 50 }));
13
+ const grid = screen.getByRole("grid");
14
+ await expect.element(grid).toBeVisible();
15
+ await wait(); // Give the grid a moment to render
16
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 0));
17
+ ourFirstCell.focus();
18
+ const values = bankDataSmall.slice(0, 50).map((c) => `${c.age}`);
19
+ for (const v of values) {
20
+ await expect.element(document.activeElement).toHaveTextContent(v);
21
+ await userEvent.keyboard("{ArrowDown}");
22
+ await wait(100);
23
+ }
24
+ for (const v of values.toReversed()) {
25
+ await expect.element(document.activeElement).toHaveTextContent(v);
26
+ await userEvent.keyboard("{ArrowUp}");
27
+ await wait(100);
28
+ }
29
+ });
30
+ test("should be able to navigate up and down cells with pins", async () => {
31
+ const screen = render(_jsx(NormalLayout, { pinTop: 2, pinBot: 2, center: 50 }));
32
+ const grid = screen.getByRole("grid");
33
+ await expect.element(grid).toBeVisible();
34
+ await wait(); // Give the grid a moment to render
35
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 0));
36
+ ourFirstCell.focus();
37
+ const values = bankDataSmall
38
+ .slice(0, 2)
39
+ .map((c) => `${c.age}`)
40
+ .concat(bankDataSmall.slice(0, 50).map((c) => `${c.age}`))
41
+ .concat(bankDataSmall.slice(0, 2).map((c) => `${c.age}`));
42
+ for (const v of values) {
43
+ await expect.element(document.activeElement).toHaveTextContent(v);
44
+ await userEvent.keyboard("{ArrowDown}");
45
+ await wait(100);
46
+ }
47
+ for (const v of values.toReversed()) {
48
+ await expect.element(document.activeElement).toHaveTextContent(v);
49
+ await userEvent.keyboard("{ArrowUp}");
50
+ await wait(100);
51
+ }
52
+ });
53
+ test("should be able to handle moving to the start or end", async () => {
54
+ const screen = render(_jsx(NormalLayout, {}));
55
+ const grid = screen.getByRole("grid");
56
+ await expect.element(grid).toBeVisible();
57
+ await wait(); // Give the grid a moment to render
58
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 0));
59
+ ourFirstCell.focus();
60
+ await expect.element(document.activeElement).toHaveTextContent("30");
61
+ await userEvent.keyboard("{Control>}{ArrowDown}{/Control}");
62
+ await wait(200);
63
+ await expect.element(document.activeElement).toHaveTextContent("42");
64
+ await userEvent.keyboard("{Control>}{ArrowUp}{/Control}");
65
+ await wait(200);
66
+ await expect.element(document.activeElement).toHaveTextContent("30");
67
+ });
68
+ test("should be navigate across full width rows", async () => {
69
+ const screen = render(_jsx(FullWidthRows, {}));
70
+ const grid = screen.getByRole("grid");
71
+ await expect.element(grid).toBeVisible();
72
+ await wait(); // Give the grid a moment to render
73
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 2));
74
+ ourFirstCell.focus();
75
+ await expect.element(document.activeElement).toHaveTextContent("1787");
76
+ await userEvent.keyboard("{ArrowDown}");
77
+ await expect.element(document.activeElement).toHaveTextContent("4789");
78
+ await userEvent.keyboard("{ArrowDown}");
79
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
80
+ await userEvent.keyboard("{ArrowDown}");
81
+ await expect.element(document.activeElement).toHaveTextContent("1476");
82
+ await userEvent.keyboard("{ArrowDown}");
83
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
84
+ await userEvent.keyboard("{ArrowDown}");
85
+ await expect.element(document.activeElement).toHaveTextContent("747");
86
+ await userEvent.keyboard("{ArrowUp}");
87
+ await expect.element(document.activeElement).toHaveTextContent("ABC");
88
+ await userEvent.keyboard("{ArrowUp}");
89
+ await expect.element(document.activeElement).toHaveTextContent("1476");
90
+ await userEvent.keyboard("{ArrowUp}");
91
+ await expect.element(document.activeElement).toHaveTextContent("Nothing");
92
+ await userEvent.keyboard("{ArrowUp}");
93
+ await expect.element(document.activeElement).toHaveTextContent("4789");
94
+ });
95
+ test("should be able to navigate across column and row spans", async () => {
96
+ const screen = render(_jsx(CellSpans, {}));
97
+ const grid = screen.getByRole("grid");
98
+ await expect.element(grid).toBeVisible();
99
+ await wait(); // Give the grid a moment to render
100
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 3));
101
+ ourFirstCell.focus();
102
+ await expect.element(document.activeElement).toHaveTextContent("primary");
103
+ await userEvent.keyboard("{ArrowDown}");
104
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
105
+ await userEvent.keyboard("{ArrowDown}");
106
+ await expect.element(document.activeElement).toHaveTextContent("management");
107
+ await userEvent.keyboard("{ArrowDown}");
108
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
109
+ await userEvent.keyboard("{ArrowDown}");
110
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
111
+ await userEvent.keyboard("{ArrowUp}");
112
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
113
+ await userEvent.keyboard("{ArrowRight}");
114
+ await expect.element(document.activeElement).toHaveTextContent("married");
115
+ await userEvent.keyboard("{ArrowDown}");
116
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
117
+ await userEvent.keyboard("{ArrowDown}");
118
+ await expect.element(document.activeElement).toHaveTextContent("married");
119
+ await userEvent.keyboard("{ArrowDown}");
120
+ await expect.element(document.activeElement).toHaveTextContent("married");
121
+ await userEvent.keyboard("{ArrowLeft}");
122
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
123
+ await userEvent.keyboard("{ArrowDown}");
124
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
125
+ await userEvent.keyboard("{ArrowDown}");
126
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
127
+ await userEvent.keyboard("{ArrowDown}");
128
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
129
+ await userEvent.keyboard("{ArrowUp}");
130
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
131
+ await userEvent.keyboard("{ArrowUp}");
132
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
133
+ await userEvent.keyboard("{ArrowUp}");
134
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
135
+ await userEvent.keyboard("{ArrowUp}");
136
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
137
+ await userEvent.keyboard("{ArrowUp}");
138
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
139
+ await userEvent.keyboard("{ArrowUp}");
140
+ await expect.element(document.activeElement).toHaveTextContent("tertiary");
141
+ await userEvent.keyboard("{ArrowUp}");
142
+ await expect.element(document.activeElement).toHaveTextContent("management");
143
+ });
144
+ test("page up and down should focus the correct 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
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 3));
150
+ ourFirstCell.focus();
151
+ await userEvent.keyboard("{PageDown}");
152
+ await expect.element(document.activeElement).toHaveTextContent("secondary");
153
+ await userEvent.keyboard("{PageUp}");
154
+ await expect.element(document.activeElement).toHaveTextContent("management");
155
+ });
156
+ test("home and end should work as expected", async () => {
157
+ const screen = render(_jsx(CellSpans, {}));
158
+ const grid = screen.getByRole("grid");
159
+ await expect.element(grid).toBeVisible();
160
+ await wait(); // Give the grid a moment to render
161
+ const ourFirstCell = document.querySelector(getCellQuery("x", 0, 3));
162
+ ourFirstCell.focus();
163
+ await expect.element(document.activeElement).toHaveTextContent("primary");
164
+ await userEvent.keyboard("{End}");
165
+ await wait(100);
166
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
167
+ await userEvent.keyboard("{Home}");
168
+ await wait(100);
169
+ await expect.element(document.activeElement).toHaveTextContent("30");
170
+ await userEvent.keyboard("{Control>}{End}{/Control}");
171
+ await wait(100);
172
+ await expect.element(document.activeElement).toHaveTextContent("unknown");
173
+ await userEvent.keyboard("{Control>}{Home}{/Control}");
174
+ await wait(100);
175
+ await expect.element(document.activeElement).toHaveTextContent("30");
176
+ });
@@ -0,0 +1,19 @@
1
+ export declare const bankDataSmall: {
2
+ age: number;
3
+ job: string;
4
+ marital: string;
5
+ education: string;
6
+ default: string;
7
+ balance: number;
8
+ housing: string;
9
+ loan: string;
10
+ contact: string;
11
+ day: number;
12
+ month: string;
13
+ duration: number;
14
+ campaign: string;
15
+ pdays: string;
16
+ previous: string;
17
+ poutcome: string;
18
+ y: string;
19
+ }[];