@patternfly/react-core 4.183.7 → 4.183.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
  3. package/dist/esm/components/Tabs/Tabs.js +0 -2
  4. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  5. package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
  6. package/dist/js/components/Tabs/Tabs.js +0 -2
  7. package/dist/js/components/Tabs/Tabs.js.map +1 -1
  8. package/dist/umd/react-core.css +1 -0
  9. package/dist/umd/react-core.js +0 -2
  10. package/dist/umd/react-core.min.css +1 -0
  11. package/dist/umd/react-core.min.js +1 -1
  12. package/package.json +6 -6
  13. package/src/components/AboutModal/examples/AboutModal.md +4 -222
  14. package/src/components/AboutModal/examples/AboutModalBasic.tsx +46 -0
  15. package/src/components/AboutModal/examples/AboutModalComplexUserPositionedContent.tsx +52 -0
  16. package/src/components/AboutModal/examples/AboutModalCustomBackgroundImage.tsx +35 -0
  17. package/src/components/AboutModal/examples/AboutModalWithoutProductName.tsx +45 -0
  18. package/src/components/Tabs/Tabs.tsx +0 -2
  19. package/src/components/Tabs/examples/Tabs.md +6 -6
  20. package/src/components/TextInputGroup/examples/TextInputGroup.md +4 -123
  21. package/src/components/TextInputGroup/examples/TextInputGroupBasic.tsx +8 -0
  22. package/src/components/TextInputGroup/examples/TextInputGroupDisabled.tsx +8 -0
  23. package/src/components/TextInputGroup/examples/TextInputGroupFilters.tsx +69 -0
  24. package/src/components/TextInputGroup/examples/TextInputGroupUtilitiesAndIcon.tsx +34 -0
  25. package/src/demos/TextInputGroupDemo.md +2 -2
  26. package/src/demos/examples/TextInputGroup/{AttributeValueFiltering.js → AttributeValueFiltering.tsx} +22 -18
  27. package/src/demos/examples/TextInputGroup/{AutoCompleteSearch.js → AutoCompleteSearch.tsx} +18 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.183.7",
3
+ "version": "4.183.11",
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.34.7",
38
- "@patternfly/react-styles": "^4.33.7",
39
- "@patternfly/react-tokens": "^4.35.7",
37
+ "@patternfly/react-icons": "^4.34.11",
38
+ "@patternfly/react-styles": "^4.33.11",
39
+ "@patternfly/react-tokens": "^4.35.11",
40
40
  "focus-trap": "6.2.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.165.1",
46
+ "@patternfly/patternfly": "4.165.2",
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": "b5f21407c3c5a898ae3887ce0b2800d382de3458"
63
+ "gitHead": "eb15686e75744e702dfdf4c78d835945304ace8d"
64
64
  }
@@ -9,235 +9,17 @@ import bgImg from './patternfly-orb.svg';
9
9
 
10
10
  ## Examples
11
11
  ### Basic
