@patternfly/react-core 4.199.0 → 4.199.3

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 (45) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +5 -5
  3. package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
  4. package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
  5. package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
  6. package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
  7. package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
  8. package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
  9. package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
  10. package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
  11. package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
  12. package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
  13. package/src/components/Button/__tests__/Button.test.tsx +116 -107
  14. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
  15. package/src/components/Card/__tests__/Card.test.tsx +119 -100
  16. package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
  17. package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
  18. package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
  19. package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
  20. package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
  21. package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
  22. package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
  23. package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
  24. package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
  25. package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
  26. package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
  27. package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
  28. package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
  29. package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
  30. package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
  31. package/src/components/Checkbox/examples/Checkbox.md +11 -115
  32. package/src/components/Checkbox/examples/CheckboxControlled.tsx +78 -0
  33. package/src/components/Checkbox/examples/CheckboxDisabled.tsx +9 -0
  34. package/src/components/Checkbox/examples/CheckboxStandaloneInput.tsx +6 -0
  35. package/src/components/Checkbox/examples/CheckboxUncontrolled.tsx +9 -0
  36. package/src/components/Checkbox/examples/CheckboxWithBody.tsx +6 -0
  37. package/src/components/Checkbox/examples/CheckboxWithDescription.tsx +10 -0
  38. package/src/components/Checkbox/examples/CheckboxWithDescriptionBody.tsx +11 -0
  39. package/src/components/Chip/examples/Chip.md +1 -73
  40. package/src/components/Chip/examples/ChipDefault.tsx +68 -0
  41. package/src/components/ChipGroup/examples/ChipGroup.md +6 -134
  42. package/src/components/ChipGroup/examples/ChipGroupInline.tsx +28 -0
  43. package/src/components/ChipGroup/examples/ChipGroupRemovableCategories.tsx +46 -0
  44. package/src/components/ChipGroup/examples/ChipGroupWithCategories.tsx +28 -0
  45. package/src/layouts/Flex/examples/Flex.md +1 -1
@@ -10,77 +10,5 @@ ouia: true
10
10
 
11
11
  ### Default
12
12
 
