@patternfly/react-core 4.263.0 → 4.264.0

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 (54) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/esm/components/Tabs/Tab.d.ts +4 -2
  3. package/dist/esm/components/Tabs/Tab.d.ts.map +1 -1
  4. package/dist/esm/components/Tabs/Tab.js +6 -7
  5. package/dist/esm/components/Tabs/Tab.js.map +1 -1
  6. package/dist/esm/components/Tabs/TabAction.d.ts +20 -0
  7. package/dist/esm/components/Tabs/TabAction.d.ts.map +1 -0
  8. package/dist/esm/components/Tabs/TabAction.js +17 -0
  9. package/dist/esm/components/Tabs/TabAction.js.map +1 -0
  10. package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
  11. package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
  12. package/dist/esm/components/Tabs/index.d.ts +1 -0
  13. package/dist/esm/components/Tabs/index.d.ts.map +1 -1
  14. package/dist/esm/components/Tabs/index.js +1 -0
  15. package/dist/esm/components/Tabs/index.js.map +1 -1
  16. package/dist/js/components/Tabs/Tab.d.ts +4 -2
  17. package/dist/js/components/Tabs/Tab.d.ts.map +1 -1
  18. package/dist/js/components/Tabs/Tab.js +6 -7
  19. package/dist/js/components/Tabs/Tab.js.map +1 -1
  20. package/dist/js/components/Tabs/TabAction.d.ts +20 -0
  21. package/dist/js/components/Tabs/TabAction.d.ts.map +1 -0
  22. package/dist/js/components/Tabs/TabAction.js +20 -0
  23. package/dist/js/components/Tabs/TabAction.js.map +1 -0
  24. package/dist/js/components/Tabs/Tabs.d.ts +1 -1
  25. package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
  26. package/dist/js/components/Tabs/index.d.ts +1 -0
  27. package/dist/js/components/Tabs/index.d.ts.map +1 -1
  28. package/dist/js/components/Tabs/index.js +1 -0
  29. package/dist/js/components/Tabs/index.js.map +1 -1
  30. package/dist/styles/assets/pficon/pficon.scss +12 -0
  31. package/dist/styles/assets/pficon/pficon.woff +0 -0
  32. package/dist/styles/assets/pficon/pficon.woff2 +0 -0
  33. package/dist/styles/base-no-reset.css +10 -0
  34. package/dist/styles/base.css +10 -0
  35. package/dist/umd/react-core.min.css +947 -778
  36. package/dist/umd/react-core.min.js +1 -1
  37. package/package.json +6 -6
  38. package/src/components/Tabs/Tab.tsx +17 -16
  39. package/src/components/Tabs/TabAction.tsx +57 -0
  40. package/src/components/Tabs/Tabs.tsx +1 -1
  41. package/src/components/Tabs/__tests__/Tab.test.tsx +10 -0
  42. package/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap +45 -0
  43. package/src/components/Tabs/examples/Tabs.md +64 -20
  44. package/src/components/Tabs/examples/TabsHelp.tsx +61 -0
  45. package/src/components/Tabs/examples/TabsHelpAndClose.tsx +84 -0
  46. package/src/components/Tabs/index.ts +1 -0
  47. package/src/demos/Tabs.md +0 -10
  48. package/src/demos/examples/DashboardWrapper.js +1 -0
  49. package/src/demos/examples/Tabs/ModalTabs.tsx +3 -3
  50. package/src/demos/examples/Tabs/NestedTabs.tsx +11 -3
  51. package/src/demos/examples/Tabs/NestedUnindentedTabs.tsx +25 -40
  52. package/src/demos/examples/Tabs/TabsAndTable.tsx +9 -52
  53. package/src/demos/examples/Tabs/GrayTabs.tsx +0 -152
  54. package/src/demos/examples/Tabs/TabsAndTablesAutoWidthTabs.tsx +0 -442