12
- ```js
13
- import React from 'react';
14
- import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
15
- import brandImg from './examples/brandImg.svg';
16
-
17
- class SimpleAboutModal extends React.Component {
18
- constructor(props) {
19
- super(props);
20
- this.state = {
21
- isModalOpen: false
22
- };
23
- this.handleModalToggle = () => {
24
- this.setState(({ isModalOpen }) => ({
25
- isModalOpen: !isModalOpen
26
- }));
27
- };
28
- }
29
-
30
- render() {
31
- const { isModalOpen } = this.state;
32
-
33
- return (
34
- <React.Fragment>
35
- <Button variant="primary" onClick={this.handleModalToggle}>
36
- Show about modal
37
- </Button>
38
- <AboutModal
39
- isOpen={isModalOpen}
40
- onClose={this.handleModalToggle}
41
- trademark="Trademark and copyright information here"
42
- brandImageSrc={brandImg}
43
- brandImageAlt="Patternfly Logo"
44
- productName="Product Name"
45
- >
46
- <TextContent>
47
- <TextList component="dl">
48
- <TextListItem component="dt">CFME Version</TextListItem>
49
- <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
50
- <TextListItem component="dt">Cloudforms Version</TextListItem>
51
- <TextListItem component="dd">4.1</TextListItem>
52
- <TextListItem component="dt">Server Name</TextListItem>
53
- <TextListItem component="dd">40DemoMaster</TextListItem>
54
- <TextListItem component="dt">User Name</TextListItem>
55
- <TextListItem component="dd">Administrator</TextListItem>
56
- <TextListItem component="dt">User Role</TextListItem>
57
- <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
58
- <TextListItem component="dt">Browser Version</TextListItem>
59
- <TextListItem component="dd">601.2</TextListItem>
60
- <TextListItem component="dt">Browser OS</TextListItem>
61
- <TextListItem component="dd">Mac</TextListItem>
62
- </TextList>
63
- </TextContent>
64
- </AboutModal>
65
- </React.Fragment>
66
- );
67
- }
68
- }
12
+ ```ts file="./AboutModalBasic.tsx"
69
13
  ```
70
14
 
71
15
  ### Without product name
72
- ```js
73
- import React from 'react';
74
- import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
75
- import brandImg from './examples/brandImg.svg';
76
-
77
- class SimpleAboutModal extends React.Component {
78
- constructor(props) {
79
- super(props);
80
- this.state = {
81
- isModalOpen: false
82
- };
83
- this.handleModalToggle = () => {
84
- this.setState(({ isModalOpen }) => ({
85
- isModalOpen: !isModalOpen
86
- }));
87
- };
88
- }
89
-
90
- render() {
91
- const { isModalOpen } = this.state;
92
-
93
- return (
94
- <React.Fragment>
95
- <Button variant="primary" onClick={this.handleModalToggle}>
96
- Show about modal
97
- </Button>
98
- <AboutModal
99
- isOpen={isModalOpen}
100
- onClose={this.handleModalToggle}
101
- trademark="Trademark and copyright information here"
102
- brandImageSrc={brandImg}
103
- brandImageAlt="Patternfly Logo"
104
- >
105
- <TextContent>
106
- <TextList component="dl">
107
- <TextListItem component="dt">CFME Version</TextListItem>
108
- <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
109
- <TextListItem component="dt">Cloudforms Version</TextListItem>
110
- <TextListItem component="dd">4.1</TextListItem>
111
- <TextListItem component="dt">Server Name</TextListItem>
112
- <TextListItem component="dd">40DemoMaster</TextListItem>
113
- <TextListItem component="dt">User Name</TextListItem>
114
- <TextListItem component="dd">Administrator</TextListItem>
115
- <TextListItem component="dt">User Role</TextListItem>
116
- <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
117
- <TextListItem component="dt">Browser Version</TextListItem>
118
- <TextListItem component="dd">601.2</TextListItem>
119
- <TextListItem component="dt">Browser OS</TextListItem>
120
- <TextListItem component="dd">Mac</TextListItem>
121
- </TextList>
122
- </TextContent>
123
- </AboutModal>
124
- </React.Fragment>
125
- );
126
- }
127
- }
16
+ ```ts file="./AboutModalWithoutProductName.tsx"
128
17
  ```
129
18
 
130
19
  ### Complex user positioned content
