@patternfly/react-core 4.220.2 → 4.221.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/CHANGELOG.md +27 -0
- package/dist/esm/components/DataList/DataList.d.ts +9 -0
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js +3 -2
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/DataList/DataListItem.d.ts +2 -0
- package/dist/esm/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataListItem.js +13 -6
- package/dist/esm/components/DataList/DataListItem.js.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.d.ts +2 -0
- package/dist/esm/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.js +3 -2
- package/dist/esm/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts +2 -0
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js +12 -10
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts +8 -0
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +38 -28
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +8 -7
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts +2 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.js +3 -2
- package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +2 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +3 -2
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts +9 -0
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js +3 -2
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/DataList/DataListItem.d.ts +2 -0
- package/dist/js/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/js/components/DataList/DataListItem.js +13 -6
- package/dist/js/components/DataList/DataListItem.js.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.d.ts +2 -0
- package/dist/js/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.js +3 -2
- package/dist/js/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts +2 -0
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js +12 -10
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts +8 -0
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js +38 -28
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +2 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +8 -7
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts +2 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.js +3 -2
- package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +2 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +3 -2
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/styles/assets/images/icon-github.hbs +4 -0
- package/dist/styles/assets/images/icon-google.hbs +4 -0
- package/dist/styles/assets/images/icon-red-hat.hbs +1 -0
- package/dist/styles/base-no-reset.css +93 -4
- package/dist/styles/base.css +93 -4
- package/dist/umd/react-core.css +790 -8
- package/dist/umd/react-core.js +433 -342
- package/dist/umd/react-core.min.css +790 -8
- package/dist/umd/react-core.min.js +6 -6
- package/package.json +6 -6
- package/src/components/DataList/DataList.tsx +12 -0
- package/src/components/DataList/DataListItem.tsx +32 -3
- package/src/components/DataList/__tests__/DataList.test.tsx +130 -0
- package/src/components/DataList/examples/DataList.md +1 -0
- package/src/components/DataList/examples/DataListSelectableRows.tsx +5 -0
- package/src/components/InputGroup/InputGroup.tsx +7 -1
- package/src/components/SearchInput/AdvancedSearchMenu.tsx +24 -18
- package/src/components/SearchInput/SearchInput.tsx +130 -113
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +1 -1
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +297 -301
- package/src/components/SearchInput/examples/SearchInput.md +5 -2
- package/src/components/Select/Select.tsx +8 -2
- package/src/components/TextInputGroup/TextInputGroup.tsx +18 -7
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +5 -0
- package/src/demos/PrimaryDetail.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.221.2",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.72.2",
|
|
38
|
+
"@patternfly/react-styles": "^4.71.2",
|
|
39
|
+
"@patternfly/react-tokens": "^4.73.2",
|
|
40
40
|
"focus-trap": "6.9.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.
|
|
46
|
+
"@patternfly/patternfly": "4.196.6",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "eeeefa74fca5d5c4739cc6113028a2cca51f0fb7"
|
|
64
64
|
}
|
|
@@ -20,6 +20,13 @@ export enum DataListWrapModifier {
|
|
|
20
20
|
breakWord = 'breakWord'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface SelectableRowObject {
|
|
24
|
+
/** Determines if only one of the selectable rows should be selectable at a time */
|
|
25
|
+
type: 'multiple' | 'single';
|
|
26
|
+
/** Callback that executes when the screen reader accessible element receives a change event */
|
|
27
|
+
onChange: (id: string, event: React.FormEvent<HTMLInputElement>) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
export interface DataListProps extends Omit<React.HTMLProps<HTMLUListElement>, 'onDragStart' | 'ref'> {
|
|
24
31
|
/** Content rendered inside the DataList list */
|
|
25
32
|
children?: React.ReactNode;
|
|
@@ -47,6 +54,8 @@ export interface DataListProps extends Omit<React.HTMLProps<HTMLUListElement>, '
|
|
|
47
54
|
wrapModifier?: DataListWrapModifier | 'nowrap' | 'truncate' | 'breakWord';
|
|
48
55
|
/** @deprecated Order of items in a draggable DataList */
|
|
49
56
|
itemOrder?: string[];
|
|
57
|
+
/** @beta Object that causes the data list to render hidden inputs which improve selectable item a11y */
|
|
58
|
+
selectableRow?: SelectableRowObject;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
interface DataListState {
|
|
@@ -60,6 +69,7 @@ interface DataListContextProps {
|
|
|
60
69
|
isSelectable: boolean;
|
|
61
70
|
selectedDataListItemId: string;
|
|
62
71
|
updateSelectedDataListItem: (id: string) => void;
|
|
72
|
+
selectableRow?: SelectableRowObject;
|
|
63
73
|
isDraggable: boolean;
|
|
64
74
|
dragStart: (e: React.DragEvent) => void;
|
|
65
75
|
dragEnd: (e: React.DragEvent) => void;
|
|
@@ -308,6 +318,7 @@ export class DataList extends React.Component<DataListProps, DataListState> {
|
|
|
308
318
|
onDragFinish,
|
|
309
319
|
gridBreakpoint,
|
|
310
320
|
itemOrder,
|
|
321
|
+
selectableRow,
|
|
311
322
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
312
323
|
...props
|
|
313
324
|
} = this.props;
|
|
@@ -330,6 +341,7 @@ export class DataList extends React.Component<DataListProps, DataListState> {
|
|
|
330
341
|
isSelectable,
|
|
331
342
|
selectedDataListItemId,
|
|
332
343
|
updateSelectedDataListItem,
|
|
344
|
+
selectableRow,
|
|
333
345
|
isDraggable: this.html5DragDrop,
|
|
334
346
|
dragStart: this.dragStart,
|
|
335
347
|
dragEnd: this.dragEnd,
|
|
@@ -16,6 +16,8 @@ export interface DataListItemProps extends Omit<React.HTMLProps<HTMLLIElement>,
|
|
|
16
16
|
'aria-labelledby': string;
|
|
17
17
|
/** Unique id for the DataList item */
|
|
18
18
|
id?: string;
|
|
19
|
+
/** @beta Aria label to apply to the selectable input if one is rendered */
|
|
20
|
+
selectableInputAriaLabel?: string;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface DataListItemChildProps {
|
|
@@ -52,13 +54,22 @@ export class DataListItem extends React.Component<DataListItemProps> {
|
|
|
52
54
|
'aria-labelledby': ''
|
|
53
55
|
};
|
|
54
56
|
render() {
|
|
55
|
-
const {
|
|
57
|
+
const {
|
|
58
|
+
children,
|
|
59
|
+
isExpanded,
|
|
60
|
+
className,
|
|
61
|
+
id,
|
|
62
|
+
'aria-labelledby': ariaLabelledBy,
|
|
63
|
+
selectableInputAriaLabel,
|
|
64
|
+
...props
|
|
65
|
+
} = this.props;
|
|
56
66
|
return (
|
|
57
67
|
<DataListContext.Consumer>
|
|
58
68
|
{({
|
|
59
69
|
isSelectable,
|
|
60
70
|
selectedDataListItemId,
|
|
61
71
|
updateSelectedDataListItem,
|
|
72
|
+
selectableRow,
|
|
62
73
|
isDraggable,
|
|
63
74
|
dragStart,
|
|
64
75
|
dragEnd,
|
|
@@ -98,6 +109,14 @@ export class DataListItem extends React.Component<DataListItemProps> {
|
|
|
98
109
|
onDragStart: dragStart
|
|
99
110
|
};
|
|
100
111
|
|
|
112
|
+
const isSelected = selectedDataListItemId === id;
|
|
113
|
+
|
|
114
|
+
const selectableInputAriaProps = selectableInputAriaLabel
|
|
115
|
+
? { 'aria-label': selectableInputAriaLabel }
|
|
116
|
+
: { 'aria-labelledby': ariaLabelledBy };
|
|
117
|
+
|
|
118
|
+
const selectableInputType = selectableRow?.type === 'multiple' ? 'checkbox' : 'radio';
|
|
119
|
+
|
|
101
120
|
return (
|
|
102
121
|
<li
|
|
103
122
|
id={id}
|
|
@@ -105,15 +124,25 @@ export class DataListItem extends React.Component<DataListItemProps> {
|
|
|
105
124
|
styles.dataListItem,
|
|
106
125
|
isExpanded && styles.modifiers.expanded,
|
|
107
126
|
isSelectable && styles.modifiers.selectable,
|
|
108
|
-
selectedDataListItemId &&
|
|
127
|
+
selectedDataListItemId && isSelected && styles.modifiers.selected,
|
|
109
128
|
className
|
|
110
129
|
)}
|
|
111
130
|
aria-labelledby={ariaLabelledBy}
|
|
112
131
|
{...(isSelectable && { tabIndex: 0, onClick: selectDataListItem, onKeyDown })}
|
|
113
|
-
{...(isSelectable &&
|
|
132
|
+
{...(isSelectable && isSelected && { 'aria-selected': true })}
|
|
114
133
|
{...props}
|
|
115
134
|
{...dragProps}
|
|
116
135
|
>
|
|
136
|
+
{selectableRow && (
|
|
137
|
+
<input
|
|
138
|
+
className="pf-screen-reader"
|
|
139
|
+
type={selectableInputType}
|
|
140
|
+
checked={isSelected}
|
|
141
|
+
onChange={event => selectableRow.onChange(id, event)}
|
|
142
|
+
tabIndex={-1}
|
|
143
|
+
{...selectableInputAriaProps}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
117
146
|
{React.Children.map(
|
|
118
147
|
children,
|
|
119
148
|
child =>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
4
5
|
|
|
5
6
|
import { DataList } from '../DataList';
|
|
6
7
|
import { DataListItem } from '../DataListItem';
|
|
@@ -47,6 +48,135 @@ describe('DataList', () => {
|
|
|
47
48
|
expect(asFragment()).toMatchSnapshot();
|
|
48
49
|
});
|
|
49
50
|
|
|
51
|
+
test('List renders with a hidden input to improve a11y when selectableRow is passed', () => {
|
|
52
|
+
render(
|
|
53
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: () => {} }}>
|
|
54
|
+
<DataListItem>
|
|
55
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
56
|
+
<p id="test-id">Test</p>
|
|
57
|
+
</DataListItemRow>
|
|
58
|
+
</DataListItem>
|
|
59
|
+
</DataList>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
63
|
+
|
|
64
|
+
expect(selectableInput).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('List does not render with a hidden input to improve a11y when selectableRow is not passed', () => {
|
|
68
|
+
render(
|
|
69
|
+
<DataList aria-label="this is a simple list">
|
|
70
|
+
<DataListItem>
|
|
71
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
72
|
+
<p id="test-id">Test</p>
|
|
73
|
+
</DataListItemRow>
|
|
74
|
+
</DataListItem>
|
|
75
|
+
</DataList>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const selectableInput = screen.queryByRole('checkbox', { hidden: true });
|
|
79
|
+
|
|
80
|
+
expect(selectableInput).not.toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('List hidden input renders as a radio when selectableRow.type is radio', () => {
|
|
84
|
+
render(
|
|
85
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'single', onChange: () => {} }}>
|
|
86
|
+
<DataListItem>
|
|
87
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
88
|
+
<p id="test-id">Test</p>
|
|
89
|
+
</DataListItemRow>
|
|
90
|
+
</DataListItem>
|
|
91
|
+
</DataList>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const selectableRadioInput = screen.getByRole('radio', { hidden: true });
|
|
95
|
+
const selectableCheckboxInput = screen.queryByRole('checkbox', { hidden: true });
|
|
96
|
+
|
|
97
|
+
expect(selectableRadioInput).toBeInTheDocument();
|
|
98
|
+
expect(selectableCheckboxInput).not.toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('List calls selectableRow.onChange when the selectable input changes', () => {
|
|
102
|
+
const mock = jest.fn();
|
|
103
|
+
|
|
104
|
+
render(
|
|
105
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: mock }}>
|
|
106
|
+
<DataListItem>
|
|
107
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
108
|
+
<p id="test-id">Test</p>
|
|
109
|
+
</DataListItemRow>
|
|
110
|
+
</DataListItem>
|
|
111
|
+
</DataList>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
115
|
+
userEvent.click(selectableInput);
|
|
116
|
+
|
|
117
|
+
expect(mock).toHaveBeenCalled();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('List does not call selectableRow.onChange when the selectable input is not changed', () => {
|
|
121
|
+
const mock = jest.fn();
|
|
122
|
+
|
|
123
|
+
render(
|
|
124
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: mock }}>
|
|
125
|
+
<DataListItem>
|
|
126
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
127
|
+
<p id="test-id">Test</p>
|
|
128
|
+
</DataListItemRow>
|
|
129
|
+
</DataListItem>
|
|
130
|
+
</DataList>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
expect(mock).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('Item applies selectableInputAriaLabel to the hidden input', () => {
|
|
137
|
+
render(
|
|
138
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: () => {} }}>
|
|
139
|
+
<DataListItem selectableInputAriaLabel="Data list item label test">
|
|
140
|
+
<DataListItemRow aria-labelledby="test-id">
|
|
141
|
+
<p id="test-id">Test</p>
|
|
142
|
+
</DataListItemRow>
|
|
143
|
+
</DataListItem>
|
|
144
|
+
</DataList>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
148
|
+
|
|
149
|
+
expect(selectableInput).toHaveAccessibleName('Data list item label test');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('Item defaults to labelling its input using its aria-labelledby prop', () => {
|
|
153
|
+
render(
|
|
154
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: () => {} }}>
|
|
155
|
+
<DataListItem aria-labelledby="test-id">
|
|
156
|
+
<p id="test-id">Test cell content</p>
|
|
157
|
+
</DataListItem>
|
|
158
|
+
</DataList>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
162
|
+
|
|
163
|
+
expect(selectableInput).toHaveAccessibleName('Test cell content');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('Item prioritizes selectableInputAriaLabel over aria-labelledby prop', () => {
|
|
167
|
+
render(
|
|
168
|
+
<DataList aria-label="this is a simple list" selectableRow={{ type: 'multiple', onChange: () => {} }}>
|
|
169
|
+
<DataListItem aria-labelledby="test-id" selectableInputAriaLabel="Data list item label test">
|
|
170
|
+
<p id="test-id">Test cell content</p>
|
|
171
|
+
</DataListItem>
|
|
172
|
+
</DataList>
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
176
|
+
|
|
177
|
+
expect(selectableInput).toHaveAccessibleName('Data list item label test');
|
|
178
|
+
});
|
|
179
|
+
|
|
50
180
|
test('Item default', () => {
|
|
51
181
|
const { asFragment } = render(
|
|
52
182
|
<DataListItem key="item-id-1" aria-labelledby="item-1">
|
|
@@ -37,12 +37,17 @@ export const DataListSelectableRows: React.FunctionComponent = () => {
|
|
|
37
37
|
setSelectedDataListItemId(id);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const handleInputChange = (id: string, _event: React.FormEvent<HTMLInputElement>) => {
|
|
41
|
+
setSelectedDataListItemId(id);
|
|
42
|
+
};
|
|
43
|
+
|
|
40
44
|
return (
|
|
41
45
|
<React.Fragment>
|
|
42
46
|
<DataList
|
|
43
47
|
aria-label="selectable data list example"
|
|
44
48
|
selectedDataListItemId={selectedDataListItemId}
|
|
45
49
|
onSelectDataListItem={onSelectDataListItem}
|
|
50
|
+
selectableRow={{ type: 'single', onChange: handleInputChange }}
|
|
46
51
|
>
|
|
47
52
|
<DataListItem aria-labelledby="selectable-action-item1" id="item1">
|
|
48
53
|
<DataListItemRow>
|
|
@@ -10,19 +10,25 @@ export interface InputGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
/** Content rendered inside the input group. */
|
|
12
12
|
children: React.ReactNode;
|
|
13
|
+
/** @hide A reference object to attach to the input box */
|
|
14
|
+
innerRef?: React.RefObject<any>;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
|
|
16
18
|
className = '',
|
|
17
19
|
children,
|
|
20
|
+
innerRef,
|
|
18
21
|
...props
|
|
19
22
|
}: InputGroupProps) => {
|
|
20
23
|
const formCtrls = [FormSelect, TextArea, TextInput].map(comp => comp.displayName);
|
|
21
24
|
const idItem = React.Children.toArray(children).find(
|
|
22
25
|
(child: any) => !formCtrls.includes(child.type.displayName) && child.props.id
|
|
23
26
|
) as React.ReactElement<{ id: string }>;
|
|
27
|
+
|
|
28
|
+
const inputGroupRef = innerRef || React.useRef(null);
|
|
29
|
+
|
|
24
30
|
return (
|
|
25
|
-
<div className={css(styles.inputGroup, className)} {...props}>
|
|
31
|
+
<div ref={inputGroupRef} className={css(styles.inputGroup, className)} {...props}>
|
|
26
32
|
{idItem
|
|
27
33
|
? React.Children.map(children, (child: any) =>
|
|
28
34
|
formCtrls.includes(child.type.displayName)
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import styles from '@patternfly/react-styles/css/components/SearchInput/search-input';
|
|
3
2
|
import { Button } from '../Button';
|
|
4
3
|
import { ActionGroup, Form, FormGroup } from '../Form';
|
|
5
4
|
import { TextInput } from '../TextInput';
|
|
6
5
|
import { GenerateId, KEY_CODES } from '../../helpers';
|
|
7
6
|
import { SearchAttribute } from './SearchInput';
|
|
7
|
+
import { Panel, PanelMain, PanelMainBody } from '../Panel';
|
|
8
|
+
import { css } from '@patternfly/react-styles';
|
|
8
9
|
|
|
9
10
|
export interface AdvancedSearchMenuProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {
|
|
11
|
+
/** Additional classes added to the Advanced search menu */
|
|
12
|
+
className?: string;
|
|
10
13
|
/** Value of the search input */
|
|
11
14
|
value?: string;
|
|
12
15
|
/** Ref of the div wrapping the whole search input **/
|
|
@@ -46,6 +49,7 @@ export interface AdvancedSearchMenuProps extends Omit<React.HTMLProps<HTMLDivEle
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps> = ({
|
|
52
|
+
className,
|
|
49
53
|
parentRef,
|
|
50
54
|
parentInputRef,
|
|
51
55
|
value = '',
|
|
@@ -200,24 +204,26 @@ export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps
|
|
|
200
204
|
};
|
|
201
205
|
|
|
202
206
|
return isSearchMenuOpen ? (
|
|
203
|
-
<
|
|
204
|
-
<
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<
|
|
210
|
-
{
|
|
211
|
-
|
|
212
|
-
{!!onClear && (
|
|
213
|
-
<Button variant="link" type="reset" onClick={onClear}>
|
|
214
|
-
{resetButtonLabel}
|
|
207
|
+
<Panel variant="raised" className={css(className)}>
|
|
208
|
+
<PanelMain>
|
|
209
|
+
<PanelMainBody>
|
|
210
|
+
<Form>
|
|
211
|
+
{buildFormGroups()}
|
|
212
|
+
{formAdditionalItems ? formAdditionalItems : null}
|
|
213
|
+
<ActionGroup>
|
|
214
|
+
<Button variant="primary" type="submit" onClick={onSearchHandler} isDisabled={!value}>
|
|
215
|
+
{submitSearchButtonLabel}
|
|
215
216
|
</Button>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
{!!onClear && (
|
|
218
|
+
<Button variant="link" type="reset" onClick={onClear}>
|
|
219
|
+
{resetButtonLabel}
|
|
220
|
+
</Button>
|
|
221
|
+
)}
|
|
222
|
+
</ActionGroup>
|
|
223
|
+
</Form>
|
|
224
|
+
</PanelMainBody>
|
|
225
|
+
</PanelMain>
|
|
226
|
+
</Panel>
|
|
221
227
|
) : null;
|
|
222
228
|
};
|
|
223
229
|
AdvancedSearchMenu.displayName = 'SearchInput';
|