@patternfly/react-core 4.192.4 → 4.192.8

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 (171) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/esm/components/Label/Label.d.ts.map +1 -1
  3. package/dist/esm/components/Label/Label.js +38 -25
  4. package/dist/esm/components/Label/Label.js.map +1 -1
  5. package/dist/esm/components/Masthead/Masthead.d.ts.map +1 -1
  6. package/dist/esm/components/Masthead/Masthead.js +6 -2
  7. package/dist/esm/components/Masthead/Masthead.js.map +1 -1
  8. package/dist/esm/components/Menu/MenuContent.js +1 -1
  9. package/dist/esm/components/Menu/MenuContent.js.map +1 -1
  10. package/dist/esm/components/Nav/Nav.d.ts +4 -2
  11. package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
  12. package/dist/esm/components/Nav/Nav.js +2 -1
  13. package/dist/esm/components/Nav/Nav.js.map +1 -1
  14. package/dist/esm/components/Nav/NavList.d.ts +2 -8
  15. package/dist/esm/components/Nav/NavList.d.ts.map +1 -1
  16. package/dist/esm/components/Nav/NavList.js +4 -7
  17. package/dist/esm/components/Nav/NavList.js.map +1 -1
  18. package/dist/esm/components/Page/Page.d.ts +14 -0
  19. package/dist/esm/components/Page/Page.d.ts.map +1 -1
  20. package/dist/esm/components/Page/Page.js +31 -16
  21. package/dist/esm/components/Page/Page.js.map +1 -1
  22. package/dist/esm/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
  23. package/dist/esm/components/Page/PageHeaderToolsGroup.js +3 -1
  24. package/dist/esm/components/Page/PageHeaderToolsGroup.js.map +1 -1
  25. package/dist/esm/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
  26. package/dist/esm/components/Page/PageHeaderToolsItem.js +7 -1
  27. package/dist/esm/components/Page/PageHeaderToolsItem.js.map +1 -1
  28. package/dist/esm/components/Page/PageSidebar.d.ts +1 -0
  29. package/dist/esm/components/Page/PageSidebar.d.ts.map +1 -1
  30. package/dist/esm/components/Page/PageSidebar.js +3 -2
  31. package/dist/esm/components/Page/PageSidebar.js.map +1 -1
  32. package/dist/esm/components/TimePicker/TimePicker.d.ts +4 -6
  33. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  34. package/dist/esm/components/TimePicker/TimePicker.js +74 -42
  35. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  36. package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
  37. package/dist/esm/components/Toolbar/Toolbar.js +3 -2
  38. package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
  39. package/dist/esm/components/Toolbar/ToolbarContent.d.ts.map +1 -1
  40. package/dist/esm/components/Toolbar/ToolbarContent.js +3 -2
  41. package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
  42. package/dist/esm/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
  43. package/dist/esm/components/Toolbar/ToolbarGroup.js +2 -1
  44. package/dist/esm/components/Toolbar/ToolbarGroup.js.map +1 -1
  45. package/dist/esm/components/Toolbar/ToolbarItem.d.ts.map +1 -1
  46. package/dist/esm/components/Toolbar/ToolbarItem.js +3 -2
  47. package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
  48. package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
  49. package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +8 -5
  50. package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
  51. package/dist/esm/helpers/util.d.ts +16 -8
  52. package/dist/esm/helpers/util.d.ts.map +1 -1
  53. package/dist/esm/helpers/util.js +53 -7
  54. package/dist/esm/helpers/util.js.map +1 -1
  55. package/dist/js/components/Label/Label.d.ts.map +1 -1
  56. package/dist/js/components/Label/Label.js +38 -25
  57. package/dist/js/components/Label/Label.js.map +1 -1
  58. package/dist/js/components/Masthead/Masthead.d.ts.map +1 -1
  59. package/dist/js/components/Masthead/Masthead.js +6 -2
  60. package/dist/js/components/Masthead/Masthead.js.map +1 -1
  61. package/dist/js/components/Menu/MenuContent.js +1 -1
  62. package/dist/js/components/Menu/MenuContent.js.map +1 -1
  63. package/dist/js/components/Nav/Nav.d.ts +4 -2
  64. package/dist/js/components/Nav/Nav.d.ts.map +1 -1
  65. package/dist/js/components/Nav/Nav.js +3 -2
  66. package/dist/js/components/Nav/Nav.js.map +1 -1
  67. package/dist/js/components/Nav/NavList.d.ts +2 -8
  68. package/dist/js/components/Nav/NavList.d.ts.map +1 -1
  69. package/dist/js/components/Nav/NavList.js +4 -7
  70. package/dist/js/components/Nav/NavList.js.map +1 -1
  71. package/dist/js/components/Page/Page.d.ts +14 -0
  72. package/dist/js/components/Page/Page.d.ts.map +1 -1
  73. package/dist/js/components/Page/Page.js +34 -19
  74. package/dist/js/components/Page/Page.js.map +1 -1
  75. package/dist/js/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
  76. package/dist/js/components/Page/PageHeaderToolsGroup.js +3 -1
  77. package/dist/js/components/Page/PageHeaderToolsGroup.js.map +1 -1
  78. package/dist/js/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
  79. package/dist/js/components/Page/PageHeaderToolsItem.js +6 -1
  80. package/dist/js/components/Page/PageHeaderToolsItem.js.map +1 -1
  81. package/dist/js/components/Page/PageSidebar.d.ts +1 -0
  82. package/dist/js/components/Page/PageSidebar.d.ts.map +1 -1
  83. package/dist/js/components/Page/PageSidebar.js +4 -3
  84. package/dist/js/components/Page/PageSidebar.js.map +1 -1
  85. package/dist/js/components/TimePicker/TimePicker.d.ts +4 -6
  86. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  87. package/dist/js/components/TimePicker/TimePicker.js +73 -41
  88. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  89. package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
  90. package/dist/js/components/Toolbar/Toolbar.js +3 -2
  91. package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
  92. package/dist/js/components/Toolbar/ToolbarContent.d.ts.map +1 -1
  93. package/dist/js/components/Toolbar/ToolbarContent.js +3 -2
  94. package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
  95. package/dist/js/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
  96. package/dist/js/components/Toolbar/ToolbarGroup.js +2 -1
  97. package/dist/js/components/Toolbar/ToolbarGroup.js.map +1 -1
  98. package/dist/js/components/Toolbar/ToolbarItem.d.ts.map +1 -1
  99. package/dist/js/components/Toolbar/ToolbarItem.js +3 -2
  100. package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
  101. package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
  102. package/dist/js/components/Toolbar/ToolbarToggleGroup.js +7 -4
  103. package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
  104. package/dist/js/helpers/util.d.ts +16 -8
  105. package/dist/js/helpers/util.d.ts.map +1 -1
  106. package/dist/js/helpers/util.js +55 -8
  107. package/dist/js/helpers/util.js.map +1 -1
  108. package/dist/umd/react-core.css +0 -104
  109. package/dist/umd/react-core.js +1400 -1304
  110. package/dist/umd/react-core.min.css +14 -118
  111. package/dist/umd/react-core.min.js +3 -3
  112. package/package.json +5 -5
  113. package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +1 -1
  114. package/src/components/ApplicationLauncher/examples/ApplicationLauncher.md +11 -577
  115. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignRight.tsx +32 -0
  116. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignTop.tsx +31 -0
  117. package/src/components/ApplicationLauncher/examples/ApplicationLauncherBasic.tsx +23 -0
  118. package/src/components/ApplicationLauncher/examples/ApplicationLauncherCustomIcon.tsx +32 -0
  119. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDisabled.tsx +25 -0
  120. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDocumentBody.tsx +31 -0
  121. package/src/components/ApplicationLauncher/examples/ApplicationLauncherFavoritesAndSearch.tsx +105 -0
  122. package/src/components/ApplicationLauncher/examples/ApplicationLauncherRouterLink.tsx +50 -0
  123. package/src/components/ApplicationLauncher/examples/ApplicationLauncherSectionsAndIcons.tsx +47 -0
  124. package/src/components/ApplicationLauncher/examples/ApplicationLauncherTooltip.tsx +35 -0
  125. package/src/components/BackToTop/examples/BackToTop.md +0 -1
  126. package/src/components/JumpLinks/examples/JumpLinks.md +0 -1
  127. package/src/components/Label/Label.tsx +58 -39
  128. package/src/components/Label/__tests__/Label.test.tsx +19 -1
  129. package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +109 -0
  130. package/src/components/Label/examples/Label.md +1 -41
  131. package/src/components/Label/examples/LabelEditable.tsx +57 -0
  132. package/src/components/Masthead/Masthead.tsx +23 -16
  133. package/src/components/Masthead/__tests__/__snapshots__/Masthead.test.tsx.snap +11 -11
  134. package/src/components/Menu/MenuContent.tsx +2 -2
  135. package/src/components/Menu/examples/Menu.md +7 -7
  136. package/src/components/Nav/Nav.tsx +4 -2
  137. package/src/components/Nav/NavList.tsx +4 -7
  138. package/src/components/Page/Page.tsx +49 -16
  139. package/src/components/Page/PageHeaderToolsGroup.tsx +16 -5
  140. package/src/components/Page/PageHeaderToolsItem.tsx +20 -14
  141. package/src/components/Page/PageSidebar.tsx +3 -3
  142. package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +2 -0
  143. package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +18 -9
  144. package/src/components/TimePicker/TimePicker.tsx +112 -124
  145. package/src/components/TimePicker/examples/TimePicker.md +16 -10
  146. package/src/components/Toolbar/Toolbar.tsx +44 -39
  147. package/src/components/Toolbar/ToolbarContent.tsx +45 -40
  148. package/src/components/Toolbar/ToolbarGroup.tsx +19 -14
  149. package/src/components/Toolbar/ToolbarItem.tsx +30 -19
  150. package/src/components/Toolbar/ToolbarToggleGroup.tsx +60 -53
  151. package/src/components/Toolbar/__tests__/Generated/__snapshots__/Toolbar.test.tsx.snap +3 -43
  152. package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap +3 -7
  153. package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarItem.test.tsx.snap +3 -8
  154. package/src/demos/ComposableMenu/ComposableMenu.md +88 -0
  155. package/src/demos/ComposableMenu/examples/ComposableActionsMenu.tsx +122 -0
  156. package/src/demos/ComposableMenu/examples/ComposableApplicationLauncher.tsx +282 -0
  157. package/src/demos/ComposableMenu/examples/ComposableContextSelector.tsx +202 -0
  158. package/src/demos/ComposableMenu/examples/ComposableDrilldownMenu.tsx +246 -0
  159. package/src/demos/ComposableMenu/examples/ComposableDropdwnVariants.tsx +235 -0
  160. package/src/demos/ComposableMenu/examples/ComposableFlyout.tsx +103 -0
  161. package/src/demos/ComposableMenu/examples/ComposableOptionsMenuVariants.tsx +94 -0
  162. package/src/demos/ComposableMenu/examples/ComposableSimpleDropdown.tsx +70 -0
  163. package/src/demos/ComposableMenu/examples/ComposableSimpleSelect.tsx +74 -0
  164. package/src/demos/ComposableMenu/examples/ComposableTreeViewMenu.tsx +240 -0
  165. package/src/demos/ComposableMenu/examples/avatarImg.svg +18 -0
  166. package/src/demos/ComposableMenu/examples/pf-logo-small.svg +23 -0
  167. package/src/demos/JumpLinks.md +0 -1
  168. package/src/demos/Page/Page.md +92 -43
  169. package/src/helpers/util.ts +61 -12
  170. package/src/demos/ComposableMenu.md +0 -1443
  171. package/src/demos/composable-menu.css +0 -3
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { MenuToggle, Menu, MenuContent, MenuList, MenuItem, Popper } from '@patternfly/react-core';
3
+
4
+ export const ComposableSimpleDropdown: React.FunctionComponent = () => {
5
+ const [isOpen, setIsOpen] = React.useState(false);
6
+ const toggleRef = React.useRef<HTMLButtonElement>();
7
+ const menuRef = React.useRef<HTMLDivElement>();
8
+
9
+ const handleMenuKeys = (event: KeyboardEvent) => {
10
+ if (!isOpen) {
11
+ return;
12
+ }
13
+ if (menuRef.current.contains(event.target as Node) || toggleRef.current.contains(event.target as Node)) {
14
+ if (event.key === 'Escape' || event.key === 'Tab') {
15
+ setIsOpen(!isOpen);
16
+ toggleRef.current.focus();
17
+ }
18
+ }
19
+ };
20
+
21
+ const handleClickOutside = (event: MouseEvent) => {
22
+ if (isOpen && !menuRef.current.contains(event.target as Node)) {
23
+ setIsOpen(false);
24
+ }
25
+ };
26
+
27
+ React.useEffect(() => {
28
+ window.addEventListener('keydown', handleMenuKeys);
29
+ window.addEventListener('click', handleClickOutside);
30
+ return () => {
31
+ window.removeEventListener('keydown', handleMenuKeys);
32
+ window.removeEventListener('click', handleClickOutside);
33
+ };
34
+ }, [isOpen, menuRef]);
35
+
36
+ const onToggleClick = (ev: React.MouseEvent) => {
37
+ ev.stopPropagation(); // Stop handleClickOutside from handling
38
+ setTimeout(() => {
39
+ if (menuRef.current) {
40
+ const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
41
+ firstElement && (firstElement as HTMLElement).focus();
42
+ }
43
+ }, 0);
44
+ setIsOpen(!isOpen);
45
+ };
46
+
47
+ const toggle = (
48
+ <MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen}>
49
+ {isOpen ? 'Expanded' : 'Collapsed'}
50
+ </MenuToggle>
51
+ );
52
+ const menu = (
53
+ // eslint-disable-next-line no-console
54
+ <Menu ref={menuRef} onSelect={(_ev, itemId) => console.log('selected', itemId)}>
55
+ <MenuContent>
56
+ <MenuList>
57
+ <MenuItem itemId={0}>Action</MenuItem>
58
+ <MenuItem itemId={1} to="#default-link2" onClick={ev => ev.preventDefault()}>
59
+ Link
60
+ </MenuItem>
61
+ <MenuItem isDisabled>Disabled Action</MenuItem>
62
+ <MenuItem isDisabled to="#default-link4">
63
+ Disabled Link
64
+ </MenuItem>
65
+ </MenuList>
66
+ </MenuContent>
67
+ </Menu>
68
+ );
69
+ return <Popper trigger={toggle} popper={menu} isVisible={isOpen} />;
70
+ };
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { MenuToggle, Menu, MenuContent, MenuList, MenuItem, Popper } from '@patternfly/react-core';
3
+ import TableIcon from '@patternfly/react-icons/dist/esm/icons/table-icon';
4
+
5
+ export const ComposableSimpleSelect: React.FunctionComponent = () => {
6
+ const [isOpen, setIsOpen] = React.useState<boolean>(false);
7
+ const [selected, setSelected] = React.useState<string>('Select a value');
8
+ const toggleRef = React.useRef<HTMLButtonElement>();
9
+ const menuRef = React.useRef<HTMLDivElement>();
10
+
11
+ const handleMenuKeys = (event: KeyboardEvent) => {
12
+ if (isOpen && menuRef.current.contains(event.target as Node)) {
13
+ if (event.key === 'Escape' || event.key === 'Tab') {
14
+ setIsOpen(!isOpen);
15
+ toggleRef.current.focus();
16
+ }
17
+ }
18
+ };
19
+
20
+ const handleClickOutside = (event: MouseEvent) => {
21
+ if (isOpen && !menuRef.current.contains(event.target as Node)) {
22
+ setIsOpen(false);
23
+ }
24
+ };
25
+
26
+ React.useEffect(() => {
27
+ window.addEventListener('keydown', handleMenuKeys);
28
+ window.addEventListener('click', handleClickOutside);
29
+ return () => {
30
+ window.removeEventListener('keydown', handleMenuKeys);
31
+ window.removeEventListener('click', handleClickOutside);
32
+ };
33
+ }, [isOpen, menuRef]);
34
+
35
+ const onToggleClick = (ev: React.MouseEvent) => {
36
+ ev.stopPropagation(); // Stop handleClickOutside from handling
37
+ setTimeout(() => {
38
+ if (menuRef.current) {
39
+ const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
40
+ firstElement && (firstElement as HTMLElement).focus();
41
+ }
42
+ }, 0);
43
+ setIsOpen(!isOpen);
44
+ };
45
+
46
+ const toggle = (
47
+ <MenuToggle
48
+ ref={toggleRef}
49
+ onClick={onToggleClick}
50
+ isExpanded={isOpen}
51
+ style={
52
+ {
53
+ width: '200px'
54
+ } as React.CSSProperties
55
+ }
56
+ >
57
+ {selected}
58
+ </MenuToggle>
59
+ );
60
+ const menu = (
61
+ <Menu ref={menuRef} id="select-menu" onSelect={(_ev, itemId) => setSelected(itemId.toString())} selected={selected}>
62
+ <MenuContent>
63
+ <MenuList>
64
+ <MenuItem itemId="Option 1">Option 1</MenuItem>
65
+ <MenuItem itemId="Option 2">Option 2</MenuItem>
66
+ <MenuItem itemId="Option 3" icon={<TableIcon aria-hidden />}>
67
+ Option 3
68
+ </MenuItem>
69
+ </MenuList>
70
+ </MenuContent>
71
+ </Menu>
72
+ );
73
+ return <Popper trigger={toggle} popper={menu} isVisible={isOpen} />;
74
+ };
@@ -0,0 +1,240 @@
1
+ import React from 'react';
2
+ import {
3
+ MenuToggle,
4
+ Menu,
5
+ MenuContent,
6
+ MenuGroup,
7
+ MenuList,
8
+ Popper,
9
+ TreeView,
10
+ TreeViewDataItem
11
+ } from '@patternfly/react-core';
12
+
13
+ export const ComposableTreeViewMenu: React.FunctionComponent = () => {
14
+ const [isOpen, setIsOpen] = React.useState<boolean>(false);
15
+ const [checkedItems, setCheckedItems] = React.useState<TreeViewDataItem[]>([]);
16
+ const toggleRef = React.useRef<HTMLButtonElement>();
17
+ const menuRef = React.useRef<HTMLDivElement>();
18
+
19
+ const statusOptions: TreeViewDataItem[] = [
20
+ {
21
+ name: 'Ready',
22
+ id: 'ready',
23
+ checkProps: { checked: false },
24
+ customBadgeContent: 1,
25
+ children: [
26
+ {
27
+ name: 'Updated',
28
+ id: 'updated',
29
+ checkProps: { checked: false },
30
+ customBadgeContent: 0
31
+ },
32
+ {
33
+ name: 'Waiting to update',
34
+ id: 'waiting',
35
+ checkProps: { checked: false },
36
+ customBadgeContent: 0
37
+ },
38
+ {
39
+ name: 'Conditions degraded',
40
+ id: 'degraded',
41
+ checkProps: { checked: false },
42
+ customBadgeContent: 1
43
+ },
44
+ {
45
+ name: 'Approval required',
46
+ id: 'approval',
47
+ checkProps: { checked: false },
48
+ customBadgeContent: 0
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ name: 'Not ready',
54
+ id: 'nr',
55
+ checkProps: { checked: false },
56
+ customBadgeContent: 1,
57
+ children: [
58
+ {
59
+ name: 'Conditions degraded',
60
+ id: 'nr-degraded',
61
+ checkProps: { checked: false },
62
+ customBadgeContent: 1
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ name: 'Updating',
68
+ id: 'updating',
69
+ checkProps: { checked: false },
70
+ customBadgeContent: 0
71
+ }
72
+ ];
73
+
74
+ const roleOptions = [
75
+ {
76
+ name: 'Server',
77
+ id: 'server',
78
+ checkProps: { checked: false },
79
+ customBadgeContent: 2
80
+ },
81
+ {
82
+ name: 'Worker',
83
+ id: 'worker',
84
+ checkProps: { checked: false },
85
+ customBadgeContent: 0
86
+ }
87
+ ];
88
+ // Helper functions
89
+ const isChecked = (dataItem: TreeViewDataItem) => checkedItems.some(item => item.id === dataItem.id);
90
+ const areAllDescendantsChecked = (dataItem: TreeViewDataItem) =>
91
+ dataItem.children ? dataItem.children.every(child => areAllDescendantsChecked(child)) : isChecked(dataItem);
92
+ const areSomeDescendantsChecked = (dataItem: TreeViewDataItem) =>
93
+ dataItem.children ? dataItem.children.some(child => areSomeDescendantsChecked(child)) : isChecked(dataItem);
94
+ const flattenTree = (tree: TreeViewDataItem[]) => {
95
+ let result = [];
96
+ tree.forEach(item => {
97
+ result.push(item);
98
+ if (item.children) {
99
+ result = result.concat(flattenTree(item.children));
100
+ }
101
+ });
102
+ return result;
103
+ };
104
+
105
+ const mapTree = (item: TreeViewDataItem) => {
106
+ const hasCheck = areAllDescendantsChecked(item);
107
+ // Reset checked properties to be updated
108
+ item.checkProps.checked = false;
109
+
110
+ if (hasCheck) {
111
+ item.checkProps.checked = true;
112
+ } else {
113
+ const hasPartialCheck = areSomeDescendantsChecked(item);
114
+ if (hasPartialCheck) {
115
+ item.checkProps.checked = null;
116
+ }
117
+ }
118
+
119
+ if (item.children) {
120
+ return {
121
+ ...item,
122
+ children: item.children.map(mapTree)
123
+ };
124
+ }
125
+ return item;
126
+ };
127
+
128
+ const filterItems = (item: TreeViewDataItem, checkedItem: TreeViewDataItem) => {
129
+ if (item.id === checkedItem.id) {
130
+ return true;
131
+ }
132
+
133
+ if (item.children) {
134
+ return (
135
+ (item.children = item.children
136
+ .map(opt => Object.assign({}, opt))
137
+ .filter(child => filterItems(child, checkedItem))).length > 0
138
+ );
139
+ }
140
+ };
141
+
142
+ const onCheck = (evt: React.ChangeEvent, treeViewItem: TreeViewDataItem, treeType: string) => {
143
+ const checked = (evt.target as HTMLInputElement).checked;
144
+
145
+ let options = [];
146
+ switch (treeType) {
147
+ case 'status':
148
+ options = statusOptions;
149
+ break;
150
+ case 'role':
151
+ options = roleOptions;
152
+ break;
153
+ default:
154
+ break;
155
+ }
156
+
157
+ const checkedItemTree = options.map(opt => Object.assign({}, opt)).filter(item => filterItems(item, treeViewItem));
158
+ const flatCheckedItems = flattenTree(checkedItemTree);
159
+ setCheckedItems(prevCheckedItems =>
160
+ checked
161
+ ? prevCheckedItems.concat(flatCheckedItems.filter(item => !prevCheckedItems.some(i => i.id === item.id)))
162
+ : prevCheckedItems.filter(item => !flatCheckedItems.some(i => i.id === item.id))
163
+ );
164
+ };
165
+
166
+ const handleMenuKeys = (event: KeyboardEvent) => {
167
+ if (!isOpen) {
168
+ return;
169
+ }
170
+ if (menuRef.current.contains(event.target as Node) || toggleRef.current.contains(event.target as Node)) {
171
+ if (event.key === 'Escape' || event.key === 'Tab') {
172
+ setIsOpen(!isOpen);
173
+ toggleRef.current.focus();
174
+ }
175
+ }
176
+ };
177
+
178
+ const handleClickOutside = (event: MouseEvent) => {
179
+ if (isOpen && !menuRef.current.contains(event.target as Node)) {
180
+ setIsOpen(false);
181
+ }
182
+ };
183
+
184
+ React.useEffect(() => {
185
+ window.addEventListener('keydown', handleMenuKeys);
186
+ window.addEventListener('click', handleClickOutside);
187
+ return () => {
188
+ window.removeEventListener('keydown', handleMenuKeys);
189
+ window.removeEventListener('click', handleClickOutside);
190
+ };
191
+ }, [isOpen, menuRef]);
192
+
193
+ const onToggleClick = (ev: React.MouseEvent) => {
194
+ ev.stopPropagation(); // Stop handleClickOutside from handling
195
+ setTimeout(() => {
196
+ if (menuRef.current) {
197
+ const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
198
+ firstElement && (firstElement as HTMLElement).focus();
199
+ }
200
+ }, 0);
201
+ setIsOpen(!isOpen);
202
+ };
203
+
204
+ const toggle = (
205
+ <MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen}>
206
+ {isOpen ? 'Expanded' : 'Collapsed'}
207
+ </MenuToggle>
208
+ );
209
+ const statusMapped = statusOptions.map(mapTree);
210
+ const roleMapped = roleOptions.map(mapTree);
211
+ const menu = (
212
+ <Menu
213
+ ref={menuRef}
214
+ // eslint-disable-next-line no-console
215
+ onSelect={(_ev, itemId) => console.log('selected', itemId)}
216
+ style={
217
+ {
218
+ '--pf-c-menu--Width': '300px'
219
+ } as React.CSSProperties
220
+ }
221
+ >
222
+ <MenuContent>
223
+ <MenuList>
224
+ <MenuGroup label="Status">
225
+ <TreeView
226
+ data={statusMapped}
227
+ hasBadges
228
+ hasChecks
229
+ onCheck={(event, item) => onCheck(event, item, 'status')}
230
+ />
231
+ </MenuGroup>
232
+ <MenuGroup label="Role">
233
+ <TreeView data={roleMapped} hasBadges hasChecks onCheck={(event, item) => onCheck(event, item, 'role')} />
234
+ </MenuGroup>
235
+ </MenuList>
236
+ </MenuContent>
237
+ </Menu>
238
+ );
239
+ return <Popper trigger={toggle} popper={menu} isVisible={isOpen} popperMatchesTriggerWidth={false} />;
240
+ };
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 24.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 36 36" style="enable-background:new 0 0 36 36;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#F0F0F0;}
7
+ .st1{fill-rule:evenodd;clip-rule:evenodd;fill:#D2D2D2;}
8
+ .st2{fill:#B8BBBE;}
9
+ .st3{fill:#D2D2D2;}
10
+ </style>
11
+ <rect class="st0" width="36" height="36"/>
12
+ <path class="st1" d="M17.7,20.1c-3.5,0-6.4-2.9-6.4-6.4s2.9-6.4,6.4-6.4s6.4,2.9,6.4,6.4S21.3,20.1,17.7,20.1z"/>
13
+ <path class="st2" d="M13.3,36l0-6.7c-2,0.4-2.9,1.4-3.1,3.5L10.1,36H13.3z"/>
14
+ <path class="st3" d="M10.1,36l0.1-3.2c0.2-2.1,1.1-3.1,3.1-3.5l0,6.7h9.4l0-6.7c2,0.4,2.9,1.4,3.1,3.5l0.1,3.2h4.7
15
+ c-0.4-3.9-1.3-9-2.9-11c-1.1-1.4-2.3-2.2-3.5-2.6s-1.8-0.6-6.3-0.6s-6.1,0.7-6.1,0.7c-1.2,0.4-2.4,1.2-3.4,2.6
16
+ C6.7,27,5.8,32.2,5.4,36H10.1z"/>
17
+ <path class="st2" d="M25.9,36l-0.1-3.2c-0.2-2.1-1.1-3.1-3.1-3.5l0,6.7H25.9z"/>
18
+ </svg>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="30px" height="27px" viewBox="0 0 30 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 54 (76480) - https://sketchapp.com -->
4
+ <title>Group 12</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs>
7
+ <linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
8
+ <stop stop-color="#7DC3E8" stop-opacity="0.600169362" offset="0%"></stop>
9
+ <stop stop-color="#007BBA" offset="100%"></stop>
10
+ </linearGradient>
11
+ </defs>
12
+ <g id="Toolbar" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
13
+ <g id="Toolbar-in-Card-View-w-Pagination-Example" transform="translate(-351.000000, -422.000000)" fill="url(#linearGradient-1)" fill-rule="nonzero">
14
+ <g id="Group-22" transform="translate(322.000000, 395.000000)">
15
+ <g id="Group-12" transform="translate(29.000000, 27.000000)">
16
+ <g id="PF3-logomark-bold">
17
+ <path d="M29.3047523,13.6067281 L14.8028311,0.0924998513 L14.6960566,0 L14.5601618,0.0924998513 L0.0873609707,13.6067281 L0,13.689978 L0.0679474216,13.7824778 L5.82406471,21.5709653 L5.88230536,21.6449652 L5.9793731,21.6449652 L10.2794742,20.7199667 L14.5601618,26.4364575 L14.6766431,26.5937073 L14.7931244,26.4364575 L19.0932255,20.6829668 L23.3836198,21.6079653 L23.4806876,21.6079653 L23.5389282,21.5339654 L29.3047523,13.7454779 L29.3726997,13.6529781 L29.3047523,13.6067281 Z M20.9957533,15.1699756 L21.5005056,16.2522239 L18.7826087,19.878218 L17.5789687,19.6192185 L20.9957533,15.1699756 Z M21.1607685,13.7454779 L16.0841254,2.77499554 L23.2186047,11.0999822 L21.1607685,13.7454779 Z M22.3255814,16.4002236 L22.3741153,16.3354737 L22.3741153,16.2614739 L21.5587462,14.5039767 L24.1116279,11.0999822 L24.1698686,11.0999822 L24.1019211,11.0167323 L18.9573306,5.01349194 L28.411729,13.8194778 L26.4703741,16.4002236 L23.1506572,20.8864664 L19.5494439,20.1002177 L22.3255814,16.4002236 Z M12.269363,20.2482175 L14.6669363,23.3747124 L14.7931244,23.5412122 L14.9096057,23.3747124 L17.1227503,20.2482175 L18.3166835,20.516467 L14.6960566,25.3634592 L11.0754297,20.516467 L12.269363,20.2482175 Z M12.871183,19.8227181 L14.6960566,2.88599536 L16.5015167,19.8227181 L14.7542973,22.2924642 L12.871183,19.8227181 Z M13.8418605,3.34849462 L12.1237614,18.8144698 L8.73609707,14.4207268 L13.8418605,3.34849462 Z M6.17350859,11.0999822 L13.3176946,2.77499554 L8.23134479,13.7454779 L6.17350859,11.0999822 Z M10.4347826,4.99499197 L5.29019211,10.9982323 L5.22224469,11.0999822 L5.29019211,11.183232 L7.88190091,14.5502266 L7.06653185,16.3077238 L7.06653185,16.3817237 L7.06653185,16.4464736 L9.79413549,20.1002177 L6.20262892,20.8864664 L0.970677452,13.7732279 L10.4347826,4.99499197 Z M11.8131446,19.6469684 L10.6095046,19.905968 L7.90131446,16.2522239 L8.39635996,15.1699756 L11.8131446,19.6469684 Z M15.5308392,3.34849462 L20.6463094,14.4484768 L17.2683519,18.8422197 L15.5308392,3.34849462 Z" id="Shape"></path>
18
+ </g>
19
+ </g>
20
+ </g>
21
+ </g>
22
+ </g>
23
+ </svg>
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  id: Jump links
3
3
  section: components
4
- beta: true
5
4
  ---
6
5
 
7
6
  import DashboardWrapper from './examples/DashboardWrapper';
@@ -11,6 +11,7 @@ import imgBrand from '@patternfly/react-core/src/demos/examples/pfColorLogo.svg'
11
11
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
12
12
  import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
13
13
  import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
14
+ import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
14
15
 
15
16
  - All but the last example set the `isManagedSidebar` prop on the Page component to have the sidebar automatically close for smaller screen widths. You can also manually control this behavior by not adding the `isManagedSidebar` prop and instead:
16
17
 
@@ -38,6 +39,7 @@ import {
38
39
  ButtonVariant,
39
40
  Card,
40
41
  CardBody,
42
+ Checkbox,
41
43
  Divider,
42
44
  Dropdown,
43
45
  DropdownGroup,
@@ -66,13 +68,21 @@ import {
66
68
  Toolbar,
67
69
  ToolbarContent,
68
70
  ToolbarGroup,
69
- ToolbarItem
71
+ ToolbarItem,
72
+ Drawer,
73
+ DrawerPanelContent,
74
+ DrawerContent,
75
+ DrawerContentBody,
76
+ DrawerHead,
77
+ DrawerActions,
78
+ DrawerCloseButton,
70
79
  } from '@patternfly/react-core';
71
80
  import { css } from '@patternfly/react-styles';
72
81
  import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
73
82
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
74
83
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
75
84
  import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
85
+ import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
76
86
  import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
77
87
  import imgBrand from './imgBrand.svg';
78
88
  import imgAvatar from './imgAvatar.svg';
@@ -84,7 +94,8 @@ class PageLayoutGrouped extends React.Component {
84
94
  isDropdownOpen: false,
85
95
  isKebabDropdownOpen: false,
86
96
  isFullKebabDropdownOpen: false,
87
- activeItem: 0
97
+ activeItem: 0,
98
+ isDrawerExpanded: false
88
99
  };
89
100
  this.onDropdownToggle = isDropdownOpen => {
90
101
  this.setState({
@@ -127,10 +138,23 @@ class PageLayoutGrouped extends React.Component {
127
138
  isFullKebabDropdownOpen: !this.state.isFullKebabDropdownOpen
128
139
  });
129
140
  };
141
+
142
+ this.onDrawerToggle = () => {
143
+ const isDrawerExpanded = !this.state.isDrawerExpanded;
144
+ this.setState({
145
+ isDrawerExpanded
146
+ });
147
+ };
148
+
149
+ this.onDrawerClose = () => {
150
+ this.setState({
151
+ isDrawerExpanded: false
152
+ });
153
+ };
130
154
  }
131
155
 
132
156
  render() {
133
- const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen } = this.state;
157
+ const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen, isDrawerExpanded } = this.state;
134
158
 
135
159
  const PageNav = (
136
160
  <Nav variant="tertiary" onSelect={this.onNavSelect} aria-label="Nav">
@@ -198,6 +222,11 @@ class PageLayoutGrouped extends React.Component {
198
222
  alignment={{ default: 'alignRight' }}
199
223
  spacer={{ default: 'spacerNone', md: 'spacerMd' }}
200
224
  >
225
+ <ToolbarItem>
226
+ <Button aria-label="Toggle drawer" variant={ButtonVariant.plain} onClick={this.onDrawerToggle}>
227
+ <LightbulbIcon color={isDrawerExpanded ? 'yellow' : 'currentColor'} />
228
+ </Button>
229
+ </ToolbarItem>
201
230
  <ToolbarItem>
202
231
  <Button aria-label="Notifications" variant={ButtonVariant.plain}>
203
232
  <AttentionBellIcon />
@@ -283,47 +312,67 @@ class PageLayoutGrouped extends React.Component {
283
312
  </Breadcrumb>
284
313
  );
285
314
 
315
+ const panelContent = (
316
+ <DrawerPanelContent isResizable>
317
+ <DrawerHead>
318
+ <span tabIndex={isDrawerExpanded ? 0 : -1}>
319
+ drawer-panel
320
+ </span>
321
+ <DrawerActions>
322
+ <DrawerCloseButton onClick={this.onDrawerClose} />
323
+ </DrawerActions>
324
+ </DrawerHead>
325
+ </DrawerPanelContent>
326
+ );
327
+
328
+ const Sidebar = <PageSidebar nav="Navigation" />;
329
+
286
330
  return (
287
- <React.Fragment>
288
- <Page
289
- header={Header}
290
- breadcrumb={PageBreadcrumb}
291
- tertiaryNav={PageNav}
292
- isManagedSidebar
293
- isTertiaryNavWidthLimited
294
- isBreadcrumbWidthLimited
295
- skipToContent={PageSkipToContent}
296
- mainContainerId={pageId}
297
- isTertiaryNavGrouped
298
- isBreadcrumbGrouped
299
- additionalGroupedContent={
300
- <PageSection variant={PageSectionVariants.light}>
301
- <TextContent>
302
- <Text component="h1">Main title</Text>
303
- <Text component="p">
304
- Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
305
- of its relative line height of 1.5.
306
- </Text>
307
- </TextContent>
308
- </PageSection>
309
- }
310
- groupProps={{
311
- sticky: 'top'
312
- }}
313
- >
314
- <PageSection>
315
- <Gallery hasGutter>
316
- {Array.apply(0, Array(20)).map((x, i) => (
317
- <GalleryItem key={i}>
318
- <Card>
319
- <CardBody>This is a card</CardBody>
320
- </Card>
321
- </GalleryItem>
322
- ))}
323
- </Gallery>
324
- </PageSection>
325
- </Page>
326
- </React.Fragment>
331
+ <Drawer isExpanded={isDrawerExpanded} isInline onExpand={this.onExpand}>
332
+ <DrawerContent panelContent={panelContent}>
333
+ <DrawerContentBody>
334
+ <Page
335
+ header={Header}
336
+ breadcrumb={PageBreadcrumb}
337
+ sidebar={Sidebar}
338
+ tertiaryNav={PageNav}
339
+ isManagedSidebar
340
+ isTertiaryNavWidthLimited
341
+ isBreadcrumbWidthLimited
342
+ skipToContent={PageSkipToContent}
343
+ mainContainerId={pageId}
344
+ isTertiaryNavGrouped
345
+ isBreadcrumbGrouped
346
+ additionalGroupedContent={
347
+ <PageSection variant={PageSectionVariants.light}>
348
+ <TextContent>
349
+ <Text component="h1">Main title</Text>
350
+ <Text component="p">
351
+ Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
352
+ of its relative line height of 1.5.
353
+ </Text>
354
+ </TextContent>
355
+ </PageSection>
356
+ }
357
+ groupProps={{
358
+ sticky: 'top'
359
+ }}
360
+ >
361
+ <PageSection>
362
+ <Gallery hasGutter>
363
+ {Array.apply(0, Array(20)).map((x, i) => (
364
+ <GalleryItem key={i}>
365
+ <Card>
366
+ <CardBody>This is a card</CardBody>
367
+ </Card>
368
+ </GalleryItem>
369
+ ))}
370
+ </Gallery>
371
+ </PageSection>
372
+ </Page>
373
+ </DrawerContentBody>
374
+ </DrawerContent>
375
+ </Drawer>
327
376
  );
328
377
  }
329
378
  }