@patternfly/react-core 4.251.4 → 4.252.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.251.4",
3
+ "version": "4.252.1",
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",
@@ -44,16 +44,16 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.92.7",
48
- "@patternfly/react-styles": "^4.91.7",
49
- "@patternfly/react-tokens": "^4.93.7",
47
+ "@patternfly/react-icons": "^4.92.8",
48
+ "@patternfly/react-styles": "^4.91.8",
49
+ "@patternfly/react-tokens": "^4.93.8",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
53
53
  "tslib": "^2.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@patternfly/patternfly": "4.218.0",
56
+ "@patternfly/patternfly": "4.219.0",
57
57
  "@rollup/plugin-commonjs": "^21.0.0",
58
58
  "@rollup/plugin-node-resolve": "^13.0.0",
59
59
  "@rollup/plugin-replace": "^3.0.0",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "449291fb1b567dc14afd99890cda544bfbe5f4ba"
73
+ "gitHead": "40db44d5598d9bcd5b729613a570fdc1887126b2"
74
74
  }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
4
4
  import styles from '@patternfly/react-styles/css/components/DataList/data-list';
5
- import { Button, ButtonVariant } from '../Button';
5
+ import { Button, ButtonProps, ButtonVariant } from '../Button';
6
6
 
7
7
  export interface DataListToggleProps extends React.HTMLProps<HTMLDivElement> {
8
8
  /** Additional classes added to the DataList cell */
@@ -19,6 +19,8 @@ export interface DataListToggleProps extends React.HTMLProps<HTMLDivElement> {
19
19
  'aria-label'?: string;
20
20
  /** Allows users of some screen readers to shift focus to the controlled element. Should be used when the controlled contents are not adjacent to the toggle that controls them. */
21
21
  'aria-controls'?: string;
22
+ /** Additional properties spread to the toggle button */
23
+ buttonProps?: ButtonProps;
22
24
  }
23
25
 
24
26
  export const DataListToggle: React.FunctionComponent<DataListToggleProps> = ({
@@ -28,6 +30,7 @@ export const DataListToggle: React.FunctionComponent<DataListToggleProps> = ({
28
30
  'aria-label': ariaLabel = 'Details',
29
31
  rowid = '',
30
32
  id,
33
+ buttonProps,
31
34
  ...props
32
35
  }: DataListToggleProps) => (
33
36
  <div className={css(styles.dataListItemControl, className)} {...props}>
@@ -39,6 +42,7 @@ export const DataListToggle: React.FunctionComponent<DataListToggleProps> = ({
39
42
  aria-label={ariaLabel}
40
43
  aria-labelledby={ariaLabel !== 'Details' ? null : `${rowid} ${id}`}
41
44
  aria-expanded={isExpanded}
45
+ {...buttonProps}
42
46
  >
43
47
  <div className={css(styles.dataListToggleIcon)}>
44
48
  <AngleRightIcon />
@@ -51,6 +51,11 @@ import { css } from '@patternfly/react-styles';
51
51
  ```ts file="./DataListExpandable.tsx"
52
52
  ```
53
53
 
54
+ ### Mixed expandable
55
+
56
+ ```ts file="./DataListMixedExpandable.tsx"
57
+ ```
58
+
54
59
  ### Width modifiers
55
60
 
56
61
  ```ts file="./DataListWidthModifiers.tsx"
@@ -0,0 +1,234 @@
1
+ import React from 'react';
2
+ import {
3
+ DataList,
4
+ DataListItem,
5
+ DataListItemRow,
6
+ DataListCell,
7
+ DataListAction,
8
+ DataListToggle,
9
+ DataListContent,
10
+ DataListItemCells,
11
+ Dropdown,
12
+ DropdownItem,
13
+ DropdownPosition,
14
+ KebabToggle
15
+ } from '@patternfly/react-core';
16
+ import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
17
+
18
+ export const DataListMixedExpandable: React.FunctionComponent = () => {
19
+ const [isOpen1, setIsOpen1] = React.useState(false);
20
+ const [isOpen2, setIsOpen2] = React.useState(false);
21
+ const [isOpen3, setIsOpen3] = React.useState(false);
22
+ const [expanded, setExpanded] = React.useState(['m-ex-toggle1', 'm-ex-toggle3']);
23
+
24
+ const onToggle1 = isOpen1 => {
25
+ setIsOpen1(isOpen1);
26
+ };
27
+
28
+ const onSelect1 = () => {
29
+ setIsOpen1(!isOpen1);
30
+ };
31
+
32
+ const onToggle2 = isOpen2 => {
33
+ setIsOpen2(isOpen2);
34
+ };
35
+
36
+ const onSelect2 = () => {
37
+ setIsOpen2(!isOpen2);
38
+ };
39
+
40
+ const onToggle3 = isOpen3 => {
41
+ setIsOpen3(isOpen3);
42
+ };
43
+
44
+ const onSelect3 = () => {
45
+ setIsOpen3(!isOpen3);
46
+ };
47
+
48
+ const toggle = id => {
49
+ const index = expanded.indexOf(id);
50
+ const newExpanded =
51
+ index >= 0 ? [...expanded.slice(0, index), ...expanded.slice(index + 1, expanded.length)] : [...expanded, id];
52
+ setExpanded(newExpanded);
53
+ };
54
+
55
+ return (
56
+ <React.Fragment>
57
+ <DataList aria-label="Mixed expandable data list example">
58
+ <DataListItem aria-labelledby="m-ex-item1" isExpanded={expanded.includes('m-ex-toggle1')}>
59
+ <DataListItemRow>
60
+ <DataListToggle
61
+ onClick={() => toggle('m-ex-toggle1')}
62
+ isExpanded={expanded.includes('m-ex-toggle1')}
63
+ id="m-ex-toggle1"
64
+ aria-controls="m-ex-expand1"
65
+ />
66
+ <DataListItemCells
67
+ dataListCells={[
68
+ <DataListCell isIcon key="icon">
69
+ <CodeBranchIcon />
70
+ </DataListCell>,
71
+ <DataListCell key="primary content">
72
+ <div id="m-ex-item1">Primary content</div>
73
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
74
+ <a href="#">link</a>
75
+ </DataListCell>,
76
+ <DataListCell key="secondary content">
77
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
78
+ </DataListCell>,
79
+ <DataListCell key="secondary content 2">
80
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
81
+ </DataListCell>
82
+ ]}
83
+ />
84
+ <DataListAction
85
+ aria-labelledby="m-ex-item1 m-ex-action1"
86
+ id="m-ex-action1"
87
+ aria-label="Actions"
88
+ isPlainButtonAction
89
+ >
90
+ <Dropdown
91
+ isPlain
92
+ position={DropdownPosition.right}
93
+ isOpen={isOpen1}
94
+ onSelect={onSelect1}
95
+ toggle={<KebabToggle onToggle={onToggle1} />}
96
+ dropdownItems={[
97
+ <DropdownItem key="link">Link</DropdownItem>,
98
+ <DropdownItem key="action" component="button">
99
+ Action
100
+ </DropdownItem>,
101
+ <DropdownItem key="disabled link" isDisabled>
102
+ Disabled Link
103
+ </DropdownItem>
104
+ ]}
105
+ />
106
+ </DataListAction>
107
+ </DataListItemRow>
108
+ <DataListContent
109
+ aria-label="First expandable content details"
110
+ id="m-ex-expand1"
111
+ isHidden={!expanded.includes('m-ex-toggle1')}
112
+ >
113
+ <p>
114
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
115
+ dolore magna aliqua.
116
+ </p>
117
+ </DataListContent>
118
+ </DataListItem>
119
+ <DataListItem aria-labelledby="m-ex-item2">
120
+ <DataListItemRow>
121
+ <DataListToggle
122
+ id="m-ex-toggle2"
123
+ buttonProps={{
124
+ disabled: true,
125
+ 'aria-hidden': 'true',
126
+ style: { visibility: 'hidden' }
127
+ }}
128
+ />
129
+ <DataListItemCells
130
+ dataListCells={[
131
+ <DataListCell isIcon key="icon">
132
+ <CodeBranchIcon />
133
+ </DataListCell>,
134
+ <DataListCell key="secondary content">
135
+ <div id="m-ex-item2">Secondary content</div>
136
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
137
+ </DataListCell>,
138
+ <DataListCell key="secondary content 2">
139
+ <span>Lorem ipsum dolor sit amet.</span>
140
+ </DataListCell>,
141
+ <DataListCell key="secondary content3">
142
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
143
+ </DataListCell>
144
+ ]}
145
+ />
146
+ <DataListAction
147
+ aria-labelledby="m-ex-item2 mex-action2"
148
+ id="m-ex-action2"
149
+ aria-label="Actions"
150
+ isPlainButtonAction
151
+ >
152
+ <Dropdown
153
+ isPlain
154
+ position={DropdownPosition.right}
155
+ isOpen={isOpen2}
156
+ onSelect={onSelect2}
157
+ toggle={<KebabToggle onToggle={onToggle2} />}
158
+ dropdownItems={[
159
+ <DropdownItem key="link">Link</DropdownItem>,
160
+ <DropdownItem key="action" component="button">
161
+ Action
162
+ </DropdownItem>,
163
+ <DropdownItem key="disabled link" isDisabled>
164
+ Disabled Link
165
+ </DropdownItem>
166
+ ]}
167
+ />
168
+ </DataListAction>
169
+ </DataListItemRow>
170
+ </DataListItem>
171
+ <DataListItem aria-labelledby="m-ex-item3" isExpanded={expanded.includes('m-ex-toggle3')}>
172
+ <DataListItemRow>
173
+ <DataListToggle
174
+ onClick={() => toggle('m-ex-toggle3')}
175
+ isExpanded={expanded.includes('m-ex-toggle3')}
176
+ id="m-ex-toggle3"
177
+ aria-controls="m-ex-expand3"
178
+ />
179
+ <DataListItemCells
180
+ dataListCells={[
181
+ <DataListCell isIcon key="icon">
182
+ <CodeBranchIcon />
183
+ </DataListCell>,
184
+ <DataListCell key="tertiary content">
185
+ <div id="m-ex-item3">Tertiary content</div>
186
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
187
+ </DataListCell>,
188
+ <DataListCell key="secondary content">
189
+ <span>Lorem ipsum dolor sit amet.</span>
190
+ </DataListCell>,
191
+ <DataListCell key="secondary content 2">
192
+ <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
193
+ </DataListCell>
194
+ ]}
195
+ />
196
+ <DataListAction
197
+ aria-labelledby="m-ex-item3 m-ex-action3"
198
+ id="m-ex-action3"
199
+ aria-label="Actions"
200
+ isPlainButtonAction
201
+ >
202
+ <Dropdown
203
+ isPlain
204
+ position={DropdownPosition.right}
205
+ isOpen={isOpen3}
206
+ onSelect={onSelect3}
207
+ toggle={<KebabToggle onToggle={onToggle3} />}
208
+ dropdownItems={[
209
+ <DropdownItem key="link">Link</DropdownItem>,
210
+ <DropdownItem key="action" component="button">
211
+ Action
212
+ </DropdownItem>,
213
+ <DropdownItem key="disabled link" isDisabled>
214
+ Disabled Link
215
+ </DropdownItem>
216
+ ]}
217
+ />
218
+ </DataListAction>
219
+ </DataListItemRow>
220
+ <DataListContent
221
+ aria-label="Third expandable content details"
222
+ id="m-ex-expand3"
223
+ isHidden={!expanded.includes('m-ex-toggle3')}
224
+ >
225
+ <p>
226
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
227
+ dolore magna aliqua.
228
+ </p>
229
+ </DataListContent>
230
+ </DataListItem>
231
+ </DataList>
232
+ </React.Fragment>
233
+ );
234
+ };
@@ -9,120 +9,16 @@ propComponents: ['SimpleList', 'SimpleListGroup', 'SimpleListItem']
9
9
 
10
10
  ### Simple list
11
11
 
12
- ```js
13
- import React from 'react';
14
- import { SimpleList, SimpleListItem } from '@patternfly/react-core';
15
-
16
- class SimpleListDemo extends React.Component {
17
- onSelect(selectedItem, selectedItemProps) {
18
- console.log('new selection SimpleListDemo', selectedItem, selectedItemProps);
19
- }
20
-
21
- render() {
22
- const items = [
23
- <SimpleListItem key="item1" isActive>
24
- List item 1
25
- </SimpleListItem>,
26
- <SimpleListItem key="item2" component="a" href="#">
27
- List item 2
28
- </SimpleListItem>,
29
- <SimpleListItem key="item3">List item 3</SimpleListItem>
30
- ];
31
-
32
- return (
33
- <SimpleList onSelect={this.onSelect} aria-label="Simple List Example">
34
- {items}
35
- </SimpleList>
36
- );
37
- }
38
- }
12
+ ```ts file="SimpleListBasic.tsx"
39
13
  ```
40
14
 
41
15
  ### Grouped list
42
16
 
43
- ```js
44
- import React from 'react';
45
- import { SimpleList, SimpleListItem, SimpleListGroup } from '@patternfly/react-core';
46
-
47
- class SimpleListGroupDemo extends React.Component {
48
- onSelect(selectedItem, selectedItemProps) {
49
- console.log('new selection SimpleListGroupDemo', selectedItem, selectedItemProps);
50
- }
51
-
52
- render() {
53
- const group1Items = [
54
- <SimpleListItem key="item1" isActive>
55
- List item 1
56
- </SimpleListItem>,
57
- <SimpleListItem key="item2" id="test 2">
58
- List item 2
59
- </SimpleListItem>,
60
- <SimpleListItem key="item3">List item 3</SimpleListItem>,
61
- <SimpleListItem key="item4">List item 4</SimpleListItem>
62
- ];
63
-
64
- const group2Items = [
65
- <SimpleListItem key="item5">List item 1</SimpleListItem>,
66
- <SimpleListItem key="item6" component="a" href="#">
67
- List item 2
68
- </SimpleListItem>,
69
- <SimpleListItem key="item7" component="a" href="#">
70
- List item 3
71
- </SimpleListItem>,
72
- <SimpleListItem key="item8">List item 4</SimpleListItem>
73
- ];
74
-
75
- return (
76
- <SimpleList onSelect={this.onSelect} aria-label="Grouped List Example">
77
- <SimpleListGroup title="Group 1" id="group-1">
78
- {group1Items}
79
- </SimpleListGroup>
80
- <SimpleListGroup title="Group 2" id="group-2">
81
- {group2Items}
82
- </SimpleListGroup>
83
- </SimpleList>
84
- );
85
- }
86
- }
17
+ ```ts file="SimpleListGrouped.tsx"
87
18
  ```
88
19
 
89
20
  ### Uncontrolled simple list
90
21
 
91
- ```js
92
- import React from 'react';
93
- import { SimpleList, SimpleListItem } from '@patternfly/react-core';
94
-
95
- class SimpleListUncontrolledDemo extends React.Component {
96
- constructor(props) {
97
- super(props);
98
- this.state = {
99
- activeItem: 0
100
- };
101
- this.onSelect = (selectedItem, selectedItemProps) => {
102
- console.log('new selection SimpleListUncontrolledDemo', selectedItem, selectedItemProps);
103
- this.setState({ activeItem: selectedItemProps.itemId });
104
- };
105
- }
106
-
107
- render() {
108
- const { activeItem } = this.state;
109
- const items = [
110
- <SimpleListItem key="item1" itemId={0} isActive={activeItem === 0}>
111
- List item 1
112
- </SimpleListItem>,
113
- <SimpleListItem key="item2" itemId={1} isActive={activeItem === 1}>
114
- List item 2
115
- </SimpleListItem>,
116
- <SimpleListItem key="item3" itemId={2} isActive={activeItem === 2}>
117
- List item 3
118
- </SimpleListItem>
119
- ];
120
-
121
- return (
122
- <SimpleList onSelect={this.onSelect} isControlled={false} aria-label="Uncontrolled Simple List Example">
123
- {items}
124
- </SimpleList>
125
- );
126
- }
127
- }
22
+ ```ts file="SimpleListUncontrolled.tsx"
128
23
  ```
24
+
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { SimpleList, SimpleListItem } from '@patternfly/react-core';
3
+
4
+ export const SimpleListBasic: React.FunctionComponent = () => {
5
+ const items = [
6
+ <SimpleListItem key="item1" isActive>
7
+ List item 1
8
+ </SimpleListItem>,
9
+ <SimpleListItem key="item2" component="a" href="#">
10
+ List item 2
11
+ </SimpleListItem>,
12
+ <SimpleListItem key="item3">List item 3</SimpleListItem>
13
+ ];
14
+
15
+ return <SimpleList aria-label="Simple List Example">{items}</SimpleList>;
16
+ };
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { SimpleList, SimpleListItem, SimpleListGroup } from '@patternfly/react-core';
3
+
4
+ export const SimpleListGrouped: React.FunctionComponent = () => {
5
+ const group1Items = [
6
+ <SimpleListItem key="item1" isActive>
7
+ List item 1
8
+ </SimpleListItem>,
9
+ <SimpleListItem key="item2">List item 2</SimpleListItem>,
10
+ <SimpleListItem key="item3">List item 3</SimpleListItem>,
11
+ <SimpleListItem key="item4">List item 4</SimpleListItem>
12
+ ];
13
+
14
+ const group2Items = [
15
+ <SimpleListItem key="item5">List item 1</SimpleListItem>,
16
+ <SimpleListItem key="item6" component="a" href="#">
17
+ List item 2
18
+ </SimpleListItem>,
19
+ <SimpleListItem key="item7" component="a" href="#">
20
+ List item 3
21
+ </SimpleListItem>,
22
+ <SimpleListItem key="item8">List item 4</SimpleListItem>
23
+ ];
24
+
25
+ return (
26
+ <SimpleList aria-label="Grouped simple list example">
27
+ <SimpleListGroup title="Group 1" id="group-1">
28
+ {group1Items}
29
+ </SimpleListGroup>
30
+ <SimpleListGroup title="Group 2" id="group-2">
31
+ {group2Items}
32
+ </SimpleListGroup>
33
+ </SimpleList>
34
+ );
35
+ };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { SimpleList, SimpleListItem, SimpleListItemProps } from '@patternfly/react-core';
3
+
4
+ export const SimpleListUncontrolled: React.FunctionComponent = () => {
5
+ const [activeItem, setActiveItem] = React.useState(0);
6
+
7
+ const onSelect = (
8
+ selectedItem: React.RefObject<HTMLButtonElement> | React.RefObject<HTMLAnchorElement>,
9
+ selectedItemProps: SimpleListItemProps
10
+ ) => {
11
+ setActiveItem(selectedItemProps.itemId as number);
12
+ };
13
+
14
+ const items = [
15
+ <SimpleListItem key="item1" itemId={0} isActive={activeItem === 0}>
16
+ List item 1
17
+ </SimpleListItem>,
18
+ <SimpleListItem key="item2" itemId={1} isActive={activeItem === 1}>
19
+ List item 2
20
+ </SimpleListItem>,
21
+ <SimpleListItem key="item3" itemId={2} isActive={activeItem === 2}>
22
+ List item 3
23
+ </SimpleListItem>
24
+ ];
25
+
26
+ return (
27
+ <SimpleList onSelect={onSelect} isControlled={false} aria-label="Uncontrolled Simple List Example">
28
+ {items}
29
+ </SimpleList>
30
+ );
31
+ };