@patternfly/react-core 4.258.6 → 4.258.8

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 (30) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  3. package/dist/esm/components/TimePicker/TimePicker.js +15 -2
  4. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  5. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  6. package/dist/js/components/TimePicker/TimePicker.js +15 -2
  7. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  8. package/dist/umd/react-core.min.js +1 -1
  9. package/package.json +2 -2
  10. package/src/components/TextArea/examples/TextArea.md +12 -260
  11. package/src/components/TextArea/examples/TextAreaAutoResizing.tsx +14 -0
  12. package/src/components/TextArea/examples/TextAreaBasic.tsx +7 -0
  13. package/src/components/TextArea/examples/TextAreaDisabled.tsx +6 -0
  14. package/src/components/TextArea/examples/TextAreaHorizontallyResizable.tsx +14 -0
  15. package/src/components/TextArea/examples/TextAreaIconSprite.tsx +41 -0
  16. package/src/components/TextArea/examples/TextAreaInvalid.tsx +15 -0
  17. package/src/components/TextArea/examples/TextAreaReadOnly.tsx +25 -0
  18. package/src/components/TextArea/examples/TextAreaUncontrolled.tsx +6 -0
  19. package/src/components/TextArea/examples/TextAreaValidated.tsx +52 -0
  20. package/src/components/TextArea/examples/TextAreaVerticallyResizable.tsx +14 -0
  21. package/src/components/TimePicker/TimePicker.tsx +18 -2
  22. package/src/components/TimePicker/__tests__/TimePicker.test.tsx +8 -5
  23. package/src/components/ToggleGroup/examples/ToggleGroup.md +5 -191
  24. package/src/components/ToggleGroup/examples/ToggleGroupCompact.tsx +30 -0
  25. package/src/components/ToggleGroup/examples/ToggleGroupDefaultMultiple.tsx +43 -0
  26. package/src/components/ToggleGroup/examples/ToggleGroupDefaultSingle.tsx +32 -0
  27. package/src/components/ToggleGroup/examples/ToggleGroupIcon.tsx +42 -0
  28. package/src/components/ToggleGroup/examples/ToggleGroupTextIcon.tsx +42 -0
  29. package/src/demos/Card/Card.md +3 -2
  30. package/src/demos/PrimaryDetail.md +4 -6
@@ -14,207 +14,21 @@ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square
14
14
  ## Examples
15
15
 
16
16
  ### Default with multiple selectable
17
- ```js
18
- import React from 'react';
19
- import { ToggleGroup, ToggleGroupItem, Button, Stack, StackItem } from '@patternfly/react-core';
20
-
21
- class DefaultToggleGroupExample extends React.Component {
22
- constructor(props) {
23
- super(props);
24
- this.state = {
25
- isSelected: {
26
- first: false,
27
- second: false,
28
- disableAll: false
29
- }
30
- };
31
- this.handleItemClick = (isSelected, event) => {
32
- const id = event.currentTarget.id;
33
- this.setState(prevState => {
34
- prevState.isSelected[id] = isSelected;
35
- return {
36
- isSelected: prevState.isSelected
37
- };
38
- });
39
- };
40
- this.disableAllClick = () => {
41
- this.setState(prevState => ({ disableAll: !prevState.disableAll }));
42
- };
43
- }
44
-
45
- render() {
46
- const { isSelected } = this.state;
47
-
48
- return (
49
- <Stack hasGutter>
50
- <StackItem>
51
- <Button onClick={this.disableAllClick}>
52
- {this.state.disableAll ? "Enable back" : "Disable all"}
53
- </Button>
54
- </StackItem>
55
- <StackItem>
56
- <ToggleGroup areAllGroupsDisabled={this.state.disableAll} aria-label="Default with multiple selectable">
57
- <ToggleGroupItem text="Option 1" key={0} buttonId="first" isSelected={isSelected.first} onChange={this.handleItemClick} />
58
- <ToggleGroupItem text="Option 2" key={1} buttonId="second" isSelected={isSelected.second} onChange={this.handleItemClick} />
59
- <ToggleGroupItem text="Option 3" key={2} isDisabled/>
60
- </ToggleGroup>
61
- </StackItem>
62
- </Stack>
63
- );
64
- }
65
- }
17
+ ```ts file="./ToggleGroupDefaultMultiple.tsx"
66
18
  ```
67
19
 
68
20
  ### Default with single selectable
69
- ```js
70
- import React from 'react';
71
- import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
72
-
73
- class DefaultAsRadioToggleGroupExample extends React.Component {
74
- constructor(props) {
75
- super(props);
76
- this.state = {
77
- isSelected: ""
78
- };
79
- this.handleItemClick = (isSelected, event) => {
80
- const id = event.currentTarget.id;
81
- this.setState({ isSelected: id });
82
- };
83
- }
84
-
85
- render() {
86
- const { isSelected } = this.state;
87
-
88
- return (
89
- <ToggleGroup aria-label="Default with single selectable">
90
- <ToggleGroupItem text="Option 1" buttonId="firstRadio" isSelected={isSelected === "firstRadio"} onChange={this.handleItemClick} />
91
- <ToggleGroupItem text="Option 2" buttonId="secondRadio" isSelected={isSelected === "secondRadio"} onChange={this.handleItemClick} />
92
- <ToggleGroupItem text="Option 3" buttonId="thirdRadio" isSelected={isSelected === "thirdRadio"} onChange={this.handleItemClick} />
93
- </ToggleGroup>
94
- );
95
- }
96
- }
21
+ ```ts file="./ToggleGroupDefaultSingle.tsx"
97
22
  ```
