@patternfly/react-core 4.202.24 → 4.202.27

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 (36) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/Select/Select.d.ts +2 -0
  3. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  4. package/dist/esm/components/Select/Select.js +3 -3
  5. package/dist/esm/components/Select/Select.js.map +1 -1
  6. package/dist/esm/components/Select/SelectToggle.d.ts +2 -0
  7. package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
  8. package/dist/esm/components/Select/SelectToggle.js +3 -3
  9. package/dist/esm/components/Select/SelectToggle.js.map +1 -1
  10. package/dist/js/components/Select/Select.d.ts +2 -0
  11. package/dist/js/components/Select/Select.d.ts.map +1 -1
  12. package/dist/js/components/Select/Select.js +3 -3
  13. package/dist/js/components/Select/Select.js.map +1 -1
  14. package/dist/js/components/Select/SelectToggle.d.ts +2 -0
  15. package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
  16. package/dist/js/components/Select/SelectToggle.js +3 -3
  17. package/dist/js/components/Select/SelectToggle.js.map +1 -1
  18. package/dist/styles/base.css +5 -0
  19. package/dist/umd/react-core.css +4 -4
  20. package/dist/umd/react-core.js +6 -6
  21. package/dist/umd/react-core.min.css +4 -4
  22. package/dist/umd/react-core.min.js +1 -1
  23. package/package.json +6 -6
  24. package/src/components/DataList/examples/DataList.md +10 -1193
  25. package/src/components/DataList/examples/DataListActions.tsx +100 -0
  26. package/src/components/DataList/examples/DataListBasic.tsx +33 -0
  27. package/src/components/DataList/examples/DataListCheckboxes.tsx +200 -0
  28. package/src/components/DataList/examples/DataListCompact.tsx +33 -0
  29. package/src/components/DataList/examples/DataListControllingText.tsx +29 -0
  30. package/src/components/DataList/examples/DataListDraggable.tsx +98 -0
  31. package/src/components/DataList/examples/DataListExpandable.tsx +261 -0
  32. package/src/components/DataList/examples/DataListSelectableRows.tsx +120 -0
  33. package/src/components/DataList/examples/DataListSmGridBreakpoint.tsx +22 -0
  34. package/src/components/DataList/examples/DataListWidthModifiers.tsx +204 -0
  35. package/src/components/Select/Select.tsx +4 -0
  36. package/src/components/Select/SelectToggle.tsx +5 -0
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ Dropdown,
5
+ DropdownItem,
6
+ DropdownPosition,
7
+ KebabToggle,
8
+ DataList,
9
+ DataListItem,
10
+ DataListCell,
11
+ DataListItemRow,
12
+ DataListItemCells,
13
+ DataListAction
14
+ } from '@patternfly/react-core';
15
+
16
+ export const DataListActions: React.FunctionComponent = () => {
17
+ const [isOpen, setIsOpen] = React.useState(false);
18
+ const [isDeleted, setIsDeleted] = React.useState(false);
19
+
20
+ const onToggle = isOpen => {
21
+ setIsOpen(isOpen);
22
+ };
23
+
24
+ const onSelect = () => {
25
+ setIsOpen(!isOpen);
26
+ };
27
+
28
+ return (
29
+ <React.Fragment>
30
+ <DataList aria-label="single action data list example ">
31
+ {!isDeleted && (
32
+ <DataListItem aria-labelledby="single-action-item1">
33
+ <DataListItemRow>
34
+ <DataListItemCells
35
+ dataListCells={[
36
+ <DataListCell key="primary content">
37
+ <span id="single-action-item1">Single actionable Primary content</span>
38
+ </DataListCell>,
39
+ <DataListCell key="secondary content">Single actionable Secondary content</DataListCell>
40
+ ]}
41
+ />
42
+ <DataListAction
43
+ aria-labelledby="single-action-item1 single-action-action1"
44
+ id="single-action-action1"
45
+ aria-label="Actions"
46
+ >
47
+ <Button
48
+ onClick={() => {
49
+ if (confirm('Are you sure?')) {
50
+ setIsDeleted(true);
51
+ }
52
+ }}
53
+ variant="primary"
54
+ key="delete-action"
55
+ >
56
+ Delete
57
+ </Button>
58
+ </DataListAction>
59
+ </DataListItemRow>
60
+ </DataListItem>
61
+ )}
62
+ <DataListItem aria-labelledby="multi-actions-item1">
63
+ <DataListItemRow>
64
+ <DataListItemCells
65
+ dataListCells={[
66
+ <DataListCell key="primary content">
67
+ <span id="multi-actions-item1">Multi actions Primary content</span>
68
+ </DataListCell>,
69
+ <DataListCell key="secondary content">Multi actions Secondary content</DataListCell>
70
+ ]}
71
+ />
72
+ <DataListAction
73
+ aria-labelledby="multi-actions-item1 multi-actions-action1"
74
+ id="multi-actions-action1"
75
+ aria-label="Actions"
76
+ isPlainButtonAction
77
+ >
78
+ <Dropdown
79
+ isPlain
80
+ position={DropdownPosition.right}
81
+ isOpen={isOpen}
82
+ onSelect={onSelect}
83
+ toggle={<KebabToggle onToggle={onToggle} />}
84
+ dropdownItems={[
85
+ <DropdownItem key="link">Link</DropdownItem>,
86
+ <DropdownItem key="action" component="button">
87
+ Action
88
+ </DropdownItem>,
89
+ <DropdownItem key="disabled link" isDisabled>
90
+ Disabled Link
91
+ </DropdownItem>
92
+ ]}
93
+ />
94
+ </DataListAction>
95
+ </DataListItemRow>
96
+ </DataListItem>
97
+ </DataList>
98
+ </React.Fragment>
99
+ );
100
+ };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell } from '@patternfly/react-core';
3
+
4
+ export const DataListBasic: React.FunctionComponent = () => (
5
+ <DataList aria-label="Simple data list example">
6
+ <DataListItem aria-labelledby="simple-item1">
7
+ <DataListItemRow>
8
+ <DataListItemCells
9
+ dataListCells={[
10
+ <DataListCell key="primary content">
11
+ <span id="simple-item1">Primary content</span>
12
+ </DataListCell>,
13
+ <DataListCell key="secondary content">Secondary content</DataListCell>
14
+ ]}
15
+ />
16
+ </DataListItemRow>
17
+ </DataListItem>
18
+ <DataListItem aria-labelledby="simple-item2">
19
+ <DataListItemRow>
20
+ <DataListItemCells
21
+ dataListCells={[
22
+ <DataListCell isFilled={false} key="secondary content fill">
23
+ <span id="simple-item2">Secondary content (pf-m-no-fill)</span>
24
+ </DataListCell>,
25
+ <DataListCell isFilled={false} alignRight key="secondary content align">
26
+ Secondary content (pf-m-align-right pf-m-no-fill)
27
+ </DataListCell>
28
+ ]}
29
+ />
30
+ </DataListItemRow>
31
+ </DataListItem>
32
+ </DataList>
33
+ );
@@ -0,0 +1,200 @@
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ DataList,
5
+ DataListItem,
6
+ DataListItemCells,
7
+ DataListItemRow,
8
+ DataListCell,
9
+ DataListCheck,
10
+ DataListAction,
11
+ Dropdown,
12
+ DropdownItem,
13
+ DropdownPosition,
14
+ KebabToggle
15
+ } from '@patternfly/react-core';
16
+
17
+ export const DataListCheckboxes: React.FunctionComponent = () => {
18
+ const [isOpen1, setIsOpen1] = React.useState(false);
19
+ const [isOpen2, setIsOpen2] = React.useState(false);
20
+ const [isOpen3, setIsOpen3] = React.useState(false);
21
+
22
+ const onToggle1 = isOpen1 => {
23
+ setIsOpen1(isOpen1);
24
+ };
25
+
26
+ const onSelect1 = () => {
27
+ setIsOpen1(!isOpen1);
28
+ };
29
+
30
+ const onToggle2 = isOpen2 => {
31
+ setIsOpen2(isOpen2);
32
+ };
33
+
34
+ const onSelect2 = () => {
35
+ setIsOpen2(!isOpen2);
36
+ };
37
+ const onToggle3 = isOpen3 => {
38
+ setIsOpen3(isOpen3);
39
+ };
40
+
41
+ const onSelect3 = () => {
42
+ setIsOpen3(!isOpen3);
43
+ };
44
+ return (
45
+ <DataList aria-label="Checkbox and action data list example">
46
+ <DataListItem aria-labelledby="check-action-item1">
47
+ <DataListItemRow>
48
+ <DataListCheck aria-labelledby="check-action-item1" name="check-action-check1" />
49
+ <DataListItemCells
50
+ dataListCells={[
51
+ <DataListCell key="primary content">
52
+ <span id="check-action-item1">Primary content</span> Dolor sit amet, consectetur adipisicing elit, sed
53
+ do eiusmod.
54
+ </DataListCell>,
55
+ <DataListCell key="secondary content 1">
56
+ Secondary content. Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
57
+ </DataListCell>,
58
+ <DataListCell key="secondary content 2">
59
+ <span>Tertiary content</span> Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
60
+ </DataListCell>,
61
+ <DataListCell key="more content 1">
62
+ <span>More content</span> Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
63
+ </DataListCell>,
64
+ <DataListCell key="more content 2">
65
+ <span>More content</span> Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
66
+ </DataListCell>
67
+ ]}
68
+ />
69
+ <DataListAction
70
+ aria-labelledby="check-action-item1 check-action-action1"
71
+ id="check-action-action1"
72
+ aria-label="Actions"
73
+ isPlainButtonAction
74
+ >
75
+ <Dropdown
76
+ isPlain
77
+ position={DropdownPosition.right}
78
+ isOpen={isOpen1}
79
+ onSelect={onSelect1}
80
+ toggle={<KebabToggle onToggle={onToggle1} />}
81
+ dropdownItems={[
82
+ <DropdownItem key="link">Link</DropdownItem>,
83
+ <DropdownItem key="action" component="button">
84
+ Action
85
+ </DropdownItem>,
86
+ <DropdownItem key="disabled link" isDisabled>
87
+ Disabled Link
88
+ </DropdownItem>
89
+ ]}
90
+ />
91
+ </DataListAction>
92
+ </DataListItemRow>
93
+ </DataListItem>
94
+ <DataListItem aria-labelledby="check-action-item2">
95
+ <DataListItemRow>
96
+ <DataListCheck aria-labelledby="check-action-item2" name="check-action-check2" />
97
+ <DataListItemCells
98
+ dataListCells={[
99
+ <DataListCell key="primary content">
100
+ <span id="check-action-item2">Primary content - Lorem ipsum</span> dolor sit amet, consectetur
101
+ adipisicing elit, sed do eiusmod.
102
+ </DataListCell>,
103
+ <DataListCell key="secondary content">
104
+ Secondary content. Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
105
+ </DataListCell>
106
+ ]}
107
+ />
108
+ <DataListAction
109
+ visibility={{ lg: 'hidden' }}
110
+ aria-labelledby="check-action-item2 check-action-action2"
111
+ id="check-action-action2"
112
+ aria-label="Actions"
113
+ isPlainButtonAction
114
+ >
115
+ <Dropdown
116
+ isPlain
117
+ position={DropdownPosition.right}
118
+ isOpen={isOpen2}
119
+ onSelect={onSelect2}
120
+ toggle={<KebabToggle onToggle={onToggle2} />}
121
+ dropdownItems={[
122
+ <DropdownItem key="pri-action2" component="button">
123
+ Primary
124
+ </DropdownItem>,
125
+ <DropdownItem key="sec-action2" component="button">
126
+ Secondary
127
+ </DropdownItem>
128
+ ]}
129
+ />
130
+ </DataListAction>
131
+ <DataListAction
132
+ visibility={{ default: 'hidden', lg: 'visible' }}
133
+ aria-labelledby="check-action-item2 check-action-action2"
134
+ id="check-action-action2"
135
+ aria-label="Actions"
136
+ >
137
+ <Button variant="primary">Primary</Button>
138
+ <Button variant="secondary">Secondary</Button>
139
+ </DataListAction>
140
+ </DataListItemRow>
141
+ </DataListItem>
142
+ <DataListItem aria-labelledby="check-action-item3">
143
+ <DataListItemRow>
144
+ <DataListCheck aria-labelledby="check-action-item3" name="check-action-check3" />
145
+ <DataListItemCells
146
+ dataListCells={[
147
+ <DataListCell key="primary content">
148
+ <span id="check-action-item3">Primary content - Lorem ipsum</span> dolor sit amet, consectetur
149
+ adipisicing elit, sed do eiusmod.
150
+ </DataListCell>,
151
+ <DataListCell key="secondary content">
152
+ Secondary content. Dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
153
+ </DataListCell>
154
+ ]}
155
+ />
156
+ <DataListAction
157
+ visibility={{ xl: 'hidden' }}
158
+ aria-labelledby="check-action-item3 check-action-action3"
159
+ id="check-actiokn-action3"
160
+ aria-label="Actions"
161
+ isPlainButtonAction
162
+ >
163
+ <Dropdown
164
+ isPlain
165
+ position={DropdownPosition.right}
166
+ isOpen={isOpen3}
167
+ onSelect={onSelect3}
168
+ toggle={<KebabToggle onToggle={onToggle3} />}
169
+ dropdownItems={[
170
+ <DropdownItem key="pri-action3" component="button">
171
+ Primary
172
+ </DropdownItem>,
173
+ <DropdownItem key="sec1-action3" component="button">
174
+ Secondary
175
+ </DropdownItem>,
176
+ <DropdownItem key="sec2-action3" component="button">
177
+ Secondary
178
+ </DropdownItem>,
179
+ <DropdownItem key="sec3-action3" component="button">
180
+ Secondary
181
+ </DropdownItem>
182
+ ]}
183
+ />
184
+ </DataListAction>
185
+ <DataListAction
186
+ visibility={{ default: 'hidden', xl: 'visible' }}
187
+ aria-labelledby="check-action-item3 check-action-action3"
188
+ id="check-action-action3"
189
+ aria-label="Actions"
190
+ >
191
+ <Button variant="primary">Primary</Button>
192
+ <Button variant="secondary">Secondary</Button>
193
+ <Button variant="secondary">Secondary</Button>
194
+ <Button variant="secondary">Secondary</Button>
195
+ </DataListAction>
196
+ </DataListItemRow>
197
+ </DataListItem>
198
+ </DataList>
199
+ );
200
+ };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell } from '@patternfly/react-core';
3
+
4
+ export const DataListCompact: React.FunctionComponent = () => (
5
+ <DataList aria-label="Compact data list example" isCompact>
6
+ <DataListItem aria-labelledby="simple-item1">
7
+ <DataListItemRow>
8
+ <DataListItemCells
9
+ dataListCells={[
10
+ <DataListCell key="primary content">
11
+ <span id="simple-item1">Primary content</span>
12
+ </DataListCell>,
13
+ <DataListCell key="secondary content">Secondary content</DataListCell>
14
+ ]}
15
+ />
16
+ </DataListItemRow>
17
+ </DataListItem>
18
+ <DataListItem aria-labelledby="simple-item2">
19
+ <DataListItemRow>
20
+ <DataListItemCells
21
+ dataListCells={[
22
+ <DataListCell isFilled={false} key="secondary content fill">
23
+ <span id="simple-item2">Secondary content (pf-m-no-fill)</span>
24
+ </DataListCell>,
25
+ <DataListCell isFilled={false} alignRight key="secondary content align">
26
+ Secondary content (pf-m-align-right pf-m-no-fill)
27
+ </DataListCell>
28
+ ]}
29
+ />
30
+ </DataListItemRow>
31
+ </DataListItem>
32
+ </DataList>
33
+ );
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import {
3
+ DataList,
4
+ DataListItem,
5
+ DataListItemRow,
6
+ DataListItemCells,
7
+ DataListCell,
8
+ DataListWrapModifier
9
+ } from '@patternfly/react-core';
10
+
11
+ export const DataListControllingText: React.FunctionComponent = () => (
12
+ <DataList aria-label="Simple data list example">
13
+ <DataListItem aria-labelledby="simple-item1">
14
+ <DataListItemRow>
15
+ <DataListItemCells
16
+ dataListCells={[
17
+ <DataListCell key="primary content" wrapModifier={DataListWrapModifier.breakWord}>
18
+ <span id="simple-item1">Primary content</span>
19
+ </DataListCell>,
20
+ <DataListCell key="secondary content" wrapModifier={DataListWrapModifier.truncate}>
21
+ Really really really really really really really really really really really really really really long
22
+ description that should be truncated before it ends
23
+ </DataListCell>
24
+ ]}
25
+ />
26
+ </DataListItemRow>
27
+ </DataListItem>
28
+ </DataList>
29
+ );
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import {
3
+ DataList,
4
+ DataListItem,
5
+ DataListCell,
6
+ DataListItemRow,
7
+ DataListCheck,
8
+ DataListControl,
9
+ DataListDragButton,
10
+ DataListItemCells,
11
+ DragDrop,
12
+ Draggable,
13
+ Droppable
14
+ } from '@patternfly/react-core';
15
+
16
+ interface ItemType {
17
+ id: string;
18
+ content: string;
19
+ }
20
+
21
+ const getItems = (count: number) =>
22
+ Array.from({ length: count }, (_, idx) => idx).map(idx => ({
23
+ id: `item-${idx}`,
24
+ content: `item ${idx} `.repeat(idx === 4 ? 20 : 1)
25
+ }));
26
+
27
+ const reorder = (list: ItemType[], startIndex: number, endIndex: number) => {
28
+ const result = list;
29
+ const [removed] = result.splice(startIndex, 1);
30
+ result.splice(endIndex, 0, removed);
31
+ return result;
32
+ };
33
+
34
+ export const DataListDraggable: React.FunctionComponent = () => {
35
+ const [items, setItems] = React.useState(getItems(10));
36
+ const [liveText, setLiveText] = React.useState('');
37
+
38
+ function onDrag(source) {
39
+ setLiveText(`Started dragging ${items[source.index].content}`);
40
+ // Return true to allow drag
41
+ return true;
42
+ }
43
+
44
+ function onDragMove(source, dest) {
45
+ const newText = dest ? `Move ${items[source.index].content} to ${items[dest.index].content}` : 'Invalid drop zone';
46
+ if (newText !== liveText) {
47
+ setLiveText(newText);
48
+ }
49
+ }
50
+
51
+ function onDrop(source, dest) {
52
+ if (dest) {
53
+ const newItems = reorder(items, source.index, dest.index);
54
+ setItems(newItems);
55
+
56
+ setLiveText('Dragging finished.');
57
+ return true; // Signal that this is a valid drop and not to animate the item returning home.
58
+ } else {
59
+ setLiveText('Dragging cancelled. List unchanged.');
60
+ }
61
+ }
62
+
63
+ return (
64
+ <DragDrop onDrag={onDrag} onDragMove={onDragMove} onDrop={onDrop}>
65
+ <Droppable hasNoWrapper>
66
+ <DataList aria-label="draggable data list example" isCompact>
67
+ {items.map(({ id, content }) => (
68
+ <Draggable key={id} hasNoWrapper>
69
+ <DataListItem aria-labelledby={id} ref={React.createRef()}>
70
+ <DataListItemRow>
71
+ <DataListControl>
72
+ <DataListDragButton
73
+ aria-label="Reorder"
74
+ aria-labelledby={id}
75
+ aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
76
+ aria-pressed="false"
77
+ />
78
+ <DataListCheck aria-labelledby={id} name={id} otherControls />
79
+ </DataListControl>
80
+ <DataListItemCells
81
+ dataListCells={[
82
+ <DataListCell key={id}>
83
+ <span id={id}>{content}</span>
84
+ </DataListCell>
85
+ ]}
86
+ />
87
+ </DataListItemRow>
88
+ </DataListItem>
89
+ </Draggable>
90
+ ))}
91
+ </DataList>
92
+ </Droppable>
93
+ <div className="pf-screen-reader" aria-live="assertive">
94
+ {liveText}
95
+ </div>
96
+ </DragDrop>
97
+ );
98
+ };