131
- ```js
132
- import React from 'react';
133
- import { AboutModal, Alert, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
134
- import brandImg from './examples/brandImg.svg';
135
-
136
- class ContentRichAboutModal extends React.Component {
137
- constructor(props) {
138
- super(props);
139
- this.state = {
140
- isModalOpen: false
141
- };
142
- this.handleModalToggle = () => {
143
- this.setState(({ isModalOpen }) => ({
144
- isModalOpen: !isModalOpen
145
- }));
146
- };
147
- }
148
-
149
- render() {
150
- const { isModalOpen } = this.state;
151
-
152
- return (
153
- <React.Fragment>
154
- <Button variant="primary" onClick={this.handleModalToggle}>
155
- Show about modal
156
- </Button>
157
- <AboutModal
158
- isOpen={isModalOpen}
159
- onClose={this.handleModalToggle}
160
- trademark="Trademark and copyright information here"
161
- brandImageSrc={brandImg}
162
- brandImageAlt="Patternfly Logo"
163
- noAboutModalBoxContentContainer={true}
164
- productName="Product Name"
165
- >
166
- <TextContent id="test1" className="pf-u-py-xl">
167
- <h4>About</h4>
168
- <p>Content here</p>
169
- </TextContent>
170
- <Alert variant="info" title="Updates available" />
171
- <TextContent id="test2" className="pf-u-py-xl">
172
- <TextList component="dl">
173
- <TextListItem component="dt">CFME Version</TextListItem>
174
- <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
175
- <TextListItem component="dt">Cloudforms Version</TextListItem>
176
- <TextListItem component="dd">4.1</TextListItem>
177
- <TextListItem component="dt">Server Name</TextListItem>
178
- <TextListItem component="dd">40DemoMaster</TextListItem>
179
- <TextListItem component="dt">User Name</TextListItem>
180
- <TextListItem component="dd">Administrator</TextListItem>
181
- <TextListItem component="dt">User Role</TextListItem>
182
- <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
183
- <TextListItem component="dt">Browser Version</TextListItem>
184
- <TextListItem component="dd">601.2</TextListItem>
185
- <TextListItem component="dt">Browser OS</TextListItem>
186
- <TextListItem component="dd">Mac</TextListItem>
187
- </TextList>
188
- </TextContent>
189
- </AboutModal>
190
- </React.Fragment>
191
- );
192
- }
193
- }
20
+ ```ts file="./AboutModalComplexUserPositionedContent.tsx"
194
21
  ```
195
22
 
196
23
  ### Custom background image
197
- ```js
198
- import React from 'react';
199
- import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
200
- import brandImg from './examples/brandImg.svg';
201
- import bgImg from './examples/patternfly-orb.svg';
202
-
203
- class SimpleAboutModal extends React.Component {
204
- constructor(props) {
205
- super(props);
206
- this.state = {
207
- isModalOpen: false
208
- };
209
- this.handleModalToggle = () => {
210
- this.setState(({ isModalOpen }) => ({
211
- isModalOpen: !isModalOpen
212
- }));
213
- };
214
- }
215
-
216
- render() {
217
- const { isModalOpen } = this.state;
218
-
219
- return (
220
- <React.Fragment>
221
- <Button variant="primary" onClick={this.handleModalToggle}>
222
- Show about modal
223
- </Button>
224
- <AboutModal
225
- isOpen={isModalOpen}
226
- onClose={this.handleModalToggle}
227
- trademark="Trademark and copyright information here"
228
- brandImageSrc={brandImg}
229
- brandImageAlt="Patternfly Logo"
230
- backgroundImageSrc={bgImg}
231
- >
232
- <TextContent>
233
- <TextList component="dl">
234
- <TextListItem component="dt">CFME Version</TextListItem>
235
- <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
236
- </TextList>
237
- </TextContent>
238
- </AboutModal>
239
- </React.Fragment>
240
- );
241
- }
242
- }
24
+ ```ts file="./AboutModalCustomBackgroundImage.tsx"
243
25
  ```
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
3
+ import brandImg from './brandImg.svg';
4
+
5
+ export const AboutModalBasic: React.FunctionComponent = () => {
6
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
7
+
8
+ const toggleModal = () => {
9
+ setIsModalOpen(!isModalOpen);
10
+ };
11
+
12
+ return (
13
+ <React.Fragment>
14
+ <Button variant="primary" onClick={toggleModal}>
15
+ Show about modal
16
+ </Button>
17
+ <AboutModal
18
+ isOpen={isModalOpen}
19
+ onClose={toggleModal}
20
+ trademark="Trademark and copyright information here"
21
+ brandImageSrc={brandImg}
22
+ brandImageAlt="Patternfly Logo"
23
+ productName="Product Name"
24
+ >
25
+ <TextContent>
26
+ <TextList component="dl">
27
+ <TextListItem component="dt">CFME Version</TextListItem>
28
+ <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
29
+ <TextListItem component="dt">Cloudforms Version</TextListItem>
30
+ <TextListItem component="dd">4.1</TextListItem>
31
+ <TextListItem component="dt">Server Name</TextListItem>
32
+ <TextListItem component="dd">40DemoMaster</TextListItem>
33
+ <TextListItem component="dt">User Name</TextListItem>
34
+ <TextListItem component="dd">Administrator</TextListItem>
35
+ <TextListItem component="dt">User Role</TextListItem>
36
+ <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
37
+ <TextListItem component="dt">Browser Version</TextListItem>
38
+ <TextListItem component="dd">601.2</TextListItem>
39
+ <TextListItem component="dt">Browser OS</TextListItem>
40
+ <TextListItem component="dd">Mac</TextListItem>
41
+ </TextList>
42
+ </TextContent>
43
+ </AboutModal>
44
+ </React.Fragment>
45
+ );
46
+ };
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { AboutModal, Alert, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
3
+ import brandImg from './brandImg.svg';
4
+
5
+ export const AboutModalComplexUserPositionedContent: React.FunctionComponent = () => {
6
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
7
+
8
+ const toggleModal = () => {
9
+ setIsModalOpen(!isModalOpen);
10
+ };
11
+
12
+ return (
13
+ <React.Fragment>
14
+ <Button variant="primary" onClick={toggleModal}>
15
+ Show about modal
16
+ </Button>
17
+ <AboutModal
18
+ isOpen={isModalOpen}
19
+ onClose={toggleModal}
20
+ trademark="Trademark and copyright information here"
21
+ brandImageSrc={brandImg}
22
+ brandImageAlt="Patternfly Logo"
23
+ noAboutModalBoxContentContainer={true}
24
+ productName="Product Name"
25
+ >
26
+ <TextContent id="test1" className="pf-u-py-xl">
27
+ <h4>About</h4>
28
+ <p>Content here</p>
29
+ </TextContent>
30
+ <Alert variant="info" title="Updates available" />
31
+ <TextContent id="test2" className="pf-u-py-xl">
32
+ <TextList component="dl">
33
+ <TextListItem component="dt">CFME Version</TextListItem>
34
+ <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
35
+ <TextListItem component="dt">Cloudforms Version</TextListItem>
36
+ <TextListItem component="dd">4.1</TextListItem>
37
+ <TextListItem component="dt">Server Name</TextListItem>
38
+ <TextListItem component="dd">40DemoMaster</TextListItem>
39
+ <TextListItem component="dt">User Name</TextListItem>
40
+ <TextListItem component="dd">Administrator</TextListItem>
41
+ <TextListItem component="dt">User Role</TextListItem>
42
+ <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
43
+ <TextListItem component="dt">Browser Version</TextListItem>
44
+ <TextListItem component="dd">601.2</TextListItem>
45
+ <TextListItem component="dt">Browser OS</TextListItem>
46
+ <TextListItem component="dd">Mac</TextListItem>
47
+ </TextList>
48
+ </TextContent>
49
+ </AboutModal>
50
+ </React.Fragment>
51
+ );
52
+ };
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
3
+ import brandImg from './brandImg.svg';
4
+ import bgImg from './patternfly-orb.svg';
5
+
6
+ export const AboutModalCustomBackgroundImage: React.FunctionComponent = () => {
7
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
8
+
9
+ const toggleModal = () => {
10
+ setIsModalOpen(!isModalOpen);
11
+ };
12
+
13
+ return (
14
+ <React.Fragment>
15
+ <Button variant="primary" onClick={toggleModal}>
16
+ Show about modal
17
+ </Button>
18
+ <AboutModal
19
+ isOpen={isModalOpen}
20
+ onClose={toggleModal}
21
+ trademark="Trademark and copyright information here"
22
+ brandImageSrc={brandImg}
23
+ brandImageAlt="Patternfly Logo"
24
+ backgroundImageSrc={bgImg}
25
+ >
26
+ <TextContent>
27
+ <TextList component="dl">
28
+ <TextListItem component="dt">CFME Version</TextListItem>
29
+ <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
30
+ </TextList>
31
+ </TextContent>
32
+ </AboutModal>
33
+ </React.Fragment>
34
+ );
35
+ };
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { AboutModal, Button, TextContent, TextList, TextListItem } from '@patternfly/react-core';
3
+ import brandImg from './brandImg.svg';
4
+
5
+ export const AboutModalWithoutProductName: React.FunctionComponent = () => {
6
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
7
+
8
+ const toggleModal = () => {
9
+ setIsModalOpen(!isModalOpen);
10
+ };
11
+
12
+ return (
13
+ <React.Fragment>
14
+ <Button variant="primary" onClick={toggleModal}>
15
+ Show about modal
16
+ </Button>
17
+ <AboutModal
18
+ isOpen={isModalOpen}
19
+ onClose={toggleModal}
20
+ trademark="Trademark and copyright information here"
21
+ brandImageSrc={brandImg}
22
+ brandImageAlt="Patternfly Logo"
23
+ >
24
+ <TextContent>
25
+ <TextList component="dl">
26
+ <TextListItem component="dt">CFME Version</TextListItem>
27
+ <TextListItem component="dd">5.5.3.4.20102789036450</TextListItem>
28
+ <TextListItem component="dt">Cloudforms Version</TextListItem>
29
+ <TextListItem component="dd">4.1</TextListItem>
30
+ <TextListItem component="dt">Server Name</TextListItem>
31
+ <TextListItem component="dd">40DemoMaster</TextListItem>
32
+ <TextListItem component="dt">User Name</TextListItem>
33
+ <TextListItem component="dd">Administrator</TextListItem>
34
+ <TextListItem component="dt">User Role</TextListItem>
35
+ <TextListItem component="dd">EvmRole-super_administrator</TextListItem>
36
+ <TextListItem component="dt">Browser Version</TextListItem>
37
+ <TextListItem component="dd">601.2</TextListItem>
38
+ <TextListItem component="dt">Browser OS</TextListItem>
39
+ <TextListItem component="dd">Mac</TextListItem>
40
+ </TextList>
41
+ </TextContent>
42
+ </AboutModal>
43
+ </React.Fragment>
44
+ );
45
+ };
@@ -149,8 +149,6 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
149
149
  eventKey: number | string,
150
150
  tabContentRef: React.RefObject<any>
151
151
  ) {
152
- // When tab is an achor tag with href, cancel navigation event
153
- event.preventDefault();
154
152
  const { shownKeys } = this.state;
155
153
  const { onSelect, defaultActiveKey } = this.props;
156
154
  // if defaultActiveKey Tabs are uncontrolled, set new active key internally
@@ -890,22 +890,22 @@ class TabsNav extends React.Component {
890
890
  aria-label="Local"
891
891
  component={TabsComponent.nav}
892
892
  >
893
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} href="#">
893
+ <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} href="#users">
894
894
  Users