98
23
 
99
24
  ### Icons
100
- ```js
101
- import React from 'react';
102
- import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
103
- import UndoIcon from '@patternfly/react-icons/dist/esm/icons/undo-icon';
104
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
105
- import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square-icon';
106
-
107
- class IconToggleGroupExample extends React.Component {
108
- constructor(props) {
109
- super(props);
110
- this.state = {
111
- isSelected: {
112
- "icons-1": false,
113
- "icons-2": false,
114
- "icons-3": true
115
- }
116
- };
117
- this.handleItemClick = (isSelected, event) => {
118
- const id = event.currentTarget.id;
119
- this.setState(prevState => {
120
- prevState.isSelected[id] = isSelected;
121
- return {
122
- isSelected: prevState.isSelected
123
- };
124
- });
125
- };
126
- }
127
-
128
- render() {
129
- const { isSelected } = this.state;
130
- return (
131
- <ToggleGroup aria-label="Icon variant toggle group">
132
- <ToggleGroupItem icon={<CopyIcon />} aria-label="copy icon button" buttonId="icons-1" isSelected={isSelected["icons-1"]} onChange={this.handleItemClick} />
133
- <ToggleGroupItem icon={<UndoIcon />} aria-label="undo icon button" buttonId="icons-2" isSelected={isSelected["icons-2"]} onChange={this.handleItemClick} />
134
- <ToggleGroupItem icon={<ShareSquareIcon />} aria-label="share square icon button" buttonId="icons-3" isSelected={isSelected["icons-3"]} onChange={this.handleItemClick} />
135
- </ToggleGroup>
136
- );
137
- }
138
- }
25
+ ```ts file="./ToggleGroupIcon.tsx"
139
26
  ```
140
27
 
141
28
  ### Text and icons
142
- ```js
143
- import React from 'react';
144
- import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
145
- import UndoIcon from '@patternfly/react-icons/dist/esm/icons/undo-icon';
146
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
147
- import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square-icon';
148
-
149
- class TextIconToggleGroupExample extends React.Component {
150
- constructor(props) {
151
- super(props);
152
- this.state = {
153
- isSelected: {
154
- "text-icons-1": false,
155
- "text-icons-2": false,
156
- "text-icons-3": true
157
- }
158
- };
159
- this.handleItemClick = (isSelected, event) => {
160
- const id = event.currentTarget.id;
161
- this.setState(prevState => {
162
- prevState.isSelected[id] = isSelected;
163
- return {
164
- isSelected: prevState.isSelected
165
- };
166
- });
167
- };
168
- }
169
-
170
- render() {
171
- const { isSelected } = this.state;
172
- return (
173
- <ToggleGroup aria-label="Icon variant toggle group">
174
- <ToggleGroupItem icon={<CopyIcon />} text="Copy" aria-label="copy icon button" buttonId="text-icons-1" isSelected={isSelected["text-icons-1"]} onChange={this.handleItemClick} />
175
- <ToggleGroupItem icon={<UndoIcon />} text="Undo" aria-label="undo icon button" buttonId="text-icons-2" isSelected={isSelected["text-icons-2"]} onChange={this.handleItemClick} />
176
- <ToggleGroupItem icon={<ShareSquareIcon />} text="Share" aria-label="share square icon button" buttonId="text-icons-3" isSelected={isSelected["text-icons-3"]} onChange={this.handleItemClick} />
177
- </ToggleGroup>
178
- );
179
- }
180
- }
29
+ ```ts file="./ToggleGroupTextIcon.tsx"
181
30
  ```
