@patternfly/react-core 4.191.5 → 4.192.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 +41 -0
- package/dist/esm/components/DataList/DataListCheck.d.ts +1 -1
- package/dist/esm/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts +2 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.js +2 -2
- package/dist/esm/components/Modal/ModalBoxCloseButton.js.map +1 -1
- package/dist/esm/components/Modal/ModalContent.js +1 -1
- package/dist/esm/components/Modal/ModalContent.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +2 -2
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts +2 -0
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +70 -48
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +2 -2
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/esm/components/Truncate/Truncate.d.ts +21 -0
- package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -0
- package/dist/esm/components/Truncate/Truncate.js +34 -0
- package/dist/esm/components/Truncate/Truncate.js.map +1 -0
- package/dist/esm/components/Truncate/index.d.ts +2 -0
- package/dist/esm/components/Truncate/index.d.ts.map +1 -0
- package/dist/esm/components/Truncate/index.js +2 -0
- package/dist/esm/components/Truncate/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/js/components/DataList/DataListCheck.d.ts +1 -1
- package/dist/js/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts +2 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.js +2 -2
- package/dist/js/components/Modal/ModalBoxCloseButton.js.map +1 -1
- package/dist/js/components/Modal/ModalContent.js +1 -1
- package/dist/js/components/Modal/ModalContent.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +2 -2
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts +2 -0
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +70 -48
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +2 -2
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/components/Truncate/Truncate.d.ts +21 -0
- package/dist/js/components/Truncate/Truncate.d.ts.map +1 -0
- package/dist/js/components/Truncate/Truncate.js +38 -0
- package/dist/js/components/Truncate/Truncate.js.map +1 -0
- package/dist/js/components/Truncate/index.d.ts +2 -0
- package/dist/js/components/Truncate/index.d.ts.map +1 -0
- package/dist/js/components/Truncate/index.js +5 -0
- package/dist/js/components/Truncate/index.js.map +1 -0
- package/dist/js/components/index.d.ts +1 -0
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +1 -0
- package/dist/js/components/index.js.map +1 -1
- package/dist/umd/react-core.css +59 -6
- package/dist/umd/react-core.js +1003 -941
- package/dist/umd/react-core.min.css +59 -6
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/BackToTop/examples/BackToTop.md +1 -1
- package/src/components/DataList/DataListCheck.tsx +1 -1
- package/src/components/Modal/ModalBoxCloseButton.tsx +11 -2
- package/src/components/Modal/ModalContent.tsx +1 -1
- package/src/components/Modal/examples/Modal.md +3 -200
- package/src/components/Modal/examples/ModalWithForm.tsx +209 -0
- package/src/components/Select/Select.tsx +2 -1
- package/src/components/Select/SelectOption.tsx +188 -133
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +7 -1
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +6 -0
- package/src/components/TextInputGroup/examples/TextInputGroupFilters.tsx +12 -7
- package/src/components/TextInputGroup/examples/TextInputGroupUtilitiesAndIcon.tsx +12 -7
- package/src/components/Truncate/Truncate.tsx +63 -0
- package/src/components/Truncate/__tests__/Truncate.test.tsx +18 -0
- package/src/components/Truncate/__tests__/__snapshots__/Truncate.test.tsx.snap +58 -0
- package/src/components/Truncate/examples/Truncate.md +59 -0
- package/src/components/Truncate/examples/TruncateExamples.css +9 -0
- package/src/components/Truncate/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/demos/Tabs/NestedTabsDemo.js +3 -3
- package/src/demos/Tabs.md +4 -0
- package/src/demos/examples/Tabs/GrayTabs.tsx +158 -0
- package/src/demos/examples/TextInputGroup/AttributeValueFiltering.tsx +13 -8
- package/src/demos/examples/TextInputGroup/AutoCompleteSearch.tsx +29 -15
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Truncate
|
|
3
|
+
section: components
|
|
4
|
+
propComponents: [Truncate]
|
|
5
|
+
beta: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import './TruncateExamples.css';
|
|
9
|
+
|
|
10
|
+
## Examples
|
|
11
|
+
|
|
12
|
+
### Default
|
|
13
|
+
```js
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { Truncate } from '@patternfly/react-core';
|
|
16
|
+
<div className="pf-c-truncate--example">
|
|
17
|
+
<Truncate
|
|
18
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Middle
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { Truncate } from '@patternfly/react-core';
|
|
28
|
+
<div className="pf-c-truncate--example">
|
|
29
|
+
<Truncate
|
|
30
|
+
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
31
|
+
trailingNumChars={10}
|
|
32
|
+
position={'middle'}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Start
|
|
38
|
+
```js
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { Truncate } from '@patternfly/react-core';
|
|
41
|
+
<div className="pf-c-truncate--example">
|
|
42
|
+
<Truncate
|
|
43
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
44
|
+
position={'start'}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Default with tooltip at the bottom
|
|
50
|
+
```js
|
|
51
|
+
import React from 'react';
|
|
52
|
+
import { Truncate } from '@patternfly/react-core';
|
|
53
|
+
<div className="pf-c-truncate--example">
|
|
54
|
+
<Truncate
|
|
55
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
56
|
+
tooltipPosition={'bottom'}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Truncate';
|
package/src/components/index.ts
CHANGED
|
@@ -109,14 +109,14 @@ export const NestedTabsDemo = () => {
|
|
|
109
109
|
<FlexItem flex={{ default: 'flex_1' }}>
|
|
110
110
|
<Card isFullHeight>
|
|
111
111
|
<CardHeader>
|
|
112
|
-
<Title headingLevel="
|
|
112
|
+
<Title headingLevel="h2">Title of Card</Title>
|
|
113
113
|
</CardHeader>
|
|
114
114
|
</Card>
|
|
115
115
|
</FlexItem>
|
|
116
116
|
<FlexItem flex={{ default: 'flex_1' }}>
|
|
117
117
|
<Card isFullHeight>
|
|
118
118
|
<CardHeader>
|
|
119
|
-
<Title headingLevel="
|
|
119
|
+
<Title headingLevel="h2">Title of Card</Title>
|
|
120
120
|
</CardHeader>
|
|
121
121
|
</Card>
|
|
122
122
|
</FlexItem>
|
|
@@ -132,7 +132,7 @@ export const NestedTabsDemo = () => {
|
|
|
132
132
|
Overview
|
|
133
133
|
</Title>
|
|
134
134
|
</PageSection>
|
|
135
|
-
<PageSection type="tabs"
|
|
135
|
+
<PageSection type="tabs" isWidthLimited>
|
|
136
136
|
<Tabs activeKey={activeTabKey} onSelect={handleTabClick} usePageInsets id="nested-tabs-example-tabs-list">
|
|
137
137
|
<Tab eventKey={0} title={<TabTitleText>Cluster 1</TabTitleText>} tabContentId={`tabContent${0}`} />
|
|
138
138
|
<Tab eventKey={1} title={<TabTitleText>Cluster 2</TabTitleText>} tabContentId={`tabContent${1}`} />
|
package/src/demos/Tabs.md
CHANGED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
PageSection,
|
|
4
|
+
PageSectionVariants,
|
|
5
|
+
Tabs,
|
|
6
|
+
Tab,
|
|
7
|
+
TabContent,
|
|
8
|
+
TabContentBody,
|
|
9
|
+
TabTitleText,
|
|
10
|
+
Title,
|
|
11
|
+
Grid,
|
|
12
|
+
GridItem,
|
|
13
|
+
Flex,
|
|
14
|
+
FlexItem,
|
|
15
|
+
Card,
|
|
16
|
+
CardBody,
|
|
17
|
+
CardHeader
|
|
18
|
+
} from '@patternfly/react-core';
|
|
19
|
+
import DashboardWrapper from '../../examples/DashboardWrapper';
|
|
20
|
+
|
|
21
|
+
export const GrayTabsDemo: React.FunctionComponent = () => {
|
|
22
|
+
const [activeTabKey, setActiveTabKey] = React.useState<string | number>(0);
|
|
23
|
+
const [activeNestedTabKey, setActiveNestedTabKey] = React.useState<string | number>(0);
|
|
24
|
+
|
|
25
|
+
// Toggle currently active tab
|
|
26
|
+
const handleTabClick = (_: React.MouseEvent, tabIndex: string | number) => setActiveTabKey(tabIndex);
|
|
27
|
+
|
|
28
|
+
// Toggle currently active nested tab
|
|
29
|
+
const handleNestedTabClick = (_: React.MouseEvent, tabIndex: string | number) => setActiveNestedTabKey(tabIndex);
|
|
30
|
+
|
|
31
|
+
const tabContent = (
|
|
32
|
+
<Grid hasGutter>
|
|
33
|
+
<GridItem xl={8} md={6}>
|
|
34
|
+
<Card>
|
|
35
|
+
<CardHeader>
|
|
36
|
+
<Title headingLevel="h2">Status</Title>
|
|
37
|
+
</CardHeader>
|
|
38
|
+
<CardBody>
|
|
39
|
+
<Flex direction={{ default: 'column' }}>
|
|
40
|
+
<FlexItem>
|
|
41
|
+
<Tabs
|
|
42
|
+
activeKey={activeNestedTabKey}
|
|
43
|
+
isSecondary
|
|
44
|
+
onSelect={handleNestedTabClick}
|
|
45
|
+
id="nested-tabs-example-tabs-list"
|
|
46
|
+
>
|
|
47
|
+
<Tab eventKey={10} title={<TabTitleText>Cluster</TabTitleText>} tabContentId={`tabContent${10}`} />
|
|
48
|
+
<Tab
|
|
49
|
+
eventKey={11}
|
|
50
|
+
title={<TabTitleText>Control plane</TabTitleText>}
|
|
51
|
+
tabContentId={`tabContent${11}`}
|
|
52
|
+
/>
|
|
53
|
+
<Tab eventKey={12} title={<TabTitleText>Operators</TabTitleText>} tabContentId={`tabContent${12}`} />
|
|
54
|
+
<Tab
|
|
55
|
+
eventKey={13}
|
|
56
|
+
title={<TabTitleText>Virtualization</TabTitleText>}
|
|
57
|
+
tabContentId={`tabContent${13}`}
|
|
58
|
+
/>
|
|
59
|
+
</Tabs>
|
|
60
|
+
</FlexItem>
|
|
61
|
+
<FlexItem>
|
|
62
|
+
<TabContent
|
|
63
|
+
key={10}
|
|
64
|
+
eventKey={10}
|
|
65
|
+
id={`tabContent${10}`}
|
|
66
|
+
activeKey={activeNestedTabKey}
|
|
67
|
+
hidden={10 !== activeNestedTabKey}
|
|
68
|
+
>
|
|
69
|
+
<TabContentBody>
|
|
70
|
+
{
|
|
71
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce in odio porttitor, feugiat risus in, feugiat arcu. Nullam euismod enim eget fringilla condimentum. Maecenas tincidunt et metus id aliquet. Integer et fermentum purus. Nulla tempor velit arcu, vitae semper purus iaculis at. Sed malesuada auctor luctus. Pellentesque et leo urna. Aliquam vitae felis congue lacus mattis fringilla. Nullam et ultricies erat, sed dignissim elit. Cras mattis pulvinar aliquam. In ac est nulla. Pellentesque fermentum nibh ac sapien porta, ut congue orci aliquam. Sed nisl est, tempor eu pharetra eget, ullamcorper ut augue. Vestibulum eleifend libero eu nulla cursus lacinia.'
|
|
72
|
+
}
|
|
73
|
+
</TabContentBody>
|
|
74
|
+
</TabContent>
|
|
75
|
+
<TabContent
|
|
76
|
+
key={11}
|
|
77
|
+
eventKey={11}
|
|
78
|
+
id={`tabContent${11}`}
|
|
79
|
+
activeKey={activeNestedTabKey}
|
|
80
|
+
hidden={11 !== activeNestedTabKey}
|
|
81
|
+
>
|
|
82
|
+
<TabContentBody>Control plane panel</TabContentBody>
|
|
83
|
+
</TabContent>
|
|
84
|
+
<TabContent
|
|
85
|
+
key={12}
|
|
86
|
+
eventKey={12}
|
|
87
|
+
id={`tabContent${12}`}
|
|
88
|
+
activeKey={activeNestedTabKey}
|
|
89
|
+
hidden={12 !== activeNestedTabKey}
|
|
90
|
+
>
|
|
91
|
+
<TabContentBody>Operators panel</TabContentBody>
|
|
92
|
+
</TabContent>
|
|
93
|
+
<TabContent
|
|
94
|
+
key={13}
|
|
95
|
+
eventKey={13}
|
|
96
|
+
id={`tabContent${13}`}
|
|
97
|
+
activeKey={activeNestedTabKey}
|
|
98
|
+
hidden={13 !== activeNestedTabKey}
|
|
99
|
+
>
|
|
100
|
+
<TabContentBody>Virtualization panel</TabContentBody>
|
|
101
|
+
</TabContent>
|
|
102
|
+
</FlexItem>
|
|
103
|
+
</Flex>
|
|
104
|
+
</CardBody>
|
|
105
|
+
</Card>
|
|
106
|
+
</GridItem>
|
|
107
|
+
<GridItem xl={4} md={6}>
|
|
108
|
+
<Flex direction={{ default: 'column' }} className="pf-u-h-100">
|
|
109
|
+
<FlexItem flex={{ default: 'flex_1' }}>
|
|
110
|
+
<Card isFullHeight>
|
|
111
|
+
<CardHeader>
|
|
112
|
+
<Title headingLevel="h2">Title of Card</Title>
|
|
113
|
+
</CardHeader>
|
|
114
|
+
</Card>
|
|
115
|
+
</FlexItem>
|
|
116
|
+
<FlexItem flex={{ default: 'flex_1' }}>
|
|
117
|
+
<Card isFullHeight>
|
|
118
|
+
<CardHeader>
|
|
119
|
+
<Title headingLevel="h2">Title of Card</Title>
|
|
120
|
+
</CardHeader>
|
|
121
|
+
</Card>
|
|
122
|
+
</FlexItem>
|
|
123
|
+
</Flex>
|
|
124
|
+
</GridItem>
|
|
125
|
+
</Grid>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<DashboardWrapper hasNoBreadcrumb>
|
|
130
|
+
<PageSection isWidthLimited variant={PageSectionVariants.light}>
|
|
131
|
+
<Title headingLevel="h1" size="2xl">
|
|
132
|
+
Overview
|
|
133
|
+
</Title>
|
|
134
|
+
</PageSection>
|
|
135
|
+
<PageSection type="tabs" isWidthLimited>
|
|
136
|
+
<Tabs
|
|
137
|
+
activeKey={activeTabKey}
|
|
138
|
+
onSelect={handleTabClick}
|
|
139
|
+
usePageInsets
|
|
140
|
+
isBox
|
|
141
|
+
variant="light300"
|
|
142
|
+
id="open-tabs-example-tabs-list"
|
|
143
|
+
>
|
|
144
|
+
<Tab eventKey={0} title={<TabTitleText>Cluster 1</TabTitleText>} tabContentId={`tabContent${0}`} />
|
|
145
|
+
<Tab eventKey={1} title={<TabTitleText>Cluster 2</TabTitleText>} tabContentId={`tabContent${1}`} />
|
|
146
|
+
</Tabs>
|
|
147
|
+
</PageSection>
|
|
148
|
+
<PageSection isWidthLimited>
|
|
149
|
+
<TabContent key={0} eventKey={0} id={`tabContent${0}`} activeKey={activeTabKey} hidden={0 !== activeTabKey}>
|
|
150
|
+
<TabContentBody>{tabContent}</TabContentBody>
|
|
151
|
+
</TabContent>
|
|
152
|
+
<TabContent key={1} eventKey={1} id={`tabContent${1}`} activeKey={activeTabKey} hidden={1 !== activeTabKey}>
|
|
153
|
+
<TabContentBody>Cluster 2 panel</TabContentBody>
|
|
154
|
+
</TabContent>
|
|
155
|
+
</PageSection>
|
|
156
|
+
</DashboardWrapper>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
@@ -205,12 +205,15 @@ export const AttributeValueFiltering: React.FunctionComponent = () => {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
/**
|
|
208
|
+
/** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
|
|
209
209
|
const showSearchIcon = !currentChips.length;
|
|
210
210
|
|
|
211
211
|
/** only show the clear button when there is something that can be cleared */
|
|
212
212
|
const showClearButton = !!inputValue || !!currentChips.length;
|
|
213
213
|
|
|
214
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
215
|
+
const showUtilities = showClearButton;
|
|
216
|
+
|
|
214
217
|
const inputGroup = (
|
|
215
218
|
<div ref={textInputGroupRef}>
|
|
216
219
|
<TextInputGroup>
|
|
@@ -229,13 +232,15 @@ export const AttributeValueFiltering: React.FunctionComponent = () => {
|
|
|
229
232
|
))}
|
|
230
233
|
</ChipGroup>
|
|
231
234
|
</TextInputGroupMain>
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
{showUtilities && (
|
|
236
|
+
<TextInputGroupUtilities>
|
|
237
|
+
{showClearButton && (
|
|
238
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
|
|
239
|
+
<TimesIcon />
|
|
240
|
+
</Button>
|
|
241
|
+
)}
|
|
242
|
+
</TextInputGroupUtilities>
|
|
243
|
+
)}
|
|
239
244
|
</TextInputGroup>
|
|
240
245
|
</div>
|
|
241
246
|
);
|
|
@@ -92,11 +92,11 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
const handleTab = (
|
|
95
|
+
const handleTab = () => {
|
|
96
96
|
if (menuItems.length === 3) {
|
|
97
97
|
setInputValue(menuItems[2].props.children);
|
|
98
|
-
event.preventDefault();
|
|
99
98
|
}
|
|
99
|
+
setMenuIsOpen(false);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/** close the menu when escape is hit */
|
|
@@ -129,7 +129,7 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
129
129
|
handleEscape();
|
|
130
130
|
break;
|
|
131
131
|
case 'Tab':
|
|
132
|
-
handleTab(
|
|
132
|
+
handleTab();
|
|
133
133
|
break;
|
|
134
134
|
case 'ArrowUp':
|
|
135
135
|
case 'ArrowDown':
|
|
@@ -166,19 +166,29 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
166
166
|
|
|
167
167
|
/** enable keyboard only usage while focused on the menu */
|
|
168
168
|
const handleMenuKeyDown = (event: React.KeyboardEvent) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
switch (event.key) {
|
|
170
|
+
case 'Tab':
|
|
171
|
+
case 'Escape':
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
focusTextInput();
|
|
174
|
+
setMenuIsOpen(false);
|
|
175
|
+
break;
|
|
176
|
+
case 'Enter':
|
|
177
|
+
case ' ':
|
|
178
|
+
setTimeout(() => setMenuIsOpen(false), 0);
|
|
179
|
+
break;
|
|
173
180
|
}
|
|
174
181
|
};
|
|
175
182
|
|
|
176
|
-
/**
|
|
183
|
+
/** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
|
|
177
184
|
const showSearchIcon = !currentChips.length;
|
|
178
185
|
|
|
179
186
|
/** only show the clear button when there is something that can be cleared */
|
|
180
187
|
const showClearButton = !!inputValue || !!currentChips.length;
|
|
181
188
|
|
|
189
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
190
|
+
const showUtilities = showClearButton;
|
|
191
|
+
|
|
182
192
|
const inputGroup = (
|
|
183
193
|
<div ref={textInputGroupRef}>
|
|
184
194
|
<TextInputGroup>
|
|
@@ -188,6 +198,8 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
188
198
|
onChange={handleInputChange}
|
|
189
199
|
onFocus={() => setMenuIsOpen(true)}
|
|
190
200
|
onKeyDown={handleTextInputKeyDown}
|
|
201
|
+
placeholder="search"
|
|
202
|
+
aria-label="Search input"
|
|
191
203
|
>
|
|
192
204
|
<ChipGroup>
|
|
193
205
|
{currentChips.map(currentChip => (
|
|
@@ -197,13 +209,15 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
197
209
|
))}
|
|
198
210
|
</ChipGroup>
|
|
199
211
|
</TextInputGroupMain>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
{showUtilities && (
|
|
213
|
+
<TextInputGroupUtilities>
|
|
214
|
+
{showClearButton && (
|
|
215
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button for chips and input">
|
|
216
|
+
<TimesIcon />
|
|
217
|
+
</Button>
|
|
218
|
+
)}
|
|
219
|
+
</TextInputGroupUtilities>
|
|
220
|
+
)}
|
|
207
221
|
</TextInputGroup>
|
|
208
222
|
</div>
|
|
209
223
|
);
|