895
895
  </Tab>
896
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>} href="#">
896
+ <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>} href="#containers">
897
897
  Containers
898
898
  </Tab>
899
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>} href="#">
899
+ <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>} href="#database">
900
900
  Database
901
901
  </Tab>
902
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#">
902
+ <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#disabled">
903
903
  Disabled
904
904
  </Tab>
905
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#">
905
+ <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#aria-disabled">
906
906
  ARIA Disabled
907
907
  </Tab>
908
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>} href="#">
908
+ <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>} href="#network">
909
909
  Network
910
910
  </Tab>
911
911
  </Tabs>
@@ -13,139 +13,20 @@ import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
13
13
 
14
14
  ### Basic
15
15
 
16
- ```js
17
- import React from 'react';
18
- import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
19
-
20
- const BasicTextInputGroup = () => (
21
- <TextInputGroup>
22
- <TextInputGroupMain />
23
- </TextInputGroup>
24
- );
16
+ ```ts file="./TextInputGroupBasic.tsx"
25
17
  ```
26
18
 
27
19
  ### Disabled
28
20
 
29
- ```js
30
- import React from 'react';
31
- import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
32
-
33
- const DisabledTextInputGroup = () => (
34
- <TextInputGroup isDisabled>
35
- <TextInputGroupMain value="Disabled" type="text" aria-label="Disabled text input group example input" />
36
- </TextInputGroup>
37
- );
21
+ ```ts file="./TextInputGroupDisabled.tsx"
38
22
  ```