13
- ```js
14
- import React from 'react';
15
- import { Badge, Chip } from '@patternfly/react-core';
16
-
17
- class SingleChip extends React.Component {
18
- constructor(props) {
19
- super(props);
20
- this.state = {
21
- chip: {
22
- name: 'Chip 1'
23
- },
24
- longchip: {
25
- name: 'Really long chip that goes on and on'
26
- },
27
- badgechip: {
28
- name: 'Chip',
29
- isRead: true,
30
- count: 7
31
- },
32
- readonlychip: {
33
- name: 'Read-only chip'
34
- },
35
- overflowchip: {
36
- name: 'Overflow chip'
37
- }
38
- };
39
- this.deleteItem = id => {
40
- this.setState({ [id]: null });
41
- };
42
- }
43
-
44
- render() {
45
- const { chip, longchip, badgechip, readonlychip, overflowchip } = this.state;
46
- return (
47
- <React.Fragment>
48
- {chip && (
49
- <React.Fragment>
50
- <Chip key="chip1" onClick={() => this.deleteItem('chip')}>
51
- {chip.name}
52
- </Chip>
53
- <br /> <br />
54
- </React.Fragment>
55
- )}
56
- {longchip && (
57
- <React.Fragment>
58
- <Chip key="chip2" onClick={() => this.deleteItem('longchip')}>
59
- {longchip.name}
60
- </Chip>
61
- <br /> <br />
62
- </React.Fragment>
63
- )}
64
- {badgechip && (
65
- <React.Fragment>
66
- <Chip key="chip3" onClick={() => this.deleteItem('badgechip')}>
67
- {badgechip.name}
68
- <Badge isRead={badgechip.isRead}>{badgechip.count}</Badge>
69
- </Chip>
70
- <br /> <br />
71
- </React.Fragment>
72
- )}
73
- <Chip key="chip4" onClick={() => this.deleteItem('readonlychip')} isReadOnly>
74
- {readonlychip.name}
75
- </Chip>
76
- <br /> <br />
77
- {overflowchip && (
78
- <Chip key="chip5" component="button" onClick={() => this.deleteItem('overflowchip')} isOverflowChip>
79
- {overflowchip.name}
80
- </Chip>
81
- )}
82
- </React.Fragment>
83
- );
84
- }
85
- }
13
+ ```ts file='./ChipDefault.tsx'
86
14
  ```
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { Badge, Chip } from '@patternfly/react-core';
3
+
4
+ export const ChipDefault: React.FunctionComponent = () => {
5
+ const [chips, setChips] = React.useState({
6
+ chip: {
7
+ name: 'Chip 1'
8
+ },
9
+ longchip: {
10
+ name: 'Really long chip that goes on and on'
11
+ },
12
+ badgechip: {
13
+ name: 'Chip',
14
+ isRead: true,
15
+ count: 7
16
+ },
17
+ readonlychip: {
18
+ name: 'Read-only chip'
19
+ },
20
+ overflowchip: {
21
+ name: 'Overflow chip'
22
+ }
23
+ });
24
+
25
+ const deleteItem = (id: string) => {
26
+ setChips({ ...chips, [id]: null });
27
+ };
28
+
29
+ const { chip, longchip, badgechip, readonlychip, overflowchip } = chips;
30
+ return (
31
+ <React.Fragment>
32
+ {chip && (
33
+ <React.Fragment>
34
+ <Chip key="chip1" onClick={() => deleteItem('chip')}>
35
+ {chip.name}
36
+ </Chip>
37
+ <br /> <br />
38
+ </React.Fragment>
39
+ )}
40
+ {longchip && (
41
+ <React.Fragment>
42
+ <Chip key="chip2" onClick={() => deleteItem('longchip')}>
43
+ {longchip.name}
44
+ </Chip>
45
+ <br /> <br />
46
+ </React.Fragment>
47
+ )}
48
+ {badgechip && (
49
+ <React.Fragment>
50
+ <Chip key="chip3" onClick={() => deleteItem('badgechip')}>
51
+ {badgechip.name}
52
+ <Badge isRead={badgechip.isRead}>{badgechip.count}</Badge>
53
+ </Chip>
54
+ <br /> <br />
55
+ </React.Fragment>
56
+ )}
57
+ <Chip key="chip4" onClick={() => deleteItem('readonlychip')} isReadOnly>
58
+ {readonlychip.name}
59
+ </Chip>
60
+ <br /> <br />
61
+ {overflowchip && (
62
+ <Chip key="chip5" component="button" onClick={() => deleteItem('overflowchip')} isOverflowChip>
63
+ {overflowchip.name}
64
+ </Chip>
65
+ )}
66
+ </React.Fragment>
67
+ );
68
+ };
@@ -8,145 +8,17 @@ ouia: true
8
8
 
9
9
  ## Examples
10
10
 
11
- ### Simple inline chip group
11
+ ### Simple inline
12
12
 
13
- ```js
14
- import React from 'react';
15
- import { Chip, ChipGroup } from '@patternfly/react-core';
16
-
17
- class SimpleInlineChipGroup extends React.Component {
18
- constructor(props) {
19
- super(props);
20
- this.state = {
21
- chips: ['Chip one', 'Really long chip that goes on and on', 'Chip three', 'Chip four', 'Chip five']
22
- };
23
-
24
- this.deleteItem = id => {
25
- const copyOfChips = this.state.chips;
26
- const index = copyOfChips.indexOf(id);
27
- if (index !== -1) {
28
- copyOfChips.splice(index, 1);
29
- this.setState({ chips: copyOfChips });
30
- }
31
- };
32
- }
33
-
34
- render() {
35
- const { chips } = this.state;
36
-
37
- return (
38
- <ChipGroup>
39
- {chips.map(currentChip => (
40
- <Chip key={currentChip} onClick={() => this.deleteItem(currentChip)}>
41
- {currentChip}
42
- </Chip>
43
- ))}
44
- </ChipGroup>
45
- );
46
- }
47
- }
13
+ ```ts file='./ChipGroupInline.tsx'
48
14
  ```
