@patternfly/react-core 4.183.3 → 4.183.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 4.183.4 (2022-01-06)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-core
9
+
10
+
11
+
12
+
13
+
6
14
  ## 4.183.3 (2022-01-06)
7
15
 
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.183.3",
3
+ "version": "4.183.4",
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,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.34.3",
38
- "@patternfly/react-styles": "^4.33.3",
39
- "@patternfly/react-tokens": "^4.35.3",
37
+ "@patternfly/react-icons": "^4.34.4",
38
+ "@patternfly/react-styles": "^4.33.4",
39
+ "@patternfly/react-tokens": "^4.35.4",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -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": "c18bb8c707fd4cb935b8f1357e8881edf20a0320"
63
+ "gitHead": "c3d126fe3f5b45d8a0c24ae7e2268d55529dd8fe"
64
64
  }
@@ -195,15 +195,15 @@ test('should render secondary tabs', () => {
195
195
  <Tab id="secondary tab1" eventKey={10} title={<TabTitleText>"Secondary Tab item 1"</TabTitleText>}>
196
196
  Secondary Tab 1 section
197
197
  </Tab>
198
- <Tab id="secondary tab2" eventKey={11} title={<TabTitleText>"Secondary Tab item 2"</TabTitleText>}>>
198
+ <Tab id="secondary tab2" eventKey={11} title={<TabTitleText>"Secondary Tab item 2"</TabTitleText>}>
199
199
  Secondary Tab 2 section
200
200
  </Tab>
201
- <Tab id="secondary tab3" eventKey={12} title={<TabTitleText>"Secondary Tab item 3"</TabTitleText>}>>
201
+ <Tab id="secondary tab3" eventKey={12} title={<TabTitleText>"Secondary Tab item 3"</TabTitleText>}>
202
202
  Secondary Tab 3 section
203
203
  </Tab>
204
204
  </Tabs>
205
205
  </Tab>
206
- <Tab id="tab2" eventKey={1} title={<TabTitleText>"Tab item 2"</TabTitleText>}>>
206
+ <Tab id="tab2" eventKey={1} title={<TabTitleText>"Tab item 2"</TabTitleText>}>
207
207
  Tab 2 section
208
208
  </Tab>
209
209
  <Tab id="tab3" eventKey={2} title={<TabTitleText>"Tab item 3"</TabTitleText>}>
@@ -1077,7 +1077,7 @@ Array [
1077
1077
  role="tabpanel"
1078
1078
  tabindex="0"
1079
1079
  >
1080
- &gt; Secondary Tab 2 section
1080
+ Secondary Tab 2 section
1081
1081
  </section>
1082
1082
  <section
1083
1083
  aria-labelledby="pf-tab-12-secondary tab3"
@@ -1089,7 +1089,7 @@ Array [
1089
1089
  role="tabpanel"
1090
1090
  tabindex="0"
1091
1091
  >
1092
- &gt; Secondary Tab 3 section
1092
+ Secondary Tab 3 section
1093
1093
  </section>
1094
1094
  </section>,
1095
1095
  <section
@@ -1102,7 +1102,7 @@ Array [
1102
1102
  role="tabpanel"
1103
1103
  tabindex="0"
1104
1104
  >
1105
- &gt; Tab 2 section
1105
+ Tab 2 section
1106
1106
  </section>,
1107
1107
  <section
1108
1108
  aria-labelledby="pf-tab-2-tab3"
package/src/demos/Tabs.md CHANGED
@@ -6,6 +6,11 @@ section: components
6
6
  import DashboardWrapper from './examples/DashboardWrapper';
7
7
  import CheckCircleIcon from '@patternfly/react-icons/dist/js/icons/check-circle-icon';
8
8
  import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
9
+ import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
10
+ import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
11
+ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
12
+ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
13
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
9
14
 
10
15
  ## Demos
11
16
 
@@ -440,4 +445,8 @@ TabsOpenWithSecondaryTabsDemo = () => {
440
445
 
441
446
  ### Nested tabs
442
447
  ```js isFullscreen file="./Tabs/NestedTabsDemo.js"
443
- ```
448
+ ```
449
+
450
+ ### Tables and tabs
451
+ ```js isFullscreen file="./examples/Tabs/TabsAndTable.tsx"
452
+ ```
@@ -0,0 +1,432 @@
1
+ /* eslint-disable no-console */
2
+ import React from 'react';
3
+ import {
4
+ Button,
5
+ Divider,
6
+ Drawer,
7
+ DrawerContent,
8
+ DrawerContentBody,
9
+ DrawerPanelContent,
10
+ DrawerHead,
11
+ DrawerActions,
12
+ DrawerCloseButton,
13
+ DrawerPanelBody,
14
+ Dropdown,
15
+ Flex,
16
+ FlexItem,
17
+ KebabToggle,
18
+ Label,
19
+ LabelGroup,
20
+ OptionsMenu,
21
+ OptionsMenuToggle,
22
+ OverflowMenu,
23
+ OverflowMenuContent,
24
+ OverflowMenuControl,
25
+ OverflowMenuGroup,
26
+ OverflowMenuItem,
27
+ PageSection,
28
+ PageSectionVariants,
29
+ Pagination,
30
+ PaginationVariant,
31
+ Progress,
32
+ ProgressSize,
33
+ Select,
34
+ SelectVariant,
35
+ Tabs,
36
+ Tab,
37
+ TabContent,
38
+ TabContentBody,
39
+ TabTitleText,
40
+ Title,
41
+ Toolbar,
42
+ ToolbarItem,
43
+ ToolbarContent,
44
+ ToolbarToggleGroup
45
+ } from '@patternfly/react-core';
46
+ import {
47
+ TableComposable,
48
+ Thead,
49
+ Tbody,
50
+ Tr,
51
+ Th,
52
+ Td,
53
+ IAction,
54
+ ActionsColumn,
55
+ CustomActionsToggleProps
56
+ } from '@patternfly/react-table';
57
+ import DashboardWrapper from '../DashboardWrapper';
58
+ import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
59
+ import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
60
+ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
61
+ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
62
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
63
+
64
+ interface Repository {
65
+ name: string;
66
+ branches: number | null;
67
+ prs: number | null;
68
+ workspaces: number;
69
+ lastCommit: string;
70
+ }
71
+
72
+ export const TablesAndTabs = () => {
73
+ // tab properties
74
+ const [activeTabKey, setActiveTabKey] = React.useState<number>(0);
75
+ // Toggle currently active tab
76
+ const handleTabClick = (tabIndex: number) => {
77
+ setActiveTabKey(tabIndex);
78
+ };
79
+
80
+ // secondary tab properties
81
+ const [secondaryActiveTabKey, setSecondaryActiveTabKey] = React.useState<number>(10);
82
+ const handleSecondaryTabClick = (tabIndex: number) => {
83
+ setSecondaryActiveTabKey(tabIndex);
84
+ };
85
+
86
+ // drawer properties
87
+ const [isExpanded, setIsExpanded] = React.useState<boolean>(false);
88
+
89
+ // table properties
90
+ // In real usage, this data would come from some external source like an API via props.
91
+ const repositories: Repository[] = [
92
+ { name: 'Node 1', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' },
93
+ { name: 'Node 2', branches: 8, prs: 30, workspaces: 2, lastCommit: '2 days ago' },
94
+ { name: 'Node 3', branches: 12, prs: 48, workspaces: 13, lastCommit: '30 days ago' },
95
+ { name: 'Node 4', branches: 3, prs: 8, workspaces: 20, lastCommit: '8 days ago' },
96
+ { name: 'Node 5', branches: 33, prs: 21, workspaces: 2, lastCommit: '26 days ago' }
97
+ ];
98
+
99
+ const columnNames = {
100
+ name: 'Repositories',
101
+ branches: 'Branches',
102
+ prs: 'Pull requests',
103
+ workspaces: 'Workspaces',
104
+ lastCommit: 'Last commit'
105
+ };
106
+
107
+ const [selectedRepoNames, setSelectedRepoNames] = React.useState<string[]>([]);
108
+ const setRepoSelected = (event: React.FormEvent<HTMLInputElement>, repo: Repository, isSelecting = true) => {
109
+ setSelectedRepoNames(prevSelected => {
110
+ const otherSelectedRepoNames = prevSelected.filter(r => r !== repo.name);
111
+ return isSelecting ? [...otherSelectedRepoNames, repo.name] : otherSelectedRepoNames;
112
+ });
113
+ event.stopPropagation();
114
+ };
115
+ const onSelectAll = (isSelecting = true) => setSelectedRepoNames(isSelecting ? repositories.map(r => r.name) : []);
116
+ const allRowsSelected = selectedRepoNames.length === repositories.length;
117
+ const isRepoSelected = (repo: Repository) => selectedRepoNames.includes(repo.name);
118
+
119
+ const [rowClicked, setRowClicked] = React.useState<string>(null);
120
+ const isRowClicked = (repo: Repository) => rowClicked === repo.name;
121
+
122
+ const defaultActions: IAction[] = [
123
+ {
124
+ title: 'Some action',
125
+ onClick: event => {
126
+ event.stopPropagation();
127
+ console.log('clicked on Some action');
128
+ }
129
+ },
130
+ {
131
+ title: <a href="https://www.patternfly.org">Link action</a>,
132
+ onClick: event => {
133
+ event.stopPropagation();
134
+ console.log('clicked on Link action');
135
+ }
136
+ },
137
+ {
138
+ isSeparator: true
139
+ },
140
+ {
141
+ title: 'Third action',
142
+ onClick: event => {
143
+ event.stopPropagation();
144
+ console.log('clicked on Third action');
145
+ }
146
+ }
147
+ ];
148
+
149
+ const customActionsToggle = (props: CustomActionsToggleProps) => (
150
+ <KebabToggle
151
+ isDisabled={props.isDisabled}
152
+ onToggle={(value, event) => {
153
+ props.onToggle(value);
154
+ event.stopPropagation();
155
+ }}
156
+ />
157
+ );
158
+
159
+ const toolbar = (
160
+ <Toolbar id="page-layout-table-column-management-action-toolbar-top" usePageInsets>
161
+ <ToolbarContent>
162
+ <ToolbarToggleGroup toggleIcon={<FilterIcon />} breakpoint="xl">
163
+ <ToolbarItem>
164
+ <Select
165
+ onToggle={() => {}}
166
+ variant={SelectVariant.single}
167
+ aria-label="Select Input"
168
+ placeholderText="Name"
169
+ />
170
+ </ToolbarItem>
171
+ </ToolbarToggleGroup>
172
+ <ToolbarItem>
173
+ <OptionsMenu
174
+ id="page-layout-table-column-management-action-toolbar-top-options-menu-toggle"
175
+ isPlain
176
+ menuItems={[]}
177
+ toggle={
178
+ <OptionsMenuToggle
179
+ toggleTemplate={<SortAmountDownIcon aria-hidden="true" />}
180
+ aria-label="Sort"
181
+ hideCaret
182
+ />
183
+ }
184
+ />
185
+ </ToolbarItem>
186
+ <OverflowMenu breakpoint="md">
187
+ <OverflowMenuContent className="pf-u-display-none pf-u-display-block-on-lg">
188
+ <OverflowMenuGroup groupType="button" isPersistent>
189
+ <OverflowMenuItem isPersistent>
190
+ <Button variant="primary">Generate</Button>
191
+ </OverflowMenuItem>
192
+ <OverflowMenuItem isPersistent>
193
+ <Button variant="secondary">Deploy</Button>
194
+ </OverflowMenuItem>
195
+ </OverflowMenuGroup>
196
+ </OverflowMenuContent>
197
+ <OverflowMenuControl hasAdditionalOptions>
198
+ <Dropdown
199
+ onSelect={() => {}}
200
+ toggle={<KebabToggle onToggle={() => {}} />}
201
+ isOpen={false}
202
+ isPlain
203
+ dropdownItems={[]}
204
+ />
205
+ </OverflowMenuControl>
206
+ </OverflowMenu>
207
+ <ToolbarItem variant="pagination">
208
+ <Pagination
209
+ itemCount={36}
210
+ widgetId="pagination-options-menu-bottom"
211
+ page={1}
212
+ variant={PaginationVariant.top}
213
+ isCompact
214
+ />
215
+ </ToolbarItem>
216
+ </ToolbarContent>
217
+ </Toolbar>
218
+ );
219
+
220
+ const tableComposable = (
221
+ <TableComposable aria-label="`Composable` table">
222
+ <Thead noWrap>
223
+ <Tr>
224
+ <Th
225
+ select={{
226
+ onSelect: (_event, isSelecting) => onSelectAll(isSelecting),
227
+ isSelected: allRowsSelected
228
+ }}
229
+ />
230
+ <Th>{columnNames.name}</Th>
231
+ <Th>{columnNames.branches}</Th>
232
+ <Th>{columnNames.prs}</Th>
233
+ <Th>{columnNames.workspaces}</Th>
234
+ <Th>{columnNames.lastCommit}</Th>
235
+ </Tr>
236
+ </Thead>
237
+ <Tbody>
238
+ {repositories.map((repo, rowIndex) => (
239
+ <Tr
240
+ key={repo.name}
241
+ onRowClick={event => {
242
+ if ((event.target as HTMLInputElement).type !== 'checkbox') {
243
+ setRowClicked(rowClicked === repo.name ? null : repo.name);
244
+ setIsExpanded(!isRowClicked(repo));
245
+ }
246
+ }}
247
+ isHoverable
248
+ isRowSelected={repo.name === rowClicked}
249
+ >
250
+ <Td
251
+ key={`${rowIndex}_0`}
252
+ select={{
253
+ rowIndex,
254
+ onSelect: (event, isSelected) => setRepoSelected(event, repo, isSelected),
255
+ isSelected: isRepoSelected(repo)
256
+ }}
257
+ />
258
+ <Td dataLabel={columnNames.name}>
259
+ {repo.name}
260
+ <div>
261
+ <a href="#">siemur/test-space</a>
262
+ </div>
263
+ </Td>
264
+ <Td dataLabel={columnNames.branches}>
265
+ <Flex>
266
+ <FlexItem>{repo.branches}</FlexItem>
267
+ <FlexItem>
268
+ <CodeBranchIcon key="icon" />
269
+ </FlexItem>
270
+ </Flex>
271
+ </Td>
272
+ <Td dataLabel={columnNames.prs}>
273
+ <Flex>
274
+ <FlexItem>{repo.prs}</FlexItem>
275
+ <FlexItem>
276
+ <CodeIcon key="icon" />
277
+ </FlexItem>
278
+ </Flex>
279
+ </Td>
280
+ <Td dataLabel={columnNames.workspaces}>
281
+ <Flex>
282
+ <FlexItem>{repo.workspaces}</FlexItem>
283
+ <FlexItem>
284
+ <CubeIcon key="icon" />
285
+ </FlexItem>
286
+ </Flex>
287
+ </Td>
288
+ <Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td>
289
+ <Td key={`${rowIndex}_5`}>
290
+ <ActionsColumn items={defaultActions} actionsToggle={customActionsToggle} />
291
+ </Td>
292
+ </Tr>
293
+ ))}
294
+ </Tbody>
295
+ </TableComposable>
296
+ );
297
+
298
+ const panelContent = (
299
+ <DrawerPanelContent widths={{ default: 'width_33', xl: 'width_33' }}>
300
+ <DrawerHead>
301
+ <DrawerActions>
302
+ <DrawerCloseButton
303
+ onClick={() => {
304
+ setRowClicked(null);
305
+ setIsExpanded(false);
306
+ }}
307
+ />
308
+ </DrawerActions>
309
+ <Flex spaceItems={{ default: 'spaceItemsSm' }} direction={{ default: 'column' }}>
310
+ <FlexItem>
311
+ <Title headingLevel="h2" size="lg">
312
+ {rowClicked}
313
+ </Title>
314
+ </FlexItem>
315
+ <FlexItem>
316
+ <a href="#">siemur/test-space</a>
317
+ </FlexItem>
318
+ </Flex>
319
+ </DrawerHead>
320
+ <DrawerPanelBody hasNoPadding>
321
+ <Tabs
322
+ activeKey={secondaryActiveTabKey}
323
+ onSelect={(_event, tabIndex) => handleSecondaryTabClick(Number(tabIndex))}
324
+ isBox
325
+ isFilled
326
+ id="tabs-tables-secondary-tabs"
327
+ >
328
+ <Tab eventKey={10} title={<TabTitleText>Overview</TabTitleText>} tabContentId={`tabContent${10}`} />
329
+ <Tab eventKey={11} title={<TabTitleText>Activity</TabTitleText>} tabContentId={`tabContent${11}`} />
330
+ </Tabs>
331
+ </DrawerPanelBody>
332
+ <DrawerPanelBody>
333
+ <TabContent
334
+ key={10}
335
+ eventKey={10}
336
+ id={`tabContent${10}`}
337
+ activeKey={secondaryActiveTabKey}
338
+ hidden={10 !== secondaryActiveTabKey}
339
+ >
340
+ <TabContentBody>
341
+ <Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsLg' }}>
342
+ <FlexItem>
343
+ <p>
344
+ The content of the drawer really is up to you. It could have form fields, definition lists, text
345
+ lists, labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in
346
+ here, and can also make the drawer scrollable.
347
+ </p>
348
+ </FlexItem>
349
+ <FlexItem>
350
+ <Progress value={33} title="Capacity" size={ProgressSize.sm} />
351
+ </FlexItem>
352
+ <FlexItem>
353
+ <Progress value={66} title="Modules" size={ProgressSize.sm} />
354
+ </FlexItem>
355
+ <Flex direction={{ default: 'column' }}>
356
+ <FlexItem>
357
+ <Title headingLevel="h3">Tags</Title>
358
+ </FlexItem>
359
+ <FlexItem>
360
+ <LabelGroup>
361
+ {[1, 2, 3, 4, 5].map(labelNumber => (
362
+ <Label variant="outline" key={`label-${labelNumber}`}>{`Tag ${labelNumber}`}</Label>
363
+ ))}
364
+ </LabelGroup>
365
+ </FlexItem>
366
+ </Flex>
367
+ </Flex>
368
+ </TabContentBody>
369
+ </TabContent>
370
+ <TabContent
371
+ key={11}
372
+ eventKey={11}
373
+ id={`tabContent${11}`}
374
+ activeKey={secondaryActiveTabKey}
375
+ hidden={11 !== secondaryActiveTabKey}
376
+ >
377
+ <TabContentBody>Activity panel</TabContentBody>
378
+ </TabContent>
379
+ </DrawerPanelBody>
380
+ </DrawerPanelContent>
381
+ );
382
+
383
+ const tabContent = (
384
+ <Drawer isExpanded={isExpanded} isInline>
385
+ <DrawerContent panelContent={panelContent}>
386
+ <DrawerContentBody>
387
+ {toolbar}
388
+ <Divider />
389
+ {tableComposable}
390
+ <Pagination
391
+ id="page-layout-table-column-management-action-toolbar-bottom"
392
+ itemCount={36}
393
+ widgetId="pagination-options-menu-bottom"
394
+ page={1}
395
+ variant={PaginationVariant.bottom}
396
+ />
397
+ </DrawerContentBody>
398
+ </DrawerContent>
399
+ </Drawer>
400
+ );
401
+
402
+ return (
403
+ <DashboardWrapper hasNoBreadcrumb>
404
+ <React.Fragment>
405
+ <PageSection variant={PageSectionVariants.light}>
406
+ <Title headingLevel="h1" size="2xl">
407
+ Nodes
408
+ </Title>
409
+ </PageSection>
410
+ <PageSection type="tabs" variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
411
+ <Tabs
412
+ activeKey={activeTabKey}
413
+ onSelect={(_event, tabIndex) => handleTabClick(Number(tabIndex))}
414
+ usePageInsets
415
+ id="tabs-table-tabs-list"
416
+ >
417
+ <Tab eventKey={0} title={<TabTitleText>Nodes</TabTitleText>} tabContentId={`tabContent${0}`} />
418
+ <Tab eventKey={1} title={<TabTitleText>Node connectors</TabTitleText>} tabContentId={`tabContent${1}`} />
419
+ </Tabs>
420
+ </PageSection>
421
+ <PageSection variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
422
+ <TabContent key={0} eventKey={0} id={`tabContent${0}`} activeKey={activeTabKey} hidden={0 !== activeTabKey}>
423
+ <TabContentBody>{tabContent}</TabContentBody>
424
+ </TabContent>
425
+ <TabContent key={1} eventKey={1} id={`tabContent${1}`} activeKey={activeTabKey} hidden={1 !== activeTabKey}>
426
+ <TabContentBody>Node connectors panel</TabContentBody>
427
+ </TabContent>
428
+ </PageSection>
429
+ </React.Fragment>
430
+ </DashboardWrapper>
431
+ );
432
+ };