@dashforge/tw 0.8.1-beta → 0.9.0-beta
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/CHANGELOG.md +126 -0
- package/COVERAGE.md +63 -0
- package/LICENSE +21 -0
- package/PERFORMANCE.md +59 -0
- package/REFINEMENT-NOTES.md +50 -0
- package/dist/index.esm.js +177 -67
- package/dist/src/components/DataGrid/DataGrid.d.ts.map +1 -1
- package/dist/src/components/DataGrid/filters/ColumnFilters.d.ts.map +1 -1
- package/dist/src/components/DataGrid/resize/useColumnResize.d.ts +7 -0
- package/dist/src/components/DataGrid/resize/useColumnResize.d.ts.map +1 -1
- package/dist/src/components/DataGrid/visibility/ColumnVisibilityMenu.d.ts +6 -2
- package/dist/src/components/DataGrid/visibility/ColumnVisibilityMenu.d.ts.map +1 -1
- package/dist/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/src/components/Table/Table.d.ts.map +1 -1
- package/dist/src/components/Table/cells/RenderChip.d.ts.map +1 -1
- package/dist/src/components/Table/table.types.d.ts +28 -3
- package/dist/src/components/Table/table.types.d.ts.map +1 -1
- package/dist/src/components/Typography/typography.variants.d.ts.map +1 -1
- package/eslint.config.mjs +16 -1
- package/package.json +9 -6
- package/src/components/Breadcrumbs/Breadcrumbs.perf.test.tsx +5 -2
- package/src/components/DataGrid/DataGrid.perf.test.tsx +114 -0
- package/src/components/DataGrid/DataGrid.test.tsx +240 -0
- package/src/components/DataGrid/DataGrid.tsx +104 -16
- package/src/components/DataGrid/filters/ColumnFilters.test.tsx +330 -0
- package/src/components/DataGrid/filters/ColumnFilters.tsx +26 -2
- package/src/components/DataGrid/reorder/useColumnReorder.test.ts +95 -3
- package/src/components/DataGrid/resize/useColumnResize.test.ts +144 -0
- package/src/components/DataGrid/resize/useColumnResize.ts +30 -1
- package/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx +42 -25
- package/src/components/Dialog/Dialog.tsx +9 -0
- package/src/components/Table/Table.perf.test.tsx +81 -0
- package/src/components/Table/Table.test.tsx +72 -1
- package/src/components/Table/Table.tsx +40 -4
- package/src/components/Table/cells/RenderChip.tsx +6 -9
- package/src/components/Table/cells/cells.test.tsx +247 -0
- package/src/components/Table/table.types.ts +28 -3
- package/src/components/Typography/Typography.test.tsx +15 -0
- package/src/components/Typography/typography.variants.ts +14 -1
- package/test-output/vitest/coverage/base.css +224 -0
- package/test-output/vitest/coverage/block-navigation.js +87 -0
- package/test-output/vitest/coverage/clover.xml +2418 -0
- package/test-output/vitest/coverage/coverage-final.json +89 -0
- package/test-output/vitest/coverage/favicon.png +0 -0
- package/test-output/vitest/coverage/index.html +746 -0
- package/test-output/vitest/coverage/prettify.css +1 -0
- package/test-output/vitest/coverage/prettify.js +2 -0
- package/test-output/vitest/coverage/sort-arrow-sprite.png +0 -0
- package/test-output/vitest/coverage/sorter.js +210 -0
- package/test-output/vitest/coverage/src/components/Accordion/Accordion.tsx.html +376 -0
- package/test-output/vitest/coverage/src/components/Accordion/accordion.variants.ts.html +181 -0
- package/test-output/vitest/coverage/src/components/Accordion/index.html +131 -0
- package/test-output/vitest/coverage/src/components/AppShell/AppShell.tsx.html +802 -0
- package/test-output/vitest/coverage/src/components/AppShell/appShell.variants.ts.html +247 -0
- package/test-output/vitest/coverage/src/components/AppShell/index.html +131 -0
- package/test-output/vitest/coverage/src/components/AspectRatio/AspectRatio.tsx.html +304 -0
- package/test-output/vitest/coverage/src/components/AspectRatio/index.html +116 -0
- package/test-output/vitest/coverage/src/components/Autocomplete/Autocomplete.tsx.html +3292 -0
- package/test-output/vitest/coverage/src/components/Autocomplete/autocomplete.variants.ts.html +508 -0
- package/test-output/vitest/coverage/src/components/Autocomplete/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Box/Box.tsx.html +334 -0
- package/test-output/vitest/coverage/src/components/Box/box.variants.ts.html +775 -0
- package/test-output/vitest/coverage/src/components/Box/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Breadcrumbs/Breadcrumbs.tsx.html +694 -0
- package/test-output/vitest/coverage/src/components/Breadcrumbs/breadcrumbs.variants.ts.html +247 -0
- package/test-output/vitest/coverage/src/components/Breadcrumbs/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Button/Button.tsx.html +535 -0
- package/test-output/vitest/coverage/src/components/Button/button.variants.ts.html +562 -0
- package/test-output/vitest/coverage/src/components/Button/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Checkbox/Checkbox.tsx.html +943 -0
- package/test-output/vitest/coverage/src/components/Checkbox/checkbox.variants.ts.html +289 -0
- package/test-output/vitest/coverage/src/components/Checkbox/index.html +131 -0
- package/test-output/vitest/coverage/src/components/ConfirmDialog/ConfirmDialog.tsx.html +841 -0
- package/test-output/vitest/coverage/src/components/ConfirmDialog/confirmDialog.variants.ts.html +313 -0
- package/test-output/vitest/coverage/src/components/ConfirmDialog/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Container/Container.tsx.html +307 -0
- package/test-output/vitest/coverage/src/components/Container/container.variants.ts.html +328 -0
- package/test-output/vitest/coverage/src/components/Container/index.html +131 -0
- package/test-output/vitest/coverage/src/components/DataGrid/DataGrid.tsx.html +3937 -0
- package/test-output/vitest/coverage/src/components/DataGrid/dataGrid.variants.ts.html +541 -0
- package/test-output/vitest/coverage/src/components/DataGrid/filters/ColumnFilters.tsx.html +1453 -0
- package/test-output/vitest/coverage/src/components/DataGrid/filters/index.html +116 -0
- package/test-output/vitest/coverage/src/components/DataGrid/index.html +131 -0
- package/test-output/vitest/coverage/src/components/DataGrid/reorder/index.html +116 -0
- package/test-output/vitest/coverage/src/components/DataGrid/reorder/useColumnReorder.ts.html +517 -0
- package/test-output/vitest/coverage/src/components/DataGrid/resize/index.html +116 -0
- package/test-output/vitest/coverage/src/components/DataGrid/resize/useColumnResize.ts.html +490 -0
- package/test-output/vitest/coverage/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx.html +592 -0
- package/test-output/vitest/coverage/src/components/DataGrid/visibility/index.html +116 -0
- package/test-output/vitest/coverage/src/components/DateTimePicker/DateTimePicker.tsx.html +1042 -0
- package/test-output/vitest/coverage/src/components/DateTimePicker/dateTimePicker.variants.ts.html +337 -0
- package/test-output/vitest/coverage/src/components/DateTimePicker/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Dialog/Dialog.tsx.html +391 -0
- package/test-output/vitest/coverage/src/components/Dialog/dialog.variants.ts.html +283 -0
- package/test-output/vitest/coverage/src/components/Dialog/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Divider/Divider.tsx.html +505 -0
- package/test-output/vitest/coverage/src/components/Divider/divider.variants.ts.html +433 -0
- package/test-output/vitest/coverage/src/components/Divider/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Grid/Grid.tsx.html +529 -0
- package/test-output/vitest/coverage/src/components/Grid/grid.variants.ts.html +484 -0
- package/test-output/vitest/coverage/src/components/Grid/index.html +131 -0
- package/test-output/vitest/coverage/src/components/LeftNav/LeftNav.tsx.html +1075 -0
- package/test-output/vitest/coverage/src/components/LeftNav/index.html +131 -0
- package/test-output/vitest/coverage/src/components/LeftNav/leftNav.variants.ts.html +406 -0
- package/test-output/vitest/coverage/src/components/NumberField/NumberField.tsx.html +1048 -0
- package/test-output/vitest/coverage/src/components/NumberField/index.html +131 -0
- package/test-output/vitest/coverage/src/components/NumberField/numberField.variants.ts.html +367 -0
- package/test-output/vitest/coverage/src/components/OTPField/OTPField.tsx.html +835 -0
- package/test-output/vitest/coverage/src/components/OTPField/index.html +131 -0
- package/test-output/vitest/coverage/src/components/OTPField/otpField.variants.ts.html +301 -0
- package/test-output/vitest/coverage/src/components/Pagination/Pagination.tsx.html +916 -0
- package/test-output/vitest/coverage/src/components/Pagination/index.html +146 -0
- package/test-output/vitest/coverage/src/components/Pagination/pagination.helpers.ts.html +391 -0
- package/test-output/vitest/coverage/src/components/Pagination/pagination.variants.ts.html +436 -0
- package/test-output/vitest/coverage/src/components/Popover/Popover.tsx.html +250 -0
- package/test-output/vitest/coverage/src/components/Popover/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Popover/popover.variants.ts.html +157 -0
- package/test-output/vitest/coverage/src/components/RadioGroup/RadioGroup.tsx.html +934 -0
- package/test-output/vitest/coverage/src/components/RadioGroup/index.html +131 -0
- package/test-output/vitest/coverage/src/components/RadioGroup/radioGroup.variants.ts.html +346 -0
- package/test-output/vitest/coverage/src/components/Skeleton/Skeleton.tsx.html +232 -0
- package/test-output/vitest/coverage/src/components/Skeleton/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Skeleton/skeleton.variants.ts.html +346 -0
- package/test-output/vitest/coverage/src/components/Snackbar/Snackbar.tsx.html +979 -0
- package/test-output/vitest/coverage/src/components/Snackbar/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Snackbar/snackbar.variants.ts.html +307 -0
- package/test-output/vitest/coverage/src/components/Stack/Stack.tsx.html +430 -0
- package/test-output/vitest/coverage/src/components/Stack/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Stack/stack.variants.ts.html +325 -0
- package/test-output/vitest/coverage/src/components/Switch/Switch.tsx.html +559 -0
- package/test-output/vitest/coverage/src/components/Switch/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Switch/switch.variants.ts.html +295 -0
- package/test-output/vitest/coverage/src/components/Table/Table.tsx.html +2677 -0
- package/test-output/vitest/coverage/src/components/Table/cells/RenderButton.tsx.html +154 -0
- package/test-output/vitest/coverage/src/components/Table/cells/RenderChip.tsx.html +385 -0
- package/test-output/vitest/coverage/src/components/Table/cells/RenderText.tsx.html +196 -0
- package/test-output/vitest/coverage/src/components/Table/cells/RenderTwoLine.tsx.html +187 -0
- package/test-output/vitest/coverage/src/components/Table/cells/RowActionsMenu.tsx.html +526 -0
- package/test-output/vitest/coverage/src/components/Table/cells/index.html +191 -0
- package/test-output/vitest/coverage/src/components/Table/cells/index.ts.html +127 -0
- package/test-output/vitest/coverage/src/components/Table/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Table/table.variants.ts.html +706 -0
- package/test-output/vitest/coverage/src/components/Tabs/Tabs.tsx.html +283 -0
- package/test-output/vitest/coverage/src/components/Tabs/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Tabs/tabs.variants.ts.html +292 -0
- package/test-output/vitest/coverage/src/components/TextField/TextField.tsx.html +820 -0
- package/test-output/vitest/coverage/src/components/TextField/index.html +131 -0
- package/test-output/vitest/coverage/src/components/TextField/textField.variants.ts.html +400 -0
- package/test-output/vitest/coverage/src/components/Textarea/Textarea.tsx.html +655 -0
- package/test-output/vitest/coverage/src/components/Textarea/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Textarea/textarea.variants.ts.html +340 -0
- package/test-output/vitest/coverage/src/components/Tooltip/Tooltip.tsx.html +295 -0
- package/test-output/vitest/coverage/src/components/Tooltip/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Tooltip/tooltip.variants.ts.html +169 -0
- package/test-output/vitest/coverage/src/components/TopBar/TopBar.tsx.html +283 -0
- package/test-output/vitest/coverage/src/components/TopBar/index.html +131 -0
- package/test-output/vitest/coverage/src/components/TopBar/topBar.variants.ts.html +199 -0
- package/test-output/vitest/coverage/src/components/Typography/Typography.tsx.html +421 -0
- package/test-output/vitest/coverage/src/components/Typography/index.html +131 -0
- package/test-output/vitest/coverage/src/components/Typography/typography.variants.ts.html +436 -0
- package/test-output/vitest/coverage/src/components/VisuallyHidden/VisuallyHidden.tsx.html +262 -0
- package/test-output/vitest/coverage/src/components/VisuallyHidden/index.html +116 -0
- package/test-output/vitest/coverage/src/components/_shared/data/getNestedValue.ts.html +181 -0
- package/test-output/vitest/coverage/src/components/_shared/data/index.html +236 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useColumnAutoDetect.ts.html +385 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useControllableState.ts.html +229 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useDebouncedValue.ts.html +157 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useTableFilter.ts.html +439 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSearch.ts.html +283 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSelection.ts.html +385 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSort.ts.html +508 -0
- package/test-output/vitest/coverage/src/components/_shared/data/useVirtualizer.ts.html +682 -0
- package/test-output/vitest/coverage/src/components/_shared/index.html +116 -0
- package/test-output/vitest/coverage/src/components/_shared/resolveValidationState.ts.html +265 -0
- package/test-output/vitest/coverage/src/hooks/index.html +116 -0
- package/test-output/vitest/coverage/src/hooks/useAccessState.ts.html +328 -0
- package/test-output/vitest/coverage/src/index.html +116 -0
- package/test-output/vitest/coverage/src/index.ts.html +1153 -0
- package/test-output/vitest/coverage/src/utils/cn.ts.html +172 -0
- package/test-output/vitest/coverage/src/utils/index.html +116 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/**
|
|
3
|
+
* Unit tests for the Table cell renderer library — `RenderText`,
|
|
4
|
+
* `RenderTwoLine`, `RenderChip`, `RenderButton`, `RowActionsMenu`.
|
|
5
|
+
*
|
|
6
|
+
* Sprint 6 P4 — these shipped in Sprint 4.1 with only integration
|
|
7
|
+
* coverage (via Table/DataGrid tests). This file exercises them
|
|
8
|
+
* directly, including the RBAC + edge-case branches.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { describe, it, expect, afterEach, beforeAll, vi } from 'vitest';
|
|
12
|
+
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
|
13
|
+
import { RenderText } from './RenderText.js';
|
|
14
|
+
import { RenderTwoLine } from './RenderTwoLine.js';
|
|
15
|
+
import { RenderChip } from './RenderChip.js';
|
|
16
|
+
import { RenderButton } from './RenderButton.js';
|
|
17
|
+
import { RowActionsMenu } from './RowActionsMenu.js';
|
|
18
|
+
|
|
19
|
+
void React;
|
|
20
|
+
afterEach(() => cleanup());
|
|
21
|
+
|
|
22
|
+
beforeAll(() => {
|
|
23
|
+
if (typeof globalThis.ResizeObserver === 'undefined') {
|
|
24
|
+
(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver =
|
|
25
|
+
class {
|
|
26
|
+
observe() {}
|
|
27
|
+
unobserve() {}
|
|
28
|
+
disconnect() {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('RenderText', () => {
|
|
34
|
+
it('renders the value in a span', () => {
|
|
35
|
+
render(<RenderText value="hello" />);
|
|
36
|
+
expect(screen.getByText('hello').tagName).toBe('SPAN');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('applies the truncate class when truncate is set', () => {
|
|
40
|
+
render(<RenderText value="long text" truncate />);
|
|
41
|
+
expect(screen.getByText('long text').className).toContain('truncate');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('applies the muted neutral color when muted is set', () => {
|
|
45
|
+
render(<RenderText value="dim" muted />);
|
|
46
|
+
expect(screen.getByText('dim').className).toContain('text-neutral-500');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('merges a custom className', () => {
|
|
50
|
+
render(<RenderText value="x" className="custom-cls" />);
|
|
51
|
+
expect(screen.getByText('x').className).toContain('custom-cls');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('renders nothing extra when no flags are set', () => {
|
|
55
|
+
render(<RenderText value="plain" />);
|
|
56
|
+
const el = screen.getByText('plain');
|
|
57
|
+
expect(el.className).not.toContain('truncate');
|
|
58
|
+
expect(el.className).not.toContain('text-neutral-500');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('RenderTwoLine', () => {
|
|
63
|
+
it('renders both primary and secondary text', () => {
|
|
64
|
+
render(<RenderTwoLine primary="Jane Doe" secondary="jane@example.com" />);
|
|
65
|
+
expect(screen.getByText('Jane Doe')).not.toBeNull();
|
|
66
|
+
expect(screen.getByText('jane@example.com')).not.toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('primary is font-medium, secondary is muted + smaller', () => {
|
|
70
|
+
render(<RenderTwoLine primary="P" secondary="S" />);
|
|
71
|
+
expect(screen.getByText('P').className).toContain('font-medium');
|
|
72
|
+
expect(screen.getByText('S').className).toContain('text-neutral-500');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('merges a custom className on the wrapper', () => {
|
|
76
|
+
const { container } = render(
|
|
77
|
+
<RenderTwoLine primary="P" secondary="S" className="twoline-cls" />,
|
|
78
|
+
);
|
|
79
|
+
expect(container.firstElementChild?.className).toContain('twoline-cls');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('RenderChip', () => {
|
|
84
|
+
it('renders children', () => {
|
|
85
|
+
render(<RenderChip>active</RenderChip>);
|
|
86
|
+
expect(screen.getByText('active')).not.toBeNull();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('defaults to soft + neutral + sm', () => {
|
|
90
|
+
render(<RenderChip>x</RenderChip>);
|
|
91
|
+
// soft neutral → bg-neutral-100
|
|
92
|
+
expect(screen.getByText('x').className).toContain('bg-neutral-100');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it.each(['primary', 'success', 'warning', 'danger', 'info', 'secondary'] as const)(
|
|
96
|
+
'renders soft variant for the %s intent',
|
|
97
|
+
(color) => {
|
|
98
|
+
render(<RenderChip color={color}>{color}</RenderChip>);
|
|
99
|
+
expect(screen.getByText(color).className).toContain(`bg-${color}-100`);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
it('renders the solid variant', () => {
|
|
104
|
+
render(
|
|
105
|
+
<RenderChip variant="solid" color="primary">
|
|
106
|
+
solid
|
|
107
|
+
</RenderChip>,
|
|
108
|
+
);
|
|
109
|
+
expect(screen.getByText('solid').className).toContain('bg-primary-500');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('renders the outline variant', () => {
|
|
113
|
+
render(
|
|
114
|
+
<RenderChip variant="outline" color="danger">
|
|
115
|
+
outline
|
|
116
|
+
</RenderChip>,
|
|
117
|
+
);
|
|
118
|
+
expect(screen.getByText('outline').className).toContain('border-danger-500');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('renders the md size', () => {
|
|
122
|
+
render(
|
|
123
|
+
<RenderChip size="md">md</RenderChip>,
|
|
124
|
+
);
|
|
125
|
+
expect(screen.getByText('md').className).toContain('h-6');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('merges a custom className', () => {
|
|
129
|
+
render(<RenderChip className="chip-cls">x</RenderChip>);
|
|
130
|
+
expect(screen.getByText('x').className).toContain('chip-cls');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('RenderButton', () => {
|
|
135
|
+
it('renders the label inside a button', () => {
|
|
136
|
+
render(<RenderButton label="Edit" />);
|
|
137
|
+
expect(screen.getByRole('button', { name: 'Edit' })).not.toBeNull();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('fires onClick when clicked', () => {
|
|
141
|
+
const onClick = vi.fn();
|
|
142
|
+
render(<RenderButton label="Go" onClick={onClick} />);
|
|
143
|
+
fireEvent.click(screen.getByRole('button', { name: 'Go' }));
|
|
144
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('honors the disabled prop', () => {
|
|
148
|
+
const onClick = vi.fn();
|
|
149
|
+
render(<RenderButton label="Nope" onClick={onClick} disabled />);
|
|
150
|
+
const btn = screen.getByRole('button', { name: 'Nope' }) as HTMLButtonElement;
|
|
151
|
+
expect(btn.disabled).toBe(true);
|
|
152
|
+
fireEvent.click(btn);
|
|
153
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('RowActionsMenu', () => {
|
|
158
|
+
interface Row {
|
|
159
|
+
id: string;
|
|
160
|
+
}
|
|
161
|
+
const row: Row = { id: 'r1' };
|
|
162
|
+
|
|
163
|
+
it('renders the default 3-dot trigger', () => {
|
|
164
|
+
render(
|
|
165
|
+
<RowActionsMenu
|
|
166
|
+
row={row}
|
|
167
|
+
actions={[{ label: 'Edit', onClick: () => {} }]}
|
|
168
|
+
/>,
|
|
169
|
+
);
|
|
170
|
+
expect(screen.getByRole('button', { name: 'Row actions' })).not.toBeNull();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('returns null when there are no visible actions', () => {
|
|
174
|
+
const { container } = render(
|
|
175
|
+
<RowActionsMenu row={row} actions={[]} />,
|
|
176
|
+
);
|
|
177
|
+
expect(container.innerHTML).toBe('');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('opens the menu and renders the action items', () => {
|
|
181
|
+
render(
|
|
182
|
+
<RowActionsMenu
|
|
183
|
+
row={row}
|
|
184
|
+
actions={[
|
|
185
|
+
{ label: 'Edit', onClick: () => {} },
|
|
186
|
+
{ label: 'Delete', onClick: () => {}, color: 'danger' },
|
|
187
|
+
]}
|
|
188
|
+
/>,
|
|
189
|
+
);
|
|
190
|
+
fireEvent.click(screen.getByRole('button', { name: 'Row actions' }));
|
|
191
|
+
expect(screen.getByRole('menuitem', { name: 'Edit' })).not.toBeNull();
|
|
192
|
+
expect(screen.getByRole('menuitem', { name: 'Delete' })).not.toBeNull();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('invokes the action onClick with the row', () => {
|
|
196
|
+
const onClick = vi.fn();
|
|
197
|
+
render(
|
|
198
|
+
<RowActionsMenu row={row} actions={[{ label: 'Edit', onClick }]} />,
|
|
199
|
+
);
|
|
200
|
+
fireEvent.click(screen.getByRole('button', { name: 'Row actions' }));
|
|
201
|
+
fireEvent.click(screen.getByRole('menuitem', { name: 'Edit' }));
|
|
202
|
+
expect(onClick).toHaveBeenCalledWith(row);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('filters out actions whose RBAC says hide', () => {
|
|
206
|
+
render(
|
|
207
|
+
<RowActionsMenu
|
|
208
|
+
row={row}
|
|
209
|
+
actions={[
|
|
210
|
+
{ label: 'Edit', onClick: () => {} },
|
|
211
|
+
{
|
|
212
|
+
label: 'SecretDelete',
|
|
213
|
+
onClick: () => {},
|
|
214
|
+
access: { onUnauthorized: 'hide' },
|
|
215
|
+
},
|
|
216
|
+
]}
|
|
217
|
+
/>,
|
|
218
|
+
);
|
|
219
|
+
fireEvent.click(screen.getByRole('button', { name: 'Row actions' }));
|
|
220
|
+
expect(screen.queryByRole('menuitem', { name: 'Edit' })).not.toBeNull();
|
|
221
|
+
expect(screen.queryByRole('menuitem', { name: 'SecretDelete' })).toBeNull();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('renders a disabled action item when action.disabled is set', () => {
|
|
225
|
+
render(
|
|
226
|
+
<RowActionsMenu
|
|
227
|
+
row={row}
|
|
228
|
+
actions={[{ label: 'Edit', onClick: () => {}, disabled: true }]}
|
|
229
|
+
/>,
|
|
230
|
+
);
|
|
231
|
+
fireEvent.click(screen.getByRole('button', { name: 'Row actions' }));
|
|
232
|
+
const item = screen.getByRole('menuitem', { name: 'Edit' }) as HTMLButtonElement;
|
|
233
|
+
expect(item.disabled).toBe(true);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('uses a custom trigger when provided', () => {
|
|
237
|
+
render(
|
|
238
|
+
<RowActionsMenu
|
|
239
|
+
row={row}
|
|
240
|
+
actions={[{ label: 'Edit', onClick: () => {} }]}
|
|
241
|
+
trigger={<button type="button">custom-trigger</button>}
|
|
242
|
+
/>,
|
|
243
|
+
);
|
|
244
|
+
expect(screen.getByRole('button', { name: 'custom-trigger' })).not.toBeNull();
|
|
245
|
+
expect(screen.queryByRole('button', { name: 'Row actions' })).toBeNull();
|
|
246
|
+
});
|
|
247
|
+
});
|
|
@@ -258,7 +258,14 @@ export type TableRowSelectionMode = 'none' | 'single' | 'multiple';
|
|
|
258
258
|
*/
|
|
259
259
|
export interface TableLabels {
|
|
260
260
|
searchPlaceholder?: string;
|
|
261
|
+
/** Shown when the dataset itself is empty (0 input rows). */
|
|
261
262
|
noData?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Shown when the dataset has rows but an active search / filter
|
|
265
|
+
* excluded them all. Distinct from `noData` so the user can tell
|
|
266
|
+
* "nothing here" from "nothing matches your query".
|
|
267
|
+
*/
|
|
268
|
+
noResults?: string;
|
|
262
269
|
loading?: string;
|
|
263
270
|
ariaSortNone?: string;
|
|
264
271
|
ariaSortAscending?: string;
|
|
@@ -291,8 +298,8 @@ export interface TableLabels {
|
|
|
291
298
|
/** Column visibility menu (Popover-based, auto-commit). */
|
|
292
299
|
columnsButton?: string;
|
|
293
300
|
columnsTitle?: string;
|
|
294
|
-
|
|
295
|
-
|
|
301
|
+
/** Aria-label for the tri-state show/hide-all master checkbox. */
|
|
302
|
+
columnsToggleAll?: string;
|
|
296
303
|
}
|
|
297
304
|
|
|
298
305
|
// ───── Slot props ─────
|
|
@@ -353,7 +360,25 @@ export interface TableProps<T extends object>
|
|
|
353
360
|
// ───── Data ─────
|
|
354
361
|
rows: T[];
|
|
355
362
|
cols: TableColumn<T>[];
|
|
356
|
-
/**
|
|
363
|
+
/**
|
|
364
|
+
* Stable row-id resolver — the React key + the identity used by
|
|
365
|
+
* selection and row-expansion state.
|
|
366
|
+
*
|
|
367
|
+
* **Strongly recommended whenever sort / search / selection /
|
|
368
|
+
* expandable rows are used.** The default falls back to the
|
|
369
|
+
* positional index (`String(index)`); once rows reorder (sort) or
|
|
370
|
+
* change presence (search / filter), index `2` points at a
|
|
371
|
+
* *different* row, so selection and expansion state silently jump
|
|
372
|
+
* to the wrong rows. Pass a value derived from the data itself:
|
|
373
|
+
*
|
|
374
|
+
* ```tsx
|
|
375
|
+
* <Table getRowId={(row) => row.id} … />
|
|
376
|
+
* ```
|
|
377
|
+
*
|
|
378
|
+
* Dashforge emits a `console.warn` in development when `getRowId`
|
|
379
|
+
* is omitted and one of those features is active. (`<DataGrid>`
|
|
380
|
+
* makes this prop required for the same reason.)
|
|
381
|
+
*/
|
|
357
382
|
getRowId?: (row: T, index: number) => string;
|
|
358
383
|
|
|
359
384
|
// ───── Sort ─────
|
|
@@ -84,6 +84,21 @@ describe('<Typography>', () => {
|
|
|
84
84
|
const { container } = render(<Typography color="inherit">x</Typography>);
|
|
85
85
|
expect(container.firstElementChild?.className).toContain('text-inherit');
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
it('defaults to color="neutral" (text-neutral-900, NOT text-inherit)', () => {
|
|
89
|
+
// Sprint 6 P5 fix — a bare <Typography> must emit the
|
|
90
|
+
// auto-inverting neutral token, not inherit the consumer's
|
|
91
|
+
// arbitrary root colour (which broke dark-mode consistency).
|
|
92
|
+
const { container } = render(<Typography>x</Typography>);
|
|
93
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
94
|
+
expect(cls).toContain('text-neutral-900');
|
|
95
|
+
expect(cls).not.toContain('text-inherit');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('color="muted" emits text-neutral-600', () => {
|
|
99
|
+
const { container } = render(<Typography color="muted">x</Typography>);
|
|
100
|
+
expect(container.firstElementChild?.className).toContain('text-neutral-600');
|
|
101
|
+
});
|
|
87
102
|
});
|
|
88
103
|
|
|
89
104
|
// ─── Override semantics ─────────────────────────────────────────────
|
|
@@ -55,6 +55,15 @@ export const typographyVariants = tv({
|
|
|
55
55
|
* paints white text).
|
|
56
56
|
*/
|
|
57
57
|
color: {
|
|
58
|
+
// `inherit` is the explicit escape hatch — use it on a
|
|
59
|
+
// `<Typography>` inside a coloured surface (e.g.
|
|
60
|
+
// `<Box variant="solid" color="primary">` paints white text)
|
|
61
|
+
// so the text picks up the surface colour. It is NO LONGER the
|
|
62
|
+
// default: a bare `<Typography>` would otherwise inherit the
|
|
63
|
+
// consuming app's arbitrary root colour (often OS-`prefers-
|
|
64
|
+
// color-scheme` driven), which diverges from the Dashforge
|
|
65
|
+
// `data-dash-tw-theme` mode and breaks colour consistency in
|
|
66
|
+
// dark mode. The default is now `neutral` — see `defaultVariants`.
|
|
58
67
|
inherit: 'text-inherit',
|
|
59
68
|
primary: 'text-primary-700 dark:text-primary-400',
|
|
60
69
|
secondary: 'text-secondary-700 dark:text-secondary-400',
|
|
@@ -109,7 +118,11 @@ export const typographyVariants = tv({
|
|
|
109
118
|
|
|
110
119
|
defaultVariants: {
|
|
111
120
|
variant: 'body1',
|
|
112
|
-
|
|
121
|
+
// `neutral` (not `inherit`): a bare `<Typography>` emits
|
|
122
|
+
// `text-neutral-900`, which auto-inverts via the dashforgePreset()
|
|
123
|
+
// CSS-var swap and follows the Dashforge mode. Pass
|
|
124
|
+
// `color="inherit"` explicitly inside a coloured surface.
|
|
125
|
+
color: 'neutral',
|
|
113
126
|
align: 'left',
|
|
114
127
|
},
|
|
115
128
|
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
body, html {
|
|
2
|
+
margin:0; padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
body {
|
|
6
|
+
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
color:#333;
|
|
9
|
+
}
|
|
10
|
+
.small { font-size: 12px; }
|
|
11
|
+
*, *:after, *:before {
|
|
12
|
+
-webkit-box-sizing:border-box;
|
|
13
|
+
-moz-box-sizing:border-box;
|
|
14
|
+
box-sizing:border-box;
|
|
15
|
+
}
|
|
16
|
+
h1 { font-size: 20px; margin: 0;}
|
|
17
|
+
h2 { font-size: 14px; }
|
|
18
|
+
pre {
|
|
19
|
+
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
-moz-tab-size: 2;
|
|
23
|
+
-o-tab-size: 2;
|
|
24
|
+
tab-size: 2;
|
|
25
|
+
}
|
|
26
|
+
a { color:#0074D9; text-decoration:none; }
|
|
27
|
+
a:hover { text-decoration:underline; }
|
|
28
|
+
.strong { font-weight: bold; }
|
|
29
|
+
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
+
.pad2y { padding: 20px 0; }
|
|
31
|
+
.pad1y { padding: 10px 0; }
|
|
32
|
+
.pad2x { padding: 0 20px; }
|
|
33
|
+
.pad2 { padding: 20px; }
|
|
34
|
+
.pad1 { padding: 10px; }
|
|
35
|
+
.space-left2 { padding-left:55px; }
|
|
36
|
+
.space-right2 { padding-right:20px; }
|
|
37
|
+
.center { text-align:center; }
|
|
38
|
+
.clearfix { display:block; }
|
|
39
|
+
.clearfix:after {
|
|
40
|
+
content:'';
|
|
41
|
+
display:block;
|
|
42
|
+
height:0;
|
|
43
|
+
clear:both;
|
|
44
|
+
visibility:hidden;
|
|
45
|
+
}
|
|
46
|
+
.fl { float: left; }
|
|
47
|
+
@media only screen and (max-width:640px) {
|
|
48
|
+
.col3 { width:100%; max-width:100%; }
|
|
49
|
+
.hide-mobile { display:none!important; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.quiet {
|
|
53
|
+
color: #7f7f7f;
|
|
54
|
+
color: rgba(0,0,0,0.5);
|
|
55
|
+
}
|
|
56
|
+
.quiet a { opacity: 0.7; }
|
|
57
|
+
|
|
58
|
+
.fraction {
|
|
59
|
+
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
color: #555;
|
|
62
|
+
background: #E8E8E8;
|
|
63
|
+
padding: 4px 5px;
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
+
table.coverage {
|
|
70
|
+
border-collapse: collapse;
|
|
71
|
+
margin: 10px 0 0 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
table.coverage td {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
vertical-align: top;
|
|
79
|
+
}
|
|
80
|
+
table.coverage td.line-count {
|
|
81
|
+
text-align: right;
|
|
82
|
+
padding: 0 5px 0 20px;
|
|
83
|
+
}
|
|
84
|
+
table.coverage td.line-coverage {
|
|
85
|
+
text-align: right;
|
|
86
|
+
padding-right: 10px;
|
|
87
|
+
min-width:20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
table.coverage td span.cline-any {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
padding: 0 5px;
|
|
93
|
+
width: 100%;
|
|
94
|
+
}
|
|
95
|
+
.missing-if-branch {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
margin-right: 5px;
|
|
98
|
+
border-radius: 3px;
|
|
99
|
+
position: relative;
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
background: #333;
|
|
102
|
+
color: yellow;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.skip-if-branch {
|
|
106
|
+
display: none;
|
|
107
|
+
margin-right: 10px;
|
|
108
|
+
position: relative;
|
|
109
|
+
padding: 0 4px;
|
|
110
|
+
background: #ccc;
|
|
111
|
+
color: white;
|
|
112
|
+
}
|
|
113
|
+
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
+
color: inherit !important;
|
|
115
|
+
}
|
|
116
|
+
.coverage-summary {
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
+
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
+
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
+
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
+
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
+
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
+
.coverage-summary th {
|
|
127
|
+
text-align: left;
|
|
128
|
+
font-weight: normal;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
+
.coverage-summary th.pct { }
|
|
133
|
+
.coverage-summary th.pic,
|
|
134
|
+
.coverage-summary th.abs,
|
|
135
|
+
.coverage-summary td.pct,
|
|
136
|
+
.coverage-summary td.abs { text-align: right; }
|
|
137
|
+
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
+
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
+
.coverage-summary tfoot td { }
|
|
140
|
+
|
|
141
|
+
.coverage-summary .sorter {
|
|
142
|
+
height: 10px;
|
|
143
|
+
width: 7px;
|
|
144
|
+
display: inline-block;
|
|
145
|
+
margin-left: 0.5em;
|
|
146
|
+
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
+
}
|
|
148
|
+
.coverage-summary .sorted .sorter {
|
|
149
|
+
background-position: 0 -20px;
|
|
150
|
+
}
|
|
151
|
+
.coverage-summary .sorted-desc .sorter {
|
|
152
|
+
background-position: 0 -10px;
|
|
153
|
+
}
|
|
154
|
+
.status-line { height: 10px; }
|
|
155
|
+
/* yellow */
|
|
156
|
+
.cbranch-no { background: yellow !important; color: #111; }
|
|
157
|
+
/* dark red */
|
|
158
|
+
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
159
|
+
.low .chart { border:1px solid #C21F39 }
|
|
160
|
+
.highlighted,
|
|
161
|
+
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
|
162
|
+
background: #C21F39 !important;
|
|
163
|
+
}
|
|
164
|
+
/* medium red */
|
|
165
|
+
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
166
|
+
/* light red */
|
|
167
|
+
.low, .cline-no { background:#FCE1E5 }
|
|
168
|
+
/* light green */
|
|
169
|
+
.high, .cline-yes { background:rgb(230,245,208) }
|
|
170
|
+
/* medium green */
|
|
171
|
+
.cstat-yes { background:rgb(161,215,106) }
|
|
172
|
+
/* dark green */
|
|
173
|
+
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
174
|
+
.high .chart { border:1px solid rgb(77,146,33) }
|
|
175
|
+
/* dark yellow (gold) */
|
|
176
|
+
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
177
|
+
.medium .chart { border:1px solid #f9cd0b; }
|
|
178
|
+
/* light yellow */
|
|
179
|
+
.medium { background: #fff4c2; }
|
|
180
|
+
|
|
181
|
+
.cstat-skip { background: #ddd; color: #111; }
|
|
182
|
+
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
183
|
+
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
184
|
+
|
|
185
|
+
span.cline-neutral { background: #eaeaea; }
|
|
186
|
+
|
|
187
|
+
.coverage-summary td.empty {
|
|
188
|
+
opacity: .5;
|
|
189
|
+
padding-top: 4px;
|
|
190
|
+
padding-bottom: 4px;
|
|
191
|
+
line-height: 1;
|
|
192
|
+
color: #888;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cover-fill, .cover-empty {
|
|
196
|
+
display:inline-block;
|
|
197
|
+
height: 12px;
|
|
198
|
+
}
|
|
199
|
+
.chart {
|
|
200
|
+
line-height: 0;
|
|
201
|
+
}
|
|
202
|
+
.cover-empty {
|
|
203
|
+
background: white;
|
|
204
|
+
}
|
|
205
|
+
.cover-full {
|
|
206
|
+
border-right: none !important;
|
|
207
|
+
}
|
|
208
|
+
pre.prettyprint {
|
|
209
|
+
border: none !important;
|
|
210
|
+
padding: 0 !important;
|
|
211
|
+
margin: 0 !important;
|
|
212
|
+
}
|
|
213
|
+
.com { color: #999 !important; }
|
|
214
|
+
.ignore-none { color: #999; font-weight: normal; }
|
|
215
|
+
|
|
216
|
+
.wrapper {
|
|
217
|
+
min-height: 100%;
|
|
218
|
+
height: auto !important;
|
|
219
|
+
height: 100%;
|
|
220
|
+
margin: 0 auto -48px;
|
|
221
|
+
}
|
|
222
|
+
.footer, .push {
|
|
223
|
+
height: 48px;
|
|
224
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var jumpToCode = (function init() {
|
|
3
|
+
// Classes of code we would like to highlight in the file view
|
|
4
|
+
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
5
|
+
|
|
6
|
+
// Elements to highlight in the file listing view
|
|
7
|
+
var fileListingElements = ['td.pct.low'];
|
|
8
|
+
|
|
9
|
+
// We don't want to select elements that are direct descendants of another match
|
|
10
|
+
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
|
11
|
+
|
|
12
|
+
// Selector that finds elements on the page to which we can jump
|
|
13
|
+
var selector =
|
|
14
|
+
fileListingElements.join(', ') +
|
|
15
|
+
', ' +
|
|
16
|
+
notSelector +
|
|
17
|
+
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
|
18
|
+
|
|
19
|
+
// The NodeList of matching elements
|
|
20
|
+
var missingCoverageElements = document.querySelectorAll(selector);
|
|
21
|
+
|
|
22
|
+
var currentIndex;
|
|
23
|
+
|
|
24
|
+
function toggleClass(index) {
|
|
25
|
+
missingCoverageElements
|
|
26
|
+
.item(currentIndex)
|
|
27
|
+
.classList.remove('highlighted');
|
|
28
|
+
missingCoverageElements.item(index).classList.add('highlighted');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeCurrent(index) {
|
|
32
|
+
toggleClass(index);
|
|
33
|
+
currentIndex = index;
|
|
34
|
+
missingCoverageElements.item(index).scrollIntoView({
|
|
35
|
+
behavior: 'smooth',
|
|
36
|
+
block: 'center',
|
|
37
|
+
inline: 'center'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function goToPrevious() {
|
|
42
|
+
var nextIndex = 0;
|
|
43
|
+
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
|
44
|
+
nextIndex = missingCoverageElements.length - 1;
|
|
45
|
+
} else if (missingCoverageElements.length > 1) {
|
|
46
|
+
nextIndex = currentIndex - 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
makeCurrent(nextIndex);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function goToNext() {
|
|
53
|
+
var nextIndex = 0;
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
typeof currentIndex === 'number' &&
|
|
57
|
+
currentIndex < missingCoverageElements.length - 1
|
|
58
|
+
) {
|
|
59
|
+
nextIndex = currentIndex + 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
makeCurrent(nextIndex);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return function jump(event) {
|
|
66
|
+
if (
|
|
67
|
+
document.getElementById('fileSearch') === document.activeElement &&
|
|
68
|
+
document.activeElement != null
|
|
69
|
+
) {
|
|
70
|
+
// if we're currently focused on the search input, we don't want to navigate
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
switch (event.which) {
|
|
75
|
+
case 78: // n
|
|
76
|
+
case 74: // j
|
|
77
|
+
goToNext();
|
|
78
|
+
break;
|
|
79
|
+
case 66: // b
|
|
80
|
+
case 75: // k
|
|
81
|
+
case 80: // p
|
|
82
|
+
goToPrevious();
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
87
|
+
window.addEventListener('keydown', jumpToCode);
|