182
31
 
183
32
  ### Compact variant
184
- ```js
185
- import React from 'react';
186
- import { ToggleGroup, ToggleGroupItem, ToggleGroupVariant } from '@patternfly/react-core';
187
-
188
- class CompactToggleGroupExample extends React.Component {
189
- constructor(props) {
190
- super(props);
191
- this.state = {
192
- isSelected: {
193
- "compact-1": false,
194
- "compact-2": false
195
- }
196
- };
197
- this.handleItemClick = (isSelected, event) => {
198
- const id = event.currentTarget.id;
199
- this.setState(prevState => {
200
- prevState.isSelected[id] = isSelected;
201
- return {
202
- isSelected: prevState.isSelected
203
- };
204
- });
205
- };
206
- }
207
-
208
- render() {
209
- const { isSelected } = this.state;
210
-
211
- return (
212
- <ToggleGroup isCompact aria-label="Compact variant toggle group">
213
- <ToggleGroupItem text="Option 1" buttonId="compact-1" isSelected={isSelected["compact-1"]} onChange={this.handleItemClick} />
214
- <ToggleGroupItem text="Option 2" buttonId="compact-2" isSelected={isSelected["compact-2"]} onChange={this.handleItemClick} />
215
- <ToggleGroupItem text="Option 3" isDisabled />
216
- </ToggleGroup>
217
- );
218
- }
219
- }
33
+ ```ts file="./ToggleGroupCompact.tsx"
220
34
  ```
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
3
+
4
+ export const ToggleGroupCompact: React.FunctionComponent = () => {
5
+ const [isSelected, setIsSelected] = React.useState({
6
+ 'toggle-group-compact-1': false,
7
+ 'toggle-group-compact-2': false
8
+ });
9
+ const handleItemClick = (isSelected: boolean, event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent) => {
10
+ const id = event.currentTarget.id;
11
+ setIsSelected(prevIsSelected => ({ ...prevIsSelected, [id]: isSelected }));
12
+ };
13
+ return (
14
+ <ToggleGroup isCompact aria-label="Compact variant toggle group">
15
+ <ToggleGroupItem
16
+ text="Option 1"
17
+ buttonId="toggle-group-compact-1"
18
+ isSelected={isSelected['toggle-group-compact-1']}
19
+ onChange={handleItemClick}
20
+ />
21
+ <ToggleGroupItem
22
+ text="Option 2"
23
+ buttonId="toggle-group-compact-2"
24
+ isSelected={isSelected['toggle-group-compact-2']}
25
+ onChange={handleItemClick}
26
+ />
27
+ <ToggleGroupItem text="Option 3" isDisabled />
28
+ </ToggleGroup>
29
+ );
30
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { ToggleGroup, ToggleGroupItem, Button, Stack, StackItem } from '@patternfly/react-core';
3
+
4
+ export const ToggleGroupDefaultMultiple: React.FunctionComponent = () => {
5
+ const [isSelected, setIsSelected] = React.useState({
6
+ 'toggle-group-multiple-1': false,
7
+ 'toggle-group-multiple-2': false
8
+ });
9
+ const [disableAll, setDisableAll] = React.useState(false);
10
+ const handleItemClick = (isSelected: boolean, event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent) => {
11
+ const id = event.currentTarget.id;
12
+ setIsSelected(prevIsSelected => ({ ...prevIsSelected, [id]: isSelected }));
13
+ };
14
+ const disableAllClick = () => {
15
+ setDisableAll(!disableAll);
16
+ };
17
+ return (
18
+ <Stack hasGutter>
19
+ <StackItem>
20
+ <Button onClick={disableAllClick}>{disableAll ? 'Enable back' : 'Disable all'}</Button>
21
+ </StackItem>
22
+ <StackItem>
23
+ <ToggleGroup areAllGroupsDisabled={disableAll} aria-label="Default with multiple selectable">
24
+ <ToggleGroupItem
25
+ text="Option 1"
26
+ key={0}
27
+ buttonId="toggle-group-multiple-1"
28
+ isSelected={isSelected['toggle-group-multiple-1']}
29
+ onChange={handleItemClick}
30
+ />
31
+ <ToggleGroupItem
32
+ text="Option 2"
33
+ key={1}
34
+ buttonId="toggle-group-multiple-2"
35
+ isSelected={isSelected['toggle-group-multiple-2']}
36
+ onChange={handleItemClick}
37
+ />
38
+ <ToggleGroupItem text="Option 3" key={2} isDisabled />
39
+ </ToggleGroup>
40
+ </StackItem>
41
+ </Stack>
42
+ );
43
+ };
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
3
+
4
+ export const ToggleGroupDefaultSingle: React.FunctionComponent = () => {
5
+ const [isSelected, setIsSelected] = React.useState('');
6
+ const handleItemClick = (isSelected: boolean, event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent) => {
7
+ const id = event.currentTarget.id;
8
+ setIsSelected(id);
9
+ };
10
+ return (
11
+ <ToggleGroup aria-label="Default with single selectable">
12
+ <ToggleGroupItem
13
+ text="Option 1"
14
+ buttonId="toggle-group-single-1"
15
+ isSelected={isSelected === 'toggle-group-single-1'}
16
+ onChange={handleItemClick}
17
+ />
18
+ <ToggleGroupItem
19
+ text="Option 2"
20
+ buttonId="toggle-group-single-2"
21
+ isSelected={isSelected === 'toggle-group-single-2'}
22
+ onChange={handleItemClick}
23
+ />
24
+ <ToggleGroupItem
25
+ text="Option 3"
26
+ buttonId="toggle-group-single-3"
27
+ isSelected={isSelected === 'toggle-group-single-3'}
28
+ onChange={handleItemClick}
29
+ />
30
+ </ToggleGroup>
31
+ );
32
+ };
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
3
+ import UndoIcon from '@patternfly/react-icons/dist/esm/icons/undo-icon';
4
+ import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
5
+ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square-icon';
6
+
7
+ export const ToggleGroupIcon: React.FunctionComponent = () => {
8
+ const [isSelected, setIsSelected] = React.useState({
9
+ 'toggle-group-icons-1': false,
10
+ 'toggle-group-icons-2': false,
11
+ 'toggle-group-icons-3': true
12
+ });
13
+ const handleItemClick = (isSelected: boolean, event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent) => {
14
+ const id = event.currentTarget.id;
15
+ setIsSelected(prevIsSelected => ({ ...prevIsSelected, [id]: isSelected }));
16
+ };
17
+ return (
18
+ <ToggleGroup aria-label="Icon variant toggle group">
19
+ <ToggleGroupItem
20
+ icon={<CopyIcon />}
21
+ aria-label="copy"
22
+ buttonId="toggle-group-icons-1"
23
+ isSelected={isSelected['toggle-group-icons-1']}
24
+ onChange={handleItemClick}
25
+ />
26
+ <ToggleGroupItem
27
+ icon={<UndoIcon />}
28
+ aria-label="undo"
29
+ buttonId="toggle-group-icons-2"
30
+ isSelected={isSelected['toggle-group-icons-2']}
31
+ onChange={handleItemClick}
32
+ />
33
+ <ToggleGroupItem
34
+ icon={<ShareSquareIcon />}
35
+ aria-label="share square"
36
+ buttonId="toggle-group-icons-3"
37
+ isSelected={isSelected['toggle-group-icons-3']}
38
+ onChange={handleItemClick}
39
+ />
40
+ </ToggleGroup>
41
+ );
42
+ };
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
3
+ import UndoIcon from '@patternfly/react-icons/dist/esm/icons/undo-icon';
4
+ import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
5
+ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square-icon';
6
+
7
+ export const ToggleGroupIcon: React.FunctionComponent = () => {
8
+ const [isSelected, setIsSelected] = React.useState({
9
+ 'text-icons-1': false,
10
+ 'text-icons-2': false,
11
+ 'text-icons-3': true
12
+ });
13
+ const handleItemClick = (isSelected: boolean, event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent) => {
14
+ const id = event.currentTarget.id;
15
+ setIsSelected(prevIsSelected => ({ ...prevIsSelected, [id]: isSelected }));
16
+ };
17
+ return (
18
+ <ToggleGroup aria-label="Text and icon toggle group">
19
+ <ToggleGroupItem
20
+ icon={<CopyIcon />}
21
+ text="Copy"
22
+ buttonId="toggle-group-text-icons-1"
23
+ isSelected={isSelected['toggle-group-text-icons-1']}
24
+ onChange={handleItemClick}
25
+ />
26
+ <ToggleGroupItem
27
+ icon={<UndoIcon />}
28
+ text="Undo"
29
+ buttonId="toggle-group-text-icons-2"
30
+ isSelected={isSelected['toggle-group-text-icons-2']}
31
+ onChange={handleItemClick}
32
+ />
33
+ <ToggleGroupItem
34
+ icon={<ShareSquareIcon />}
35
+ text="Share"
36
+ buttonId="toggle-group-text-icons-3"
37
+ isSelected={isSelected['toggle-group-text-icons-3']}
38
+ onChange={handleItemClick}
39
+ />
40
+ </ToggleGroup>
41
+ );
42
+ };
@@ -426,11 +426,12 @@ class CardViewBasic extends React.Component {
426
426
  aria-label={anySelected ? 'Deselect all' : 'Select all'}
427
427
  isChecked={areAllSelected}
428
428
  onClick={this.splitCheckboxSelectAll.bind(this)}
429
- ></DropdownToggleCheckbox>
429
+ >
430
+ {numSelected !== 0 && `${numSelected} selected`}
431
+ </DropdownToggleCheckbox>
430
432
  ]}
431
433
  onToggle={this.onSplitButtonToggle}
432
434
  >
433
- {numSelected !== 0 && <React.Fragment>{numSelected} selected</React.Fragment>}
434
435
  </DropdownToggle>
435
436
  }
436
437
  isOpen={splitButtonDropdownIsOpen}
@@ -1369,14 +1369,12 @@ class PrimaryDetailCardView extends React.Component {
1369
1369
  aria-label={anySelected ? 'Deselect all' : 'Select all'}
1370
1370
  isChecked={areAllSelected}
1371
1371
  onClick={this.splitCheckboxSelectAll}
1372
- ></DropdownToggleCheckbox>
1372
+ >
1373
+ {numSelected !== 0 && `${numSelected} selected`}
1374
+ </DropdownToggleCheckbox>
1373
1375
  ]}
1374
1376
  onToggle={this.onSplitButtonToggle}
1375
- >
1376
- {numSelected !== 0 && (
1377
- <React.Fragment>{allSelected ? this.state.totalItemCount : numSelected} selected</React.Fragment>
1378
- )}
1379
- </DropdownToggle>
1377
+ ></DropdownToggle>
1380
1378
  }
1381
1379
  isOpen={splitButtonDropdownIsOpen}
1382
1380
  dropdownItems={splitButtonDropdownItems}