@patternfly/react-data-view 6.4.0 → 6.5.0-prerelease.2
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/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.d.ts +2 -0
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.js +3 -2
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.test.d.ts +1 -1
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.test.js +8 -2
- package/dist/cjs/DataViewTable/DataViewTable.d.ts +2 -1
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +11 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +46 -6
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +47 -9
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.d.ts +4 -0
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.js +31 -2
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.test.d.ts +1 -1
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.test.js +88 -0
- package/dist/cjs/DataViewTh/DataViewTh.d.ts +4 -4
- package/dist/cjs/DataViewTh/DataViewTh.js +8 -1
- package/dist/cjs/DataViewTh/index.d.ts +2 -0
- package/dist/cjs/DataViewTh/index.js +23 -0
- package/dist/cjs/DataViewToolbar/DataViewToolbar.js +13 -1
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.d.ts +28 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.js +230 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.js +176 -0
- package/dist/cjs/DataViewTreeFilter/index.d.ts +2 -0
- package/dist/cjs/DataViewTreeFilter/index.js +23 -0
- package/dist/cjs/Hooks/selection.d.ts +8 -8
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +10 -1
- package/dist/dynamic/DataViewTh/package.json +1 -0
- package/dist/dynamic/DataViewTreeFilter/package.json +1 -0
- package/dist/dynamic-modules.json +62 -0
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.d.ts +2 -0
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.js +3 -2
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.test.d.ts +1 -1
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.test.js +9 -3
- package/dist/esm/DataViewTable/DataViewTable.d.ts +2 -1
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +11 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +48 -8
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +45 -10
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.d.ts +4 -0
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.js +31 -2
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.test.d.ts +1 -1
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.test.js +90 -2
- package/dist/esm/DataViewTh/DataViewTh.d.ts +4 -4
- package/dist/esm/DataViewTh/DataViewTh.js +8 -1
- package/dist/esm/DataViewTh/index.d.ts +2 -0
- package/dist/esm/DataViewTh/index.js +2 -0
- package/dist/esm/DataViewToolbar/DataViewToolbar.js +13 -1
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.d.ts +28 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.js +226 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.js +171 -0
- package/dist/esm/DataViewTreeFilter/index.d.ts +2 -0
- package/dist/esm/DataViewTreeFilter/index.js +2 -0
- package/dist/esm/Hooks/selection.d.ts +8 -8
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generate-fed-package-json.js +18 -0
- package/generate-index.js +2 -2
- package/package.json +6 -6
- package/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md +10 -4
- package/patternfly-docs/content/extensions/data-view/examples/DataView/PredefinedLayoutFullExample.tsx +2 -1
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableExpandableExample.tsx +108 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableInteractiveExample.tsx +148 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableStickyExample.tsx +90 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +63 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/FiltersExample.tsx +3 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/PaginationExample.tsx +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +9 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/TreeFilterExample.tsx +248 -0
- package/patternfly-docs/patternfly-docs.config.js +4 -1
- package/src/DataViewCheckboxFilter/DataViewCheckboxFilter.test.tsx +16 -7
- package/src/DataViewCheckboxFilter/DataViewCheckboxFilter.tsx +5 -1
- package/src/DataViewTable/DataViewTable.tsx +3 -1
- package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +7 -7
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +54 -12
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +101 -10
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +10 -10
- package/src/DataViewTextFilter/DataViewTextFilter.test.tsx +140 -1
- package/src/DataViewTextFilter/DataViewTextFilter.tsx +63 -22
- package/src/DataViewTh/DataViewTh.tsx +15 -7
- package/src/DataViewTh/index.ts +2 -0
- package/src/DataViewToolbar/DataViewToolbar.tsx +17 -2
- package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +288 -280
- package/src/DataViewTreeFilter/DataViewTreeFilter.test.tsx +233 -0
- package/src/DataViewTreeFilter/DataViewTreeFilter.tsx +365 -0
- package/src/DataViewTreeFilter/__snapshots__/DataViewTreeFilter.test.tsx.snap +199 -0
- package/src/DataViewTreeFilter/index.ts +2 -0
- package/src/Hooks/selection.ts +8 -8
- package/src/index.ts +9 -0
|
@@ -4,7 +4,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
4
4
|
<div>
|
|
5
5
|
<table
|
|
6
6
|
aria-label="Repositories table"
|
|
7
|
-
class="pf-v6-c-table pf-m-grid-md"
|
|
7
|
+
class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
|
|
8
8
|
data-ouia-component-id="TableExample"
|
|
9
9
|
data-ouia-component-type="PF6/Table"
|
|
10
10
|
data-ouia-safe="true"
|
|
@@ -67,7 +67,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
67
67
|
role="rowgroup"
|
|
68
68
|
>
|
|
69
69
|
<tr
|
|
70
|
-
class="pf-v6-c-table__tr"
|
|
70
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
71
71
|
data-ouia-component-id="TableExample-tr-0"
|
|
72
72
|
data-ouia-component-type="PF6/TableRow"
|
|
73
73
|
data-ouia-safe="true"
|
|
@@ -109,7 +109,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
109
109
|
</td>
|
|
110
110
|
</tr>
|
|
111
111
|
<tr
|
|
112
|
-
class="pf-v6-c-table__tr"
|
|
112
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
113
113
|
data-ouia-component-id="TableExample-tr-1"
|
|
114
114
|
data-ouia-component-type="PF6/TableRow"
|
|
115
115
|
data-ouia-safe="true"
|
|
@@ -151,7 +151,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
151
151
|
</td>
|
|
152
152
|
</tr>
|
|
153
153
|
<tr
|
|
154
|
-
class="pf-v6-c-table__tr"
|
|
154
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
155
155
|
data-ouia-component-id="TableExample-tr-2"
|
|
156
156
|
data-ouia-component-type="PF6/TableRow"
|
|
157
157
|
data-ouia-safe="true"
|
|
@@ -193,7 +193,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
193
193
|
</td>
|
|
194
194
|
</tr>
|
|
195
195
|
<tr
|
|
196
|
-
class="pf-v6-c-table__tr"
|
|
196
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
197
197
|
data-ouia-component-id="TableExample-tr-3"
|
|
198
198
|
data-ouia-component-type="PF6/TableRow"
|
|
199
199
|
data-ouia-safe="true"
|
|
@@ -235,7 +235,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
235
235
|
</td>
|
|
236
236
|
</tr>
|
|
237
237
|
<tr
|
|
238
|
-
class="pf-v6-c-table__tr"
|
|
238
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
239
239
|
data-ouia-component-id="TableExample-tr-4"
|
|
240
240
|
data-ouia-component-type="PF6/TableRow"
|
|
241
241
|
data-ouia-safe="true"
|
|
@@ -277,7 +277,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
277
277
|
</td>
|
|
278
278
|
</tr>
|
|
279
279
|
<tr
|
|
280
|
-
class="pf-v6-c-table__tr"
|
|
280
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
281
281
|
data-ouia-component-id="TableExample-tr-5"
|
|
282
282
|
data-ouia-component-type="PF6/TableRow"
|
|
283
283
|
data-ouia-safe="true"
|
|
@@ -335,7 +335,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
|
|
|
335
335
|
>
|
|
336
336
|
<table
|
|
337
337
|
aria-label="Repositories table"
|
|
338
|
-
class="pf-v6-c-table pf-m-grid-md"
|
|
338
|
+
class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
|
|
339
339
|
data-ouia-component-id="TableExample"
|
|
340
340
|
data-ouia-component-type="PF6/Table"
|
|
341
341
|
data-ouia-safe="true"
|
|
@@ -412,7 +412,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
|
|
|
412
412
|
>
|
|
413
413
|
<table
|
|
414
414
|
aria-label="Repositories table"
|
|
415
|
-
class="pf-v6-c-table pf-m-grid-md"
|
|
415
|
+
class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
|
|
416
416
|
data-ouia-component-id="TableExample"
|
|
417
417
|
data-ouia-component-type="PF6/Table"
|
|
418
418
|
data-ouia-safe="true"
|
|
@@ -489,7 +489,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
|
|
|
489
489
|
>
|
|
490
490
|
<table
|
|
491
491
|
aria-label="Repositories table"
|
|
492
|
-
class="pf-v6-c-table pf-m-grid-md"
|
|
492
|
+
class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
|
|
493
493
|
data-ouia-component-id="TableExample"
|
|
494
494
|
data-ouia-component-type="PF6/Table"
|
|
495
495
|
data-ouia-safe="true"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
2
3
|
import DataViewTextFilter, { DataViewTextFilterProps } from './DataViewTextFilter';
|
|
3
4
|
import DataViewToolbar from '../DataViewToolbar';
|
|
4
5
|
|
|
@@ -20,4 +21,142 @@ describe('DataViewTextFilter component', () => {
|
|
|
20
21
|
/>);
|
|
21
22
|
expect(container).toMatchSnapshot();
|
|
22
23
|
});
|
|
24
|
+
|
|
25
|
+
it('should use chipTitle for the filter chip category when provided', () => {
|
|
26
|
+
render(<DataViewToolbar
|
|
27
|
+
filters={
|
|
28
|
+
<DataViewTextFilter {...defaultProps} chipTitle="Short name" />
|
|
29
|
+
}
|
|
30
|
+
/>);
|
|
31
|
+
expect(screen.getByText('Short name')).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByPlaceholderText('Filter by Test Filter')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should focus the search input when "/" key is pressed and filter is visible', () => {
|
|
36
|
+
render(<DataViewToolbar
|
|
37
|
+
filters={
|
|
38
|
+
<DataViewTextFilter {...defaultProps} showToolbarItem={true} />
|
|
39
|
+
}
|
|
40
|
+
/>);
|
|
41
|
+
|
|
42
|
+
const input = document.getElementById('test-filter') as HTMLInputElement;
|
|
43
|
+
expect(input).toBeInTheDocument();
|
|
44
|
+
|
|
45
|
+
// Simulate pressing "/" key by creating and dispatching a KeyboardEvent
|
|
46
|
+
const keyEvent = new KeyboardEvent('keydown', {
|
|
47
|
+
key: '/',
|
|
48
|
+
code: 'Slash',
|
|
49
|
+
bubbles: true,
|
|
50
|
+
cancelable: true,
|
|
51
|
+
});
|
|
52
|
+
window.dispatchEvent(keyEvent);
|
|
53
|
+
|
|
54
|
+
// Check that the input has focus
|
|
55
|
+
expect(document.activeElement).toBe(input);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should not focus the search input when "/" key is pressed if filter is not visible', () => {
|
|
59
|
+
render(<DataViewToolbar
|
|
60
|
+
filters={
|
|
61
|
+
<DataViewTextFilter {...defaultProps} showToolbarItem={false} />
|
|
62
|
+
}
|
|
63
|
+
/>);
|
|
64
|
+
|
|
65
|
+
const input = document.getElementById('test-filter') as HTMLInputElement;
|
|
66
|
+
|
|
67
|
+
// Simulate pressing "/" key
|
|
68
|
+
const keyEvent = new KeyboardEvent('keydown', {
|
|
69
|
+
key: '/',
|
|
70
|
+
code: 'Slash',
|
|
71
|
+
bubbles: true,
|
|
72
|
+
cancelable: true,
|
|
73
|
+
});
|
|
74
|
+
window.dispatchEvent(keyEvent);
|
|
75
|
+
|
|
76
|
+
if (input) {
|
|
77
|
+
expect(document.activeElement).not.toBe(input);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should not focus the search input when "/" key is pressed while typing in another input', () => {
|
|
82
|
+
const { container } = render(
|
|
83
|
+
<div>
|
|
84
|
+
<input data-testid="other-input" />
|
|
85
|
+
<DataViewToolbar
|
|
86
|
+
filters={
|
|
87
|
+
<DataViewTextFilter {...defaultProps} showToolbarItem={true} />
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const otherInput = container.querySelector('[data-testid="other-input"]') as HTMLInputElement;
|
|
94
|
+
|
|
95
|
+
// Focus the other input first
|
|
96
|
+
otherInput.focus();
|
|
97
|
+
expect(document.activeElement).toBe(otherInput);
|
|
98
|
+
|
|
99
|
+
// Simulate pressing "/" key while focused on the other input
|
|
100
|
+
// The event target should be the input element
|
|
101
|
+
const keyEvent = new KeyboardEvent('keydown', {
|
|
102
|
+
key: '/',
|
|
103
|
+
code: 'Slash',
|
|
104
|
+
bubbles: true,
|
|
105
|
+
cancelable: true,
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(keyEvent, 'target', {
|
|
108
|
+
value: otherInput,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
});
|
|
111
|
+
window.dispatchEvent(keyEvent);
|
|
112
|
+
|
|
113
|
+
// The search input should not be focused since we're already in an input field
|
|
114
|
+
expect(document.activeElement).toBe(otherInput);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should not focus the search input when enableShortcut is false', () => {
|
|
118
|
+
render(<DataViewToolbar
|
|
119
|
+
filters={
|
|
120
|
+
<DataViewTextFilter {...defaultProps} showToolbarItem={true} enableShortcut={false} />
|
|
121
|
+
}
|
|
122
|
+
/>);
|
|
123
|
+
|
|
124
|
+
const input = document.getElementById('test-filter') as HTMLInputElement;
|
|
125
|
+
expect(input).toBeInTheDocument();
|
|
126
|
+
|
|
127
|
+
// Simulate pressing "/" key
|
|
128
|
+
const keyEvent = new KeyboardEvent('keydown', {
|
|
129
|
+
key: '/',
|
|
130
|
+
code: 'Slash',
|
|
131
|
+
bubbles: true,
|
|
132
|
+
cancelable: true,
|
|
133
|
+
});
|
|
134
|
+
window.dispatchEvent(keyEvent);
|
|
135
|
+
|
|
136
|
+
// The input should not be focused since the shortcut is disabled
|
|
137
|
+
expect(document.activeElement).not.toBe(input);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should focus the search input when enableShortcut is true (default)', () => {
|
|
141
|
+
render(<DataViewToolbar
|
|
142
|
+
filters={
|
|
143
|
+
<DataViewTextFilter {...defaultProps} showToolbarItem={true} />
|
|
144
|
+
}
|
|
145
|
+
/>);
|
|
146
|
+
|
|
147
|
+
const input = document.getElementById('test-filter') as HTMLInputElement;
|
|
148
|
+
expect(input).toBeInTheDocument();
|
|
149
|
+
|
|
150
|
+
// Simulate pressing "/" key
|
|
151
|
+
const keyEvent = new KeyboardEvent('keydown', {
|
|
152
|
+
key: '/',
|
|
153
|
+
code: 'Slash',
|
|
154
|
+
bubbles: true,
|
|
155
|
+
cancelable: true,
|
|
156
|
+
});
|
|
157
|
+
window.dispatchEvent(keyEvent);
|
|
158
|
+
|
|
159
|
+
// The input should be focused since the shortcut is enabled by default
|
|
160
|
+
expect(document.activeElement).toBe(input);
|
|
161
|
+
});
|
|
23
162
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, useEffect } from 'react';
|
|
2
2
|
import { SearchInput, SearchInputProps, ToolbarFilter, ToolbarFilterProps } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
/** extends SearchInputProps */
|
|
@@ -9,6 +9,8 @@ export interface DataViewTextFilterProps extends SearchInputProps {
|
|
|
9
9
|
value?: string;
|
|
10
10
|
/** Filter title displayed in the toolbar */
|
|
11
11
|
title: string;
|
|
12
|
+
/** Label for the applied filter chip / category; defaults to title */
|
|
13
|
+
chipTitle?: string;
|
|
12
14
|
/** Callback for when the input value changes */
|
|
13
15
|
onChange?: (event: React.FormEvent<HTMLInputElement> | undefined, value: string) => void;
|
|
14
16
|
/** Controls visibility of the filter in the toolbar */
|
|
@@ -17,38 +19,77 @@ export interface DataViewTextFilterProps extends SearchInputProps {
|
|
|
17
19
|
trimValue?: boolean;
|
|
18
20
|
/** Custom OUIA ID */
|
|
19
21
|
ouiaId?: string;
|
|
22
|
+
/** Enable keyboard shortcut (/) to focus the filter. Defaults to true. */
|
|
23
|
+
enableShortcut?: boolean;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export const DataViewTextFilter: FC<DataViewTextFilterProps> = ({
|
|
23
27
|
filterId,
|
|
24
28
|
title,
|
|
29
|
+
chipTitle,
|
|
25
30
|
value = '',
|
|
26
31
|
onChange,
|
|
27
32
|
onClear = () => onChange?.(undefined, ''),
|
|
28
33
|
showToolbarItem,
|
|
29
34
|
trimValue = true,
|
|
30
35
|
ouiaId = 'DataViewTextFilter',
|
|
36
|
+
enableShortcut = true,
|
|
31
37
|
...props
|
|
32
|
-
}: DataViewTextFilterProps) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
38
|
+
}: DataViewTextFilterProps) => {
|
|
39
|
+
const categoryName = chipTitle ?? title;
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!enableShortcut) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
47
|
+
// Only handle "/" key when not typing in an input, textarea, or contenteditable element
|
|
48
|
+
if (event.key === '/' && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
49
|
+
const target = event.target as HTMLElement;
|
|
50
|
+
const isInputElement = target.tagName === 'INPUT' ||
|
|
51
|
+
target.tagName === 'TEXTAREA' ||
|
|
52
|
+
target.isContentEditable;
|
|
53
|
+
|
|
54
|
+
// Only focus if the filter is visible and we're not already in an input field
|
|
55
|
+
if (showToolbarItem && !isInputElement) {
|
|
56
|
+
// Find the input element by its ID (searchInputId prop)
|
|
57
|
+
const inputElement = document.getElementById(filterId) as HTMLInputElement;
|
|
58
|
+
if (inputElement) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
inputElement.focus();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
67
|
+
return () => {
|
|
68
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
69
|
+
};
|
|
70
|
+
}, [showToolbarItem, filterId, enableShortcut]);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ToolbarFilter
|
|
74
|
+
key={ouiaId}
|
|
75
|
+
data-ouia-component-id={ouiaId}
|
|
76
|
+
labels={value.length > 0 ? [ { key: categoryName, node: value } ] : []}
|
|
77
|
+
deleteLabel={() => onChange?.(undefined, '')}
|
|
78
|
+
categoryName={categoryName}
|
|
79
|
+
showToolbarItem={showToolbarItem}
|
|
80
|
+
>
|
|
81
|
+
<SearchInput
|
|
82
|
+
searchInputId={filterId}
|
|
83
|
+
value={value}
|
|
84
|
+
onChange={(e, inputValue) => onChange?.(e, trimValue ? inputValue.trim() : inputValue)}
|
|
85
|
+
onClear={onClear}
|
|
86
|
+
placeholder={`Filter by ${title}`}
|
|
87
|
+
aria-label={`${title ?? filterId} filter`}
|
|
88
|
+
data-ouia-component-id={`${ouiaId}-input`}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
</ToolbarFilter>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
53
94
|
|
|
54
95
|
export default DataViewTextFilter;
|
|
@@ -58,13 +58,13 @@ export interface DataViewThResizableProps {
|
|
|
58
58
|
id: string | number | undefined,
|
|
59
59
|
width: number
|
|
60
60
|
) => void;
|
|
61
|
-
/**
|
|
61
|
+
/** Starting width in pixels of the column */
|
|
62
62
|
width?: number;
|
|
63
|
-
/** Minimum width of the column */
|
|
63
|
+
/** Minimum resize width in pixels of the column */
|
|
64
64
|
minWidth?: number;
|
|
65
|
-
/** Increment for keyboard navigation */
|
|
65
|
+
/** Increment in pixels for keyboard navigation */
|
|
66
66
|
increment?: number;
|
|
67
|
-
/** Increment for keyboard navigation while shift is held */
|
|
67
|
+
/** Increment in pixels for keyboard navigation while shift is held */
|
|
68
68
|
shiftIncrement?: number;
|
|
69
69
|
/** Provides an accessible name for the resizable column via a human readable string. */
|
|
70
70
|
resizeButtonAriaLabel?: string;
|
|
@@ -324,14 +324,22 @@ export const DataViewTh: FC<DataViewThProps> = ({
|
|
|
324
324
|
</Fragment>
|
|
325
325
|
);
|
|
326
326
|
|
|
327
|
+
const classNames: string[] = [];
|
|
328
|
+
if (thProps?.className) {
|
|
329
|
+
classNames.push(thProps.className);
|
|
330
|
+
}
|
|
331
|
+
if (dataViewThClassName) {
|
|
332
|
+
classNames.push(dataViewThClassName);
|
|
333
|
+
}
|
|
334
|
+
|
|
327
335
|
return (
|
|
328
336
|
<Th
|
|
337
|
+
modifier="truncate"
|
|
329
338
|
{...thProps}
|
|
330
339
|
{...props}
|
|
331
|
-
style={width > 0 ? { minWidth: width } : undefined}
|
|
332
340
|
ref={thRef}
|
|
333
|
-
|
|
334
|
-
className={
|
|
341
|
+
style={width > 0 ? { ...thProps?.style, minWidth: width } : thProps?.style}
|
|
342
|
+
className={classNames.length > 0 ? classNames.join(' ') : undefined}
|
|
335
343
|
{...(isResizable && { additionalContent: resizableContent })}
|
|
336
344
|
>
|
|
337
345
|
{content}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, PropsWithChildren, useRef } from 'react';
|
|
2
2
|
import { Button, Toolbar, ToolbarContent, ToolbarItem, ToolbarItemVariant, ToolbarProps } from '@patternfly/react-core';
|
|
3
|
+
import { createUseStyles } from 'react-jss';
|
|
3
4
|
|
|
4
5
|
/** extends ToolbarProps */
|
|
5
6
|
export interface DataViewToolbarProps extends Omit<PropsWithChildren<ToolbarProps>, 'ref'> {
|
|
@@ -21,7 +22,19 @@ export interface DataViewToolbarProps extends Omit<PropsWithChildren<ToolbarProp
|
|
|
21
22
|
customLabelGroupContent?: React.ReactNode;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
const useStyles = createUseStyles({
|
|
26
|
+
dataViewToolbarPagination: {
|
|
27
|
+
flexBasis: '100%',
|
|
28
|
+
width: '100%'
|
|
29
|
+
},
|
|
30
|
+
dataViewToolbarPaginationWrapper: {
|
|
31
|
+
flexBasis: '100%',
|
|
32
|
+
width: '100%'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
24
36
|
export const DataViewToolbar: FC<DataViewToolbarProps> = ({ className, ouiaId = 'DataViewToolbar', bulkSelect, actions, toggleGroup, pagination, filters, customLabelGroupContent, clearAllFilters, children, ...props }: DataViewToolbarProps) => {
|
|
37
|
+
const classes = useStyles();
|
|
25
38
|
const defaultClearFilters = useRef(
|
|
26
39
|
<ToolbarItem>
|
|
27
40
|
<Button ouiaId={`${ouiaId}-clear-all-filters`} variant="link" onClick={clearAllFilters} isInline>
|
|
@@ -53,8 +66,10 @@ export const DataViewToolbar: FC<DataViewToolbarProps> = ({ className, ouiaId =
|
|
|
53
66
|
</ToolbarItem>
|
|
54
67
|
)}
|
|
55
68
|
{pagination && (
|
|
56
|
-
<ToolbarItem variant={ToolbarItemVariant.pagination} data-ouia-component-id={`${ouiaId}-pagination`}>
|
|
57
|
-
{
|
|
69
|
+
<ToolbarItem variant={ToolbarItemVariant.pagination} data-ouia-component-id={`${ouiaId}-pagination`} className={classes.dataViewToolbarPagination}>
|
|
70
|
+
<div className={classes.dataViewToolbarPaginationWrapper}>
|
|
71
|
+
{pagination}
|
|
72
|
+
</div>
|
|
58
73
|
</ToolbarItem>
|
|
59
74
|
)}
|
|
60
75
|
{children}
|