49
15
 
50
- ### Chip groups with categories
51
-
52
- ```js
53
- import React from 'react';
54
- import { Chip, ChipGroup } from '@patternfly/react-core';
55
-
56
- class SimpleCategoryChipGroup extends React.Component {
57
- constructor(props) {
58
- super(props);
59
- this.state = {
60
- chips: ['Chip one', 'Chip two', 'Chip three', 'Chip four', 'Chip five']
61
- };
62
- this.deleteItem = id => {
63
- const copyOfChips = this.state.chips;
64
- const index = copyOfChips.indexOf(id);
65
- if (index !== -1) {
66
- copyOfChips.splice(index, 1);
67
- this.setState({ chips: copyOfChips });
68
- }
69
- };
70
- }
71
-
72
- render() {
73
- const { chips } = this.state;
16
+ ### With categories
74
17
 
75
- return (
76
- <ChipGroup categoryName="Category one">
77
- {chips.map(currentChip => (
78
- <Chip key={currentChip} onClick={() => this.deleteItem(currentChip)}>
79
- {currentChip}
80
- </Chip>
81
- ))}
82
- </ChipGroup>
83
- );
84
- }
85
- }
18
+ ```ts file='./ChipGroupWithCategories.tsx'
86
19
  ```
87
20
 
88
- ### Chip groups with categories removable
89
-
90
- ```js
91
- import React from 'react';
92
- import { Chip, ChipGroup } from '@patternfly/react-core';
93
-
94
- class CategoryChipGroupRemovable extends React.Component {
95
- constructor(props) {
96
- super(props);
97
- this.state = {
98
- chips: ['Chip one', 'Chip two', 'Chip three'],
99
- chips2: ['Chip one', 'Chip two', 'Chip three', 'Chip 4']
100
- };
101
- this.deleteItem = id => {
102
- const copyOfChips = this.state.chips;
103
- const index = copyOfChips.indexOf(id);
104
- if (index !== -1) {
105
- copyOfChips.splice(index, 1);
106
- this.setState({ chips: copyOfChips });
107
- }
108
- };
109
-
110
- this.deleteItem2 = id => {
111
- const copyOfChips = this.state.chips2;
112
- const index = copyOfChips.indexOf(id);
113
- if (index !== -1) {
114
- copyOfChips.splice(index, 1);
115
- this.setState({ chips2: copyOfChips });
116
- }
117
- };
118
-
119
- this.deleteCategory = () => {
120
- this.setState({ chips: [] });
121
- };
122
-
123
- this.deleteCategory2 = () => {
124
- this.setState({ chips2: [] });
125
- };
126
- }
127
-
128
- render() {
129
- const { chips, chips2 } = this.state;
21
+ ### With removable categories
130
22
 
131
- return (
132
- <React.Fragment>
133
- <ChipGroup categoryName="Category one" isClosable onClick={this.deleteCategory}>
134
- {chips.map(currentChip => (
135
- <Chip key={currentChip} onClick={() => this.deleteItem(currentChip)}>
136
- {currentChip}
137
- </Chip>
138
- ))}
139
- </ChipGroup>
140
- <br /> <br />
141
- <ChipGroup categoryName="Category two has a very long name" isClosable onClick={this.deleteCategory2}>
142
- {chips2.map(currentChip => (
143
- <Chip key={currentChip} onClick={() => this.deleteItem2(currentChip)}>
144
- {currentChip}
145
- </Chip>
146
- ))}
147
- </ChipGroup>
148
- </React.Fragment>
149
- );
150
- }
151
- }
23
+ ```ts file='./ChipGroupRemovableCategories.tsx'
152
24
  ```
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { Chip, ChipGroup } from '@patternfly/react-core';
3
+
4
+ export const ChipGroupInline: React.FunctionComponent = () => {
5
+ const [chips, setChips] = React.useState([
6
+ 'Chip one',
7
+ 'Really long chip that goes on and on',
8
+ 'Chip three',
9
+ 'Chip four',
10
+ 'Chip five'
11
+ ]);
12
+
13
+ const deleteItem = (id: string) => {
14
+ const copyOfChips = [...chips];
15
+ const filteredCopy = copyOfChips.filter(chip => chip !== id);
16
+ setChips(filteredCopy);
17
+ };
18
+
19
+ return (
20
+ <ChipGroup>
21
+ {chips.map(currentChip => (
22
+ <Chip key={currentChip} onClick={() => deleteItem(currentChip)}>
23
+ {currentChip}
24
+ </Chip>
25
+ ))}
26
+ </ChipGroup>
27
+ );
28
+ };
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { Chip, ChipGroup } from '@patternfly/react-core';
3
+
4
+ export const ChipGroupRemovableCategories: React.FunctionComponent = () => {
5
+ const [chipGroup1, setChipGroup1] = React.useState(['Chip one', 'Chip two', 'Chip three']);
6
+ const [chipGroup2, setChipGroup2] = React.useState(['Chip one', 'Chip two', 'Chip three', 'Chip four']);
7
+
8
+ const deleteItem = (id: string, group: string[]) => {
9
+ const copyOfChips = [...group];
10
+ const filteredCopy = copyOfChips.filter(chip => chip !== id);
11
+
12
+ if (group === chipGroup1) {
13
+ setChipGroup1(filteredCopy);
14
+ } else {
15
+ setChipGroup2(filteredCopy);
16
+ }
17
+ };
18
+
19
+ const deleteCategory = (group: string[]) => {
20
+ if (group === chipGroup1) {
21
+ setChipGroup1([]);
22
+ } else {
23
+ setChipGroup2([]);
24
+ }
25
+ };
26
+
27
+ return (
28
+ <React.Fragment>
29
+ <ChipGroup categoryName="Category one" isClosable onClick={() => deleteCategory(chipGroup1)}>
30
+ {chipGroup1.map(currentChip => (
31
+ <Chip key={currentChip} onClick={() => deleteItem(currentChip, chipGroup1)}>
32
+ {currentChip}
33
+ </Chip>
34
+ ))}
35
+ </ChipGroup>
36
+ <br /> <br />
37
+ <ChipGroup categoryName="Category two has a very long name" isClosable onClick={() => deleteCategory(chipGroup2)}>
38
+ {chipGroup2.map(currentChip => (
39
+ <Chip key={currentChip} onClick={() => deleteItem(currentChip, chipGroup2)}>
40
+ {currentChip}
41
+ </Chip>
42
+ ))}
43
+ </ChipGroup>
44
+ </React.Fragment>
45
+ );
46
+ };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { Chip, ChipGroup } from '@patternfly/react-core';
3
+
4
+ export const ChipGroupWithCategories: React.FunctionComponent = () => {
5
+ const [chips, setChips] = React.useState([
6
+ 'Chip one',
7
+ 'Really long chip that goes on and on',
8
+ 'Chip three',
9
+ 'Chip four',
10
+ 'Chip five'
11
+ ]);
12
+
13
+ const deleteItem = (id: string) => {
14
+ const copyOfChips = [...chips];
15
+ const filteredCopy = copyOfChips.filter(chip => chip !== id);
16
+ setChips(filteredCopy);
17
+ };
18
+
19
+ return (
20
+ <ChipGroup categoryName="Category one">
21
+ {chips.map(currentChip => (
22
+ <Chip key={currentChip} onClick={() => deleteItem(currentChip)}>
23
+ {currentChip}
24
+ </Chip>
25
+ ))}
26
+ </ChipGroup>
27
+ );
28
+ };
@@ -81,7 +81,7 @@ import { Flex, FlexItem } from '@patternfly/react-core';
81
81
  import React from 'react';
82
82
  import { Flex, FlexItem } from '@patternfly/react-core';
83
83
 
84
- <Flex spaceItems={{ modifier: 'spaceItemsXl' }}>
84
+ <Flex spaceItems={{ default: 'spaceItemsXl' }}>
85
85
  <FlexItem>Flex item</FlexItem>
86
86
  <FlexItem>Flex item</FlexItem>
87
87
  <FlexItem>Flex item</FlexItem>