@@ -1,442 +0,0 @@
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 '@patternfly/react-core/src/demos/examples/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
- hasBorderBottom={false}
325
- inset={{ default: 'insetMd', md: 'insetSm' }}
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
- <Tab eventKey={12} title={<TabTitleText>Status</TabTitleText>} tabContentId={`tabContent${12}`} />
331
- </Tabs>
332
- </DrawerPanelBody>
333
- <DrawerPanelBody>
334
- <TabContent
335
- key={10}
336
- eventKey={10}
337
- id={`tabContent${10}`}
338
- activeKey={secondaryActiveTabKey}
339
- hidden={10 !== secondaryActiveTabKey}
340
- >
341
- <TabContentBody>
342
- <Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsLg' }}>
343
- <FlexItem>
344
- <p>
345
- The content of the drawer really is up to you. It could have form fields, definition lists, text
346
- lists, labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in
347
- here, and can also make the drawer scrollable.
348
- </p>
349
- </FlexItem>
350
- <FlexItem>
351
- <Progress value={33} title="Capacity" size={ProgressSize.sm} />
352
- </FlexItem>
353
- <FlexItem>
354
- <Progress value={66} title="Modules" size={ProgressSize.sm} />
355
- </FlexItem>
356
- <Flex direction={{ default: 'column' }}>
357
- <FlexItem>
358
- <Title headingLevel="h3">Tags</Title>
359
- </FlexItem>
360
- <FlexItem>
361
- <LabelGroup>
362
- {[1, 2, 3, 4, 5].map(labelNumber => (
363
- <Label variant="outline" key={`label-${labelNumber}`}>{`Tag ${labelNumber}`}</Label>
364
- ))}
365
- </LabelGroup>
366
- </FlexItem>
367
- </Flex>
368
- </Flex>
369
- </TabContentBody>
370
- </TabContent>
371
- <TabContent
372
- key={11}
373
- eventKey={11}
374
- id={`tabContent${11}`}
375
- activeKey={secondaryActiveTabKey}
376
- hidden={11 !== secondaryActiveTabKey}
377
- >
378
- <TabContentBody>Activity panel</TabContentBody>
379
- </TabContent>
380
- <TabContent
381
- key={12}
382
- eventKey={12}
383
- id={`tabContent${12}`}
384
- activeKey={secondaryActiveTabKey}
385
- hidden={12 !== secondaryActiveTabKey}
386
- >
387
- <TabContentBody>Status panel</TabContentBody>
388
- </TabContent>
389
- </DrawerPanelBody>
390
- </DrawerPanelContent>
391
- );
392
-
393
- const tabContent = (
394
- <Drawer isExpanded={isExpanded} isInline>
395
- <DrawerContent panelContent={panelContent}>
396
- <DrawerContentBody>
397
- {toolbar}
398
- <Divider />
399
- {tableComposable}
400
- <Pagination
401
- id="page-layout-table-column-management-action-toolbar-bottom"
402
- itemCount={36}
403
- widgetId="pagination-options-menu-bottom"
404
- page={1}
405
- variant={PaginationVariant.bottom}
406
- />
407
- </DrawerContentBody>
408
- </DrawerContent>
409
- </Drawer>
410
- );
411
-
412
- return (
413
- <DashboardWrapper hasNoBreadcrumb>
414
- <React.Fragment>
415
- <PageSection variant={PageSectionVariants.light}>
416
- <Title headingLevel="h1" size="2xl">
417
- Nodes
418
- </Title>
419
- </PageSection>
420
- <PageSection type="tabs" variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
421
- <Tabs
422
- activeKey={activeTabKey}
423
- onSelect={(_event, tabIndex) => handleTabClick(Number(tabIndex))}
424
- usePageInsets
425
- id="tabs-table-tabs-list"
426
- >
427
- <Tab eventKey={0} title={<TabTitleText>Nodes</TabTitleText>} tabContentId={`tabContent${0}`} />
428
- <Tab eventKey={1} title={<TabTitleText>Node connectors</TabTitleText>} tabContentId={`tabContent${1}`} />
429
- </Tabs>
430
- </PageSection>
431
- <PageSection variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
432
- <TabContent key={0} eventKey={0} id={`tabContent${0}`} activeKey={activeTabKey} hidden={0 !== activeTabKey}>
433
- <TabContentBody>{tabContent}</TabContentBody>
434
- </TabContent>
435
- <TabContent key={1} eventKey={1} id={`tabContent${1}`} activeKey={activeTabKey} hidden={1 !== activeTabKey}>
436
- <TabContentBody>Node connectors panel</TabContentBody>
437
- </TabContent>
438
- </PageSection>
439
- </React.Fragment>
440
- </DashboardWrapper>
441
- );
442
- };