39
23
 
40
24
  ### Utilities and icon
41
25
 
42
- ```js
43
- import React from 'react';
44
- import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, Button } from '@patternfly/react-core';
45
- import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
46
- import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
47
-
48
- const TextInputGroupWithIcons = () => {
49
- const [inputValue, setInputValue] = React.useState('');
50
-
51
- /** callback for updating the inputValue state in this component so that the input can be controlled */
52
- const handleInputChange = (value, _event) => {
53
- setInputValue(value);
54
- };
55
-
56
- /** show the input clearing button only when the input is not empty */
57
- const showClearButton = inputValue;
58
-
59
- /** callback for clearing the text input */
60
- const clearInput = () => {
61
- setInputValue('');
62
- };
63
-
64
- return (
65
- <TextInputGroup>
66
- <TextInputGroupMain icon={<SearchIcon />} value={inputValue} onChange={handleInputChange} />
67
- <TextInputGroupUtilities>
68
- {showClearButton && (
69
- <Button variant="plain" onClick={clearInput} aria-label="Clear button and input">
70
- <TimesIcon />
71
- </Button>
72
- )}
73
- </TextInputGroupUtilities>
74
- </TextInputGroup>
75
- );
76
- };
26
+ ```ts file="./TextInputGroupUtilitiesAndIcon.tsx"
77
27
  ```
78
28
 
79
29
  ### Filters
80
30
 
81
- ```js
82
- import React from 'react';
83
- import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, Button } from '@patternfly/react-core';
84
- import { Chip, ChipGroup } from '@patternfly/react-core';
85
- import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
86
- import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
87
-
88
- const TextInputGroupWithChips = () => {
89
- const [inputValue, setInputValue] = React.useState('');
90
- const [currentChips, setCurrentChips] = React.useState([
91
- 'chip one',
92
- 'chip two',
93
- 'chip three',
94
- 'chip four',
95
- 'chip five',
96
- 'chip six',
97
- 'chip seven',
98
- 'chip eight',
99
- 'chip nine',
100
- 'chip ten',
101
- 'chip eleven',
102
- 'chip twelve',
103
- 'chip thirteen',
104
- 'chip fourteen'
105
- ]);
106
-
107
- /** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
108
- const showSearchIcon = !currentChips.length;
109
-
110
- /** callback for updating the inputValue state in this component so that the input can be controlled */
111
- const handleInputChange = (value, _event) => {
112
- setInputValue(value);
113
- };
114
-
115
- /** callback for removing a chip from the chip selections */
116
- const deleteChip = chipToDelete => {
117
- const newChips = currentChips.filter(chip => !Object.is(chip, chipToDelete));
118
- setCurrentChips(newChips);
119
- };
120
-
121
- /** show the input/chip clearing button only when either the text input or chip group are not empty */
122
- const showClearButton = inputValue || !!currentChips.length;
123
-
124
- /** callback for clearing all selected chips and the text input */
125
- const clearChipsAndInput = () => {
126
- setCurrentChips([]);
127
- setInputValue('');
128
- };
129
-
130
- return (
131
- <TextInputGroup>
132
- <TextInputGroupMain icon={showSearchIcon && <SearchIcon />} value={inputValue} onChange={handleInputChange}>
133
- <ChipGroup>
134
- {currentChips.map(currentChip => (
135
- <Chip key={currentChip} onClick={() => deleteChip(currentChip)}>
136
- {currentChip}
137
- </Chip>
138
- ))}
139
- </ChipGroup>
140
- </TextInputGroupMain>
141
- <TextInputGroupUtilities>
142
- {showClearButton && (
143
- <Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
144
- <TimesIcon />
145
- </Button>
146
- )}
147
- </TextInputGroupUtilities>
148
- </TextInputGroup>
149
- );
150
- };
31
+ ```ts file="./TextInputGroupFilters.tsx"
151
32
  ```
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
3
+
4
+ export const TextInputGroupBasic: React.FunctionComponent = () => (
5
+ <TextInputGroup>
6
+ <TextInputGroupMain />
7
+ </TextInputGroup>
8
+ );
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { TextInputGroup, TextInputGroupMain } from '@patternfly/react-core';
3
+
4
+ export const TextInputGroupDisabled: React.FunctionComponent = () => (
5
+ <TextInputGroup isDisabled>
6
+ <TextInputGroupMain value="Disabled" type="text" aria-label="Disabled text input group example input" />
7
+ </TextInputGroup>
8
+ );