@patternfly/react-core 5.0.0-alpha.88 → 5.0.0-alpha.89

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 (247) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/components/AboutModal/package.json +1 -1
  3. package/dist/esm/components/Accordion/package.json +1 -1
  4. package/dist/esm/components/ActionList/package.json +1 -1
  5. package/dist/esm/components/Alert/package.json +1 -1
  6. package/dist/esm/components/Avatar/package.json +1 -1
  7. package/dist/esm/components/BackToTop/package.json +1 -1
  8. package/dist/esm/components/Backdrop/package.json +1 -1
  9. package/dist/esm/components/BackgroundImage/package.json +1 -1
  10. package/dist/esm/components/Badge/package.json +1 -1
  11. package/dist/esm/components/Banner/package.json +1 -1
  12. package/dist/esm/components/Brand/package.json +1 -1
  13. package/dist/esm/components/Breadcrumb/package.json +1 -1
  14. package/dist/esm/components/Button/package.json +1 -1
  15. package/dist/esm/components/CalendarMonth/package.json +1 -1
  16. package/dist/esm/components/Card/package.json +1 -1
  17. package/dist/esm/components/Checkbox/package.json +1 -1
  18. package/dist/esm/components/Chip/package.json +1 -1
  19. package/dist/esm/components/ClipboardCopy/package.json +1 -1
  20. package/dist/esm/components/CodeBlock/package.json +1 -1
  21. package/dist/esm/components/DataList/package.json +1 -1
  22. package/dist/esm/components/DatePicker/package.json +1 -1
  23. package/dist/esm/components/DescriptionList/package.json +1 -1
  24. package/dist/esm/components/Divider/package.json +1 -1
  25. package/dist/esm/components/DragDrop/package.json +1 -1
  26. package/dist/esm/components/Drawer/package.json +1 -1
  27. package/dist/esm/components/Dropdown/package.json +1 -1
  28. package/dist/esm/components/DualListSelector/package.json +1 -1
  29. package/dist/esm/components/EmptyState/package.json +1 -1
  30. package/dist/esm/components/ExpandableSection/package.json +1 -1
  31. package/dist/esm/components/FileUpload/package.json +1 -1
  32. package/dist/esm/components/Form/package.json +1 -1
  33. package/dist/esm/components/FormSelect/package.json +1 -1
  34. package/dist/esm/components/HelperText/package.json +1 -1
  35. package/dist/esm/components/Hint/package.json +1 -1
  36. package/dist/esm/components/Icon/package.json +1 -1
  37. package/dist/esm/components/InputGroup/package.json +1 -1
  38. package/dist/esm/components/JumpLinks/package.json +1 -1
  39. package/dist/esm/components/Label/package.json +1 -1
  40. package/dist/esm/components/LabelGroup/package.json +1 -1
  41. package/dist/esm/components/List/package.json +1 -1
  42. package/dist/esm/components/LoginPage/package.json +1 -1
  43. package/dist/esm/components/Masthead/package.json +1 -1
  44. package/dist/esm/components/Menu/package.json +1 -1
  45. package/dist/esm/components/MenuToggle/package.json +1 -1
  46. package/dist/esm/components/Modal/package.json +1 -1
  47. package/dist/esm/components/MultipleFileUpload/package.json +1 -1
  48. package/dist/esm/components/Nav/Nav.d.ts +4 -6
  49. package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
  50. package/dist/esm/components/Nav/Nav.js +3 -4
  51. package/dist/esm/components/Nav/Nav.js.map +1 -1
  52. package/dist/esm/components/Nav/NavItem.js +1 -1
  53. package/dist/esm/components/Nav/NavItem.js.map +1 -1
  54. package/dist/esm/components/Nav/package.json +1 -1
  55. package/dist/esm/components/NotificationBadge/package.json +1 -1
  56. package/dist/esm/components/NotificationDrawer/package.json +1 -1
  57. package/dist/esm/components/NumberInput/package.json +1 -1
  58. package/dist/esm/components/OverflowMenu/package.json +1 -1
  59. package/dist/esm/components/Page/package.json +1 -1
  60. package/dist/esm/components/Pagination/package.json +1 -1
  61. package/dist/esm/components/Panel/package.json +1 -1
  62. package/dist/esm/components/Popover/package.json +1 -1
  63. package/dist/esm/components/Progress/package.json +1 -1
  64. package/dist/esm/components/ProgressStepper/package.json +1 -1
  65. package/dist/esm/components/Radio/package.json +1 -1
  66. package/dist/esm/components/SearchInput/package.json +1 -1
  67. package/dist/esm/components/Select/package.json +1 -1
  68. package/dist/esm/components/Sidebar/package.json +1 -1
  69. package/dist/esm/components/SimpleList/package.json +1 -1
  70. package/dist/esm/components/Skeleton/package.json +1 -1
  71. package/dist/esm/components/SkipToContent/package.json +1 -1
  72. package/dist/esm/components/Slider/package.json +1 -1
  73. package/dist/esm/components/Spinner/package.json +1 -1
  74. package/dist/esm/components/Switch/package.json +1 -1
  75. package/dist/esm/components/Tabs/package.json +1 -1
  76. package/dist/esm/components/Text/package.json +1 -1
  77. package/dist/esm/components/TextArea/package.json +1 -1
  78. package/dist/esm/components/TextInput/package.json +1 -1
  79. package/dist/esm/components/TextInputGroup/package.json +1 -1
  80. package/dist/esm/components/Tile/package.json +1 -1
  81. package/dist/esm/components/TimePicker/package.json +1 -1
  82. package/dist/esm/components/Timestamp/package.json +1 -1
  83. package/dist/esm/components/Title/package.json +1 -1
  84. package/dist/esm/components/ToggleGroup/package.json +1 -1
  85. package/dist/esm/components/Toolbar/package.json +1 -1
  86. package/dist/esm/components/Tooltip/package.json +1 -1
  87. package/dist/esm/components/TreeView/package.json +1 -1
  88. package/dist/esm/components/Truncate/package.json +1 -1
  89. package/dist/esm/components/Wizard/hooks/package.json +1 -1
  90. package/dist/esm/components/Wizard/package.json +1 -1
  91. package/dist/esm/components/package.json +1 -1
  92. package/dist/esm/deprecated/components/ApplicationLauncher/package.json +1 -1
  93. package/dist/esm/deprecated/components/ContextSelector/package.json +1 -1
  94. package/dist/esm/deprecated/components/Dropdown/package.json +1 -1
  95. package/dist/esm/deprecated/components/OptionsMenu/package.json +1 -1
  96. package/dist/esm/deprecated/components/PageHeader/package.json +1 -1
  97. package/dist/esm/deprecated/components/Select/package.json +1 -1
  98. package/dist/esm/deprecated/components/Wizard/package.json +1 -1
  99. package/dist/esm/deprecated/components/package.json +1 -1
  100. package/dist/esm/deprecated/package.json +1 -1
  101. package/dist/esm/helpers/Popper/thirdparty/popper-core/package.json +1 -1
  102. package/dist/esm/helpers/package.json +1 -1
  103. package/dist/esm/layouts/Bullseye/package.json +1 -1
  104. package/dist/esm/layouts/Flex/package.json +1 -1
  105. package/dist/esm/layouts/Gallery/package.json +1 -1
  106. package/dist/esm/layouts/Grid/package.json +1 -1
  107. package/dist/esm/layouts/Level/package.json +1 -1
  108. package/dist/esm/layouts/Split/package.json +1 -1
  109. package/dist/esm/layouts/Stack/package.json +1 -1
  110. package/dist/esm/layouts/package.json +1 -1
  111. package/dist/esm/next/components/package.json +1 -1
  112. package/dist/esm/next/package.json +1 -1
  113. package/dist/esm/package.json +1 -1
  114. package/dist/js/components/AboutModal/package.json +1 -1
  115. package/dist/js/components/Accordion/package.json +1 -1
  116. package/dist/js/components/ActionList/package.json +1 -1
  117. package/dist/js/components/Alert/package.json +1 -1
  118. package/dist/js/components/Avatar/package.json +1 -1
  119. package/dist/js/components/BackToTop/package.json +1 -1
  120. package/dist/js/components/Backdrop/package.json +1 -1
  121. package/dist/js/components/BackgroundImage/package.json +1 -1
  122. package/dist/js/components/Badge/package.json +1 -1
  123. package/dist/js/components/Banner/package.json +1 -1
  124. package/dist/js/components/Brand/package.json +1 -1
  125. package/dist/js/components/Breadcrumb/package.json +1 -1
  126. package/dist/js/components/Button/package.json +1 -1
  127. package/dist/js/components/CalendarMonth/package.json +1 -1
  128. package/dist/js/components/Card/package.json +1 -1
  129. package/dist/js/components/Checkbox/package.json +1 -1
  130. package/dist/js/components/Chip/package.json +1 -1
  131. package/dist/js/components/ClipboardCopy/package.json +1 -1
  132. package/dist/js/components/CodeBlock/package.json +1 -1
  133. package/dist/js/components/DataList/package.json +1 -1
  134. package/dist/js/components/DatePicker/package.json +1 -1
  135. package/dist/js/components/DescriptionList/package.json +1 -1
  136. package/dist/js/components/Divider/package.json +1 -1
  137. package/dist/js/components/DragDrop/package.json +1 -1
  138. package/dist/js/components/Drawer/package.json +1 -1
  139. package/dist/js/components/Dropdown/package.json +1 -1
  140. package/dist/js/components/DualListSelector/package.json +1 -1
  141. package/dist/js/components/EmptyState/package.json +1 -1
  142. package/dist/js/components/ExpandableSection/package.json +1 -1
  143. package/dist/js/components/FileUpload/package.json +1 -1
  144. package/dist/js/components/Form/package.json +1 -1
  145. package/dist/js/components/FormSelect/package.json +1 -1
  146. package/dist/js/components/HelperText/package.json +1 -1
  147. package/dist/js/components/Hint/package.json +1 -1
  148. package/dist/js/components/Icon/package.json +1 -1
  149. package/dist/js/components/InputGroup/package.json +1 -1
  150. package/dist/js/components/JumpLinks/package.json +1 -1
  151. package/dist/js/components/Label/package.json +1 -1
  152. package/dist/js/components/LabelGroup/package.json +1 -1
  153. package/dist/js/components/List/package.json +1 -1
  154. package/dist/js/components/LoginPage/package.json +1 -1
  155. package/dist/js/components/Masthead/package.json +1 -1
  156. package/dist/js/components/Menu/package.json +1 -1
  157. package/dist/js/components/MenuToggle/package.json +1 -1
  158. package/dist/js/components/Modal/package.json +1 -1
  159. package/dist/js/components/MultipleFileUpload/package.json +1 -1
  160. package/dist/js/components/Nav/Nav.d.ts +4 -6
  161. package/dist/js/components/Nav/Nav.d.ts.map +1 -1
  162. package/dist/js/components/Nav/Nav.js +3 -4
  163. package/dist/js/components/Nav/Nav.js.map +1 -1
  164. package/dist/js/components/Nav/NavItem.js +1 -1
  165. package/dist/js/components/Nav/NavItem.js.map +1 -1
  166. package/dist/js/components/Nav/package.json +1 -1
  167. package/dist/js/components/NotificationBadge/package.json +1 -1
  168. package/dist/js/components/NotificationDrawer/package.json +1 -1
  169. package/dist/js/components/NumberInput/package.json +1 -1
  170. package/dist/js/components/OverflowMenu/package.json +1 -1
  171. package/dist/js/components/Page/package.json +1 -1
  172. package/dist/js/components/Pagination/package.json +1 -1
  173. package/dist/js/components/Panel/package.json +1 -1
  174. package/dist/js/components/Popover/package.json +1 -1
  175. package/dist/js/components/Progress/package.json +1 -1
  176. package/dist/js/components/ProgressStepper/package.json +1 -1
  177. package/dist/js/components/Radio/package.json +1 -1
  178. package/dist/js/components/SearchInput/package.json +1 -1
  179. package/dist/js/components/Select/package.json +1 -1
  180. package/dist/js/components/Sidebar/package.json +1 -1
  181. package/dist/js/components/SimpleList/package.json +1 -1
  182. package/dist/js/components/Skeleton/package.json +1 -1
  183. package/dist/js/components/SkipToContent/package.json +1 -1
  184. package/dist/js/components/Slider/package.json +1 -1
  185. package/dist/js/components/Spinner/package.json +1 -1
  186. package/dist/js/components/Switch/package.json +1 -1
  187. package/dist/js/components/Tabs/package.json +1 -1
  188. package/dist/js/components/Text/package.json +1 -1
  189. package/dist/js/components/TextArea/package.json +1 -1
  190. package/dist/js/components/TextInput/package.json +1 -1
  191. package/dist/js/components/TextInputGroup/package.json +1 -1
  192. package/dist/js/components/Tile/package.json +1 -1
  193. package/dist/js/components/TimePicker/package.json +1 -1
  194. package/dist/js/components/Timestamp/package.json +1 -1
  195. package/dist/js/components/Title/package.json +1 -1
  196. package/dist/js/components/ToggleGroup/package.json +1 -1
  197. package/dist/js/components/Toolbar/package.json +1 -1
  198. package/dist/js/components/Tooltip/package.json +1 -1
  199. package/dist/js/components/TreeView/package.json +1 -1
  200. package/dist/js/components/Truncate/package.json +1 -1
  201. package/dist/js/components/Wizard/hooks/package.json +1 -1
  202. package/dist/js/components/Wizard/package.json +1 -1
  203. package/dist/js/components/package.json +1 -1
  204. package/dist/js/deprecated/components/ApplicationLauncher/package.json +1 -1
  205. package/dist/js/deprecated/components/ContextSelector/package.json +1 -1
  206. package/dist/js/deprecated/components/Dropdown/package.json +1 -1
  207. package/dist/js/deprecated/components/OptionsMenu/package.json +1 -1
  208. package/dist/js/deprecated/components/PageHeader/package.json +1 -1
  209. package/dist/js/deprecated/components/Select/package.json +1 -1
  210. package/dist/js/deprecated/components/Wizard/package.json +1 -1
  211. package/dist/js/deprecated/components/package.json +1 -1
  212. package/dist/js/deprecated/package.json +1 -1
  213. package/dist/js/helpers/Popper/thirdparty/popper-core/package.json +1 -1
  214. package/dist/js/helpers/package.json +1 -1
  215. package/dist/js/layouts/Bullseye/package.json +1 -1
  216. package/dist/js/layouts/Flex/package.json +1 -1
  217. package/dist/js/layouts/Gallery/package.json +1 -1
  218. package/dist/js/layouts/Grid/package.json +1 -1
  219. package/dist/js/layouts/Level/package.json +1 -1
  220. package/dist/js/layouts/Split/package.json +1 -1
  221. package/dist/js/layouts/Stack/package.json +1 -1
  222. package/dist/js/layouts/package.json +1 -1
  223. package/dist/js/next/components/package.json +1 -1
  224. package/dist/js/next/package.json +1 -1
  225. package/dist/js/package.json +1 -1
  226. package/dist/umd/react-core.min.js +1 -1
  227. package/package.json +2 -2
  228. package/src/components/Nav/Nav.tsx +20 -23
  229. package/src/components/Nav/NavItem.tsx +1 -1
  230. package/src/components/Nav/examples/Nav.md +24 -0
  231. package/src/components/Nav/examples/NavDefault.tsx +1 -1
  232. package/src/components/Nav/examples/NavExpandable.tsx +8 -2
  233. package/src/components/Nav/examples/NavExpandableThirdLevel.tsx +8 -2
  234. package/src/components/Nav/examples/NavFlyout.tsx +1 -1
  235. package/src/components/Nav/examples/NavGrouped.tsx +1 -1
  236. package/src/components/Nav/examples/NavHorizontalSubNav.tsx +2 -2
  237. package/src/components/Nav/examples/NavLegacyTertiary.tsx +2 -2
  238. package/src/components/Nav/examples/NavMixed.tsx +4 -1
  239. package/src/demos/Nav.md +12 -12
  240. package/src/demos/NotificationDrawer/NotificationDrawer.md +2 -2
  241. package/src/demos/SearchInput/SearchInput.md +165 -124
  242. package/src/demos/Wizard/WizardDemo.md +2 -2
  243. package/src/demos/examples/DashboardWrapper.js +1 -1
  244. package/src/demos/examples/Masthead/MastheadWithUtilitiesAndUserDropdownMenu.tsx +1 -2
  245. package/src/demos/examples/Page/PageStickySectionBreadcrumb.tsx +1 -2
  246. package/src/demos/examples/Page/PageStickySectionGroup.tsx +1 -2
  247. package/src/demos/examples/Page/PageStickySectionGroupAlternate.tsx +1 -2
@@ -3,24 +3,25 @@ id: Search input
3
3
  section: components
4
4
  beta: true
5
5
  ---
6
- import {
7
- Button,
8
- Card,
9
- CardBody,
10
- CardFooter,
11
- DatePicker,
12
- Form,
13
- FormGroup,
14
- Grid,
15
- GridItem,
16
- Menu,
17
- MenuContent,
18
- MenuItem,
19
- MenuList,
20
- MenuToggle,
21
- Popper,
22
- SearchInput,
23
- TextInput
6
+
7
+ import {
8
+ Button,
9
+ Card,
10
+ CardBody,
11
+ CardFooter,
12
+ DatePicker,
13
+ Form,
14
+ FormGroup,
15
+ Grid,
16
+ GridItem,
17
+ Menu,
18
+ MenuContent,
19
+ MenuItem,
20
+ MenuList,
21
+ MenuToggle,
22
+ Popper,
23
+ SearchInput,
24
+ TextInput
24
25
  } from '@patternfly/react-core';
25
26
  import { words } from './words.js';
26
27
 
@@ -31,17 +32,9 @@ import { words } from './words.js';
31
32
  This demo handles building the advanced search form using the composable Menu, and the `SearchInput`'s `hint` prop.
32
33
  It also demonstrates wiring up the appropriate keyboard interactions, focus management, and general event handling.
33
34
 
34
-
35
35
  ```js
36
36
  import React from 'react';
37
- import {
38
- Menu,
39
- MenuContent,
40
- MenuItem,
41
- MenuList,
42
- Popper,
43
- SearchInput
44
- } from '@patternfly/react-core';
37
+ import { Menu, MenuContent, MenuItem, MenuList, Popper, SearchInput } from '@patternfly/react-core';
45
38
 
46
39
  import { words } from './words.js';
47
40
 
@@ -49,32 +42,52 @@ SearchAutocomplete = () => {
49
42
  const [value, setValue] = React.useState('');
50
43
  const [hint, setHint] = React.useState('');
51
44
  const [autocompleteOptions, setAutocompleteOptions] = React.useState([]);
52
-
45
+
53
46
  const [isAutocompleteOpen, setIsAutocompleteOpen] = React.useState(false);
54
-
47
+
55
48
  const searchInputRef = React.useRef(null);
56
49
  const autocompleteRef = React.useRef(null);
57
-
50
+
58
51
  const onClear = () => {
59
52
  setValue('');
60
53
  };
61
-
62
- const onChange = (newValue) => {
63
- if (newValue !== '' && searchInputRef && searchInputRef.current && searchInputRef.current.contains(document.activeElement)) {
54
+
55
+ const onChange = (_event, newValue) => {
56
+ if (
57
+ newValue !== '' &&
58
+ searchInputRef &&
59
+ searchInputRef.current &&
60
+ searchInputRef.current.contains(document.activeElement)
61
+ ) {
64
62
  setIsAutocompleteOpen(true);
65
-
63
+
66
64
  // When the value of the search input changes, build a list of no more than 10 autocomplete options.
67
65
  // Options which start with the search input value are listed first, followed by options which contain
68
66
  // the search input value.
69
- let options = words.filter((option) => option.startsWith(newValue.toLowerCase())).map((option) => <MenuItem itemId={option} key={option}>{option}</MenuItem>);
67
+ let options = words
68
+ .filter((option) => option.startsWith(newValue.toLowerCase()))
69
+ .map((option) => (
70
+ <MenuItem itemId={option} key={option}>
71
+ {option}
72
+ </MenuItem>
73
+ ));
70
74
  if (options.length > 10) {
71
- options = options.slice(0,10);
75
+ options = options.slice(0, 10);
72
76
  } else {
73
- options = [...options, ...words.filter((option) => !option.startsWith(newValue.toLowerCase()) && option.includes(newValue.toLowerCase())).map((option) => <MenuItem itemId={option} key={option}>{option}</MenuItem>)].slice(0, 10)
77
+ options = [
78
+ ...options,
79
+ ...words
80
+ .filter((option) => !option.startsWith(newValue.toLowerCase()) && option.includes(newValue.toLowerCase()))
81
+ .map((option) => (
82
+ <MenuItem itemId={option} key={option}>
83
+ {option}
84
+ </MenuItem>
85
+ ))
86
+ ].slice(0, 10);
74
87
  }
75
-
88
+
76
89
  // The hint is set whenever there is only one autocomplete option left.
77
- setHint(options.length === 1? options[0].props.itemId : '');
90
+ setHint(options.length === 1 ? options[0].props.itemId : '');
78
91
  // The menu is hidden if there are no options
79
92
  setIsAutocompleteOpen(options.length > 0);
80
93
  setAutocompleteOptions(options);
@@ -83,7 +96,7 @@ SearchAutocomplete = () => {
83
96
  }
84
97
  setValue(newValue);
85
98
  };
86
-
99
+
87
100
  // Whenever an autocomplete option is selected, set the search input value, close the menu, and put the browser
88
101
  // focus back on the search input
89
102
  const onSelect = (e, itemId) => {
@@ -92,53 +105,57 @@ SearchAutocomplete = () => {
92
105
  setIsAutocompleteOpen(false);
93
106
  searchInputRef.current.focus();
94
107
  };
95
-
96
- const handleMenuKeys = event => {
97
- // If there is a hint while the browser focus is on the search input, tab or right arrow will 'accept' the hint value
108
+
109
+ const handleMenuKeys = (event) => {
110
+ // If there is a hint while the browser focus is on the search input, tab or right arrow will 'accept' the hint value
98
111
  // and set it as the search input value
99
112
  if (hint && (event.key === 'Tab' || event.key === 'ArrowRight') && searchInputRef.current === event.target) {
100
113
  setValue(hint);
101
114
  setHint('');
102
115
  setIsAutocompleteOpen(false);
103
116
  if (event.key === 'ArrowRight') {
104
- event.preventDefault();
117
+ event.preventDefault();
105
118
  }
106
- // if the autocomplete is open and the browser focus is on the search input,
119
+ // if the autocomplete is open and the browser focus is on the search input,
107
120
  } else if (isAutocompleteOpen && searchInputRef.current && searchInputRef.current === event.target) {
108
121
  // the escape key closes the autocomplete menu and keeps the focus on the search input.
109
122
  if (event.key === 'Escape') {
110
123
  setIsAutocompleteOpen(false);
111
124
  searchInputRef.current.focus();
112
- // the up and down arrow keys move browser focus into the autocomplete menu
125
+ // the up and down arrow keys move browser focus into the autocomplete menu
113
126
  } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
114
127
  const firstElement = autocompleteRef.current.querySelector('li > button:not(:disabled)');
115
128
  firstElement && firstElement.focus();
116
129
  event.preventDefault(); // by default, the up and down arrow keys scroll the window
117
- // the tab, enter, and space keys will close the menu, and the tab key will move browser
118
- // focus forward one element (by default)
119
- } else if (event.key === 'Tab'|| event.key === "Enter" || event.key === 'Space'){
130
+ // the tab, enter, and space keys will close the menu, and the tab key will move browser
131
+ // focus forward one element (by default)
132
+ } else if (event.key === 'Tab' || event.key === 'Enter' || event.key === 'Space') {
120
133
  setIsAutocompleteOpen(false);
121
- if (event.key === "Enter" || event.key === 'Space') {
134
+ if (event.key === 'Enter' || event.key === 'Space') {
122
135
  event.preventDefault();
123
136
  }
124
137
  }
125
- // If the autocomplete is open and the browser focus is in the autocomplete menu
126
- // hitting tab will close the autocomplete and but browser focus back on the search input.
127
- } else if (isAutocompleteOpen && autocompleteRef.current.contains(event.target) && (event.key === 'Tab')) {
138
+ // If the autocomplete is open and the browser focus is in the autocomplete menu
139
+ // hitting tab will close the autocomplete and but browser focus back on the search input.
140
+ } else if (isAutocompleteOpen && autocompleteRef.current.contains(event.target) && event.key === 'Tab') {
128
141
  event.preventDefault();
129
142
  setIsAutocompleteOpen(false);
130
143
  searchInputRef.current.focus();
131
144
  }
132
-
133
145
  };
134
-
146
+
135
147
  // The autocomplete menu should close if the user clicks outside the menu.
136
- const handleClickOutside = event => {
137
- if (isAutocompleteOpen && autocompleteRef && autocompleteRef.current && !autocompleteRef.current.contains(event.target)) {
148
+ const handleClickOutside = (event) => {
149
+ if (
150
+ isAutocompleteOpen &&
151
+ autocompleteRef &&
152
+ autocompleteRef.current &&
153
+ !autocompleteRef.current.contains(event.target)
154
+ ) {
138
155
  setIsAutocompleteOpen(false);
139
156
  }
140
157
  };
141
-
158
+
142
159
  React.useEffect(() => {
143
160
  window.addEventListener('keydown', handleMenuKeys);
144
161
  window.addEventListener('click', handleClickOutside);
@@ -147,7 +164,7 @@ SearchAutocomplete = () => {
147
164
  window.removeEventListener('click', handleClickOutside);
148
165
  };
149
166
  }, [isAutocompleteOpen, hint, searchInputRef.current]);
150
-
167
+
151
168
  const searchInput = (
152
169
  <SearchInput
153
170
  value={value}
@@ -158,17 +175,14 @@ SearchAutocomplete = () => {
158
175
  id="autocomplete-search"
159
176
  />
160
177
  );
161
-
178
+
162
179
  const autocomplete = (
163
180
  <Menu ref={autocompleteRef} onSelect={onSelect}>
164
181
  <MenuContent>
165
- <MenuList>
166
- {autocompleteOptions}
167
- </MenuList>
182
+ <MenuList>{autocompleteOptions}</MenuList>
168
183
  </MenuContent>
169
184
  </Menu>
170
185
  );
171
-
172
186
 
173
187
  return (
174
188
  <Popper
@@ -187,7 +201,7 @@ SearchAutocomplete = () => {
187
201
 
188
202
  ### Composable advanced search
189
203
 
190
- This demo handles building the advanced search form using the composable Menu, as well as wiring up a
204
+ This demo handles building the advanced search form using the composable Menu, as well as wiring up a
191
205
  select using the composable Menu and MenuToggle components. This demo also demonstrates wiring up the appropriate
192
206
  keyboard interactions, focus management, and general event handling.
193
207
 
@@ -195,14 +209,14 @@ Note: This demo and its handling of 'date within' and a date picker is modeled a
195
209
 
196
210
  ```js
197
211
  import React from 'react';
198
- import {
212
+ import {
199
213
  ActionGroup,
200
- Button,
214
+ Button,
201
215
  DatePicker,
202
- Form,
216
+ Form,
203
217
  FormGroup,
204
218
  Grid,
205
- GridItem,
219
+ GridItem,
206
220
  isValidDate,
207
221
  Menu,
208
222
  MenuContent,
@@ -212,8 +226,8 @@ import {
212
226
  Panel,
213
227
  PanelMain,
214
228
  PanelMainBody,
215
- Popper,
216
- SearchInput,
229
+ Popper,
230
+ SearchInput,
217
231
  TextInput,
218
232
  yyyyMMddFormat
219
233
  } from '@patternfly/react-core';
@@ -223,25 +237,25 @@ AdvancedComposableSearchInput = () => {
223
237
  const [hasWords, setHasWords] = React.useState('');
224
238
  const [dateWithin, setDateWithin] = React.useState('1 day');
225
239
  const [date, setDate] = React.useState();
226
-
240
+
227
241
  const [isAdvancedSearchOpen, setIsAdvancedSearchOpen] = React.useState(false);
228
242
  const [isDateWithinOpen, setIsDateWithinOpen] = React.useState(false);
229
-
243
+
230
244
  const isInitialMount = React.useRef(true);
231
245
  const firstAttrRef = React.useRef(null);
232
246
  const searchInputRef = React.useRef(null);
233
247
  const advancedSearchPaneRef = React.useRef(null);
234
248
  const dateWithinToggleRef = React.useRef();
235
249
  const dateWithinMenuRef = React.useRef();
236
-
250
+
237
251
  const onClear = () => {
238
252
  setValue('');
239
253
  setHasWords('');
240
254
  setDateWithin('');
241
255
  setDate('');
242
256
  };
243
-
244
- const onChange = (value) => {
257
+
258
+ const onChange = (_event, value) => {
245
259
  if (value.length <= hasWords.length + 1) {
246
260
  setValue(value);
247
261
  setHasWords(value);
@@ -249,7 +263,7 @@ AdvancedComposableSearchInput = () => {
249
263
  setValue(hasWords);
250
264
  }
251
265
  };
252
-
266
+
253
267
  // After initial page load, whenever the advanced search menu is opened, the browser focus should be placed on the
254
268
  // first advanced search form input. Whenever the advanced search menu is closed, the browser focus should
255
269
  // be returned to the search input.
@@ -264,38 +278,51 @@ AdvancedComposableSearchInput = () => {
264
278
  }
265
279
  }
266
280
  }, [isAdvancedSearchOpen]);
267
-
268
- // If a menu is open and has browser focus, then the escape key closes them and puts the browser focus onto their
281
+
282
+ // If a menu is open and has browser focus, then the escape key closes them and puts the browser focus onto their
269
283
  // respective toggle. The 'date within' menu also needs to close when the 'tab' key is hit. However, hitting tab while
270
284
  // focus is in the advanced search form should move the focus to the next form input, not close the advanced search
271
285
  // menu.
272
- const handleMenuKeys = event => {
286
+ const handleMenuKeys = (event) => {
273
287
  if (isDateWithinOpen && dateWithinMenuRef.current && dateWithinMenuRef.current.contains(event.target)) {
274
288
  if (event.key === 'Escape' || event.key === 'Tab') {
275
289
  setIsDateWithinOpen(!isDateWithinOpen);
276
290
  dateWithinToggleRef.current.focus();
277
291
  }
278
- }
292
+ }
279
293
  if (isAdvancedSearchOpen && advancedSearchPaneRef.current && advancedSearchPaneRef.current.contains(event.target)) {
280
- if (event.key === 'Escape' ||
281
- (event.key === 'Tab' && !event.shiftKey && advancedSearchPaneRef.current.querySelector('button[type=reset]') === event.target)
294
+ if (
295
+ event.key === 'Escape' ||
296
+ (event.key === 'Tab' &&
297
+ !event.shiftKey &&
298
+ advancedSearchPaneRef.current.querySelector('button[type=reset]') === event.target)
282
299
  ) {
283
300
  setIsAdvancedSearchOpen(!isAdvancedSearchOpen);
284
301
  searchInputRef.current.focus();
285
302
  }
286
- }
303
+ }
287
304
  };
288
-
305
+
289
306
  // If a menu is open and has browser focus, then clicking outside the menu should close it.
290
- const handleClickOutside = event => {
291
- if (isDateWithinOpen && dateWithinMenuRef && dateWithinMenuRef.current && !dateWithinMenuRef.current.contains(event.target)) {
307
+ const handleClickOutside = (event) => {
308
+ if (
309
+ isDateWithinOpen &&
310
+ dateWithinMenuRef &&
311
+ dateWithinMenuRef.current &&
312
+ !dateWithinMenuRef.current.contains(event.target)
313
+ ) {
292
314
  setIsDateWithinOpen(false);
293
- }
294
- if (isAdvancedSearchOpen && advancedSearchPaneRef && advancedSearchPaneRef.current && !advancedSearchPaneRef.current.contains(event.target)) {
315
+ }
316
+ if (
317
+ isAdvancedSearchOpen &&
318
+ advancedSearchPaneRef &&
319
+ advancedSearchPaneRef.current &&
320
+ !advancedSearchPaneRef.current.contains(event.target)
321
+ ) {
295
322
  setIsAdvancedSearchOpen(false);
296
323
  }
297
324
  };
298
-
325
+
299
326
  React.useEffect(() => {
300
327
  window.addEventListener('keydown', handleMenuKeys);
301
328
  window.addEventListener('click', handleClickOutside);
@@ -304,12 +331,11 @@ AdvancedComposableSearchInput = () => {
304
331
  window.removeEventListener('click', handleClickOutside);
305
332
  };
306
333
  }, [dateWithinMenuRef.current, advancedSearchPaneRef.current, isAdvancedSearchOpen, isDateWithinOpen]);
307
-
308
-
334
+
309
335
  // This demo and its handling of 'date within' and a date picker is modeled after the gmail advanced search form.
310
336
  const onSubmit = (event, value) => {
311
337
  event.preventDefault();
312
-
338
+
313
339
  if (isValidDate(new Date(date)) && dateWithin) {
314
340
  let afterDate = new Date(date);
315
341
  let toDate = new Date(date);
@@ -355,21 +381,21 @@ AdvancedComposableSearchInput = () => {
355
381
  toDate.setDate(toDate.getDate() + 1);
356
382
  break;
357
383
  }
358
- setValue(`${hasWords && (hasWords + " ")}after:${yyyyMMddFormat(afterDate)} to:${yyyyMMddFormat(toDate)}`)
384
+ setValue(`${hasWords && hasWords + ' '}after:${yyyyMMddFormat(afterDate)} to:${yyyyMMddFormat(toDate)}`);
359
385
  } else {
360
386
  setValue(hasWords);
361
387
  }
362
-
388
+
363
389
  setIsAdvancedSearchOpen(false);
364
390
  };
365
-
391
+
366
392
  const searchInput = (
367
393
  <SearchInput
368
394
  value={value}
369
- onChange={(_event, value) => onChange(value)}
395
+ onChange={onChange}
370
396
  onToggleAdvancedSearch={(e, isOpen) => {
371
397
  e.stopPropagation();
372
- setIsAdvancedSearchOpen(isOpen)
398
+ setIsAdvancedSearchOpen(isOpen);
373
399
  }}
374
400
  isAdvancedSearchOpen={isAdvancedSearchOpen}
375
401
  onClear={onClear}
@@ -378,10 +404,10 @@ AdvancedComposableSearchInput = () => {
378
404
  id="custom-advanced-search"
379
405
  />
380
406
  );
381
-
382
- // Clicking the 'date within' toggle should open its associated menu and then place the browser
383
- // focus on the first menu item.
384
- const toggleDateWithinMenu = ev => {
407
+
408
+ // Clicking the 'date within' toggle should open its associated menu and then place the browser
409
+ // focus on the first menu item.
410
+ const toggleDateWithinMenu = (ev) => {
385
411
  ev.stopPropagation(); // Stop handleClickOutside from handling
386
412
  setTimeout(() => {
387
413
  if (dateWithinMenuRef.current) {
@@ -391,7 +417,7 @@ AdvancedComposableSearchInput = () => {
391
417
  }, 0);
392
418
  setIsDateWithinOpen(!isDateWithinOpen);
393
419
  };
394
-
420
+
395
421
  // Selecting a date within option closes the menu, sets the value of date within, and puts browser focus back
396
422
  // on the date within toggle.
397
423
  const onDateWithinSelect = (e, itemId) => {
@@ -402,7 +428,7 @@ AdvancedComposableSearchInput = () => {
402
428
  dateWithinToggleRef.current.focus();
403
429
  }
404
430
  };
405
-
431
+
406
432
  const dateWithinOptions = (
407
433
  <Menu ref={dateWithinMenuRef} selected={dateWithin} onSelect={onDateWithinSelect}>
408
434
  <MenuContent>
@@ -419,25 +445,30 @@ AdvancedComposableSearchInput = () => {
419
445
  </MenuContent>
420
446
  </Menu>
421
447
  );
422
-
448
+
423
449
  const dateWithinToggle = (
424
- <MenuToggle ref={dateWithinToggleRef} onClick={toggleDateWithinMenu} isExpanded={isDateWithinOpen} style={{width: "100%"}}>
450
+ <MenuToggle
451
+ ref={dateWithinToggleRef}
452
+ onClick={toggleDateWithinMenu}
453
+ isExpanded={isDateWithinOpen}
454
+ style={{ width: '100%' }}
455
+ >
425
456
  {dateWithin}
426
457
  </MenuToggle>
427
458
  );
428
-
459
+
429
460
  const advancedForm = (
430
461
  <div ref={advancedSearchPaneRef} role="dialog" aria-label="Advanced search form">
431
- <Panel variant='raised'>
462
+ <Panel variant="raised">
432
463
  <PanelMain>
433
464
  <PanelMainBody>
434
465
  <Form>
435
- <FormGroup label='Has the words' fieldId='has-words' key='has-words'>
466
+ <FormGroup label="Has the words" fieldId="has-words" key="has-words">
436
467
  <TextInput
437
- type='text'
438
- id='has-words'
468
+ type="text"
469
+ id="has-words"
439
470
  value={hasWords}
440
- onChange={value => {
471
+ onChange={(value) => {
441
472
  setHasWords(value);
442
473
  setValue(value);
443
474
  }}
@@ -446,26 +477,36 @@ AdvancedComposableSearchInput = () => {
446
477
  </FormGroup>
447
478
  <Grid hasGutter md={6}>
448
479
  <GridItem>
449
- <FormGroup label='Date within' fieldId='date-within' key='date-within'>
450
- <Popper trigger={dateWithinToggle} triggerRef={dateWithinToggleRef} popper={dateWithinOptions} popperRef={dateWithinMenuRef} isVisible={isDateWithinOpen} />
480
+ <FormGroup label="Date within" fieldId="date-within" key="date-within">
481
+ <Popper
482
+ trigger={dateWithinToggle}
483
+ triggerRef={dateWithinToggleRef}
484
+ popper={dateWithinOptions}
485
+ popperRef={dateWithinMenuRef}
486
+ isVisible={isDateWithinOpen}
487
+ />
451
488
  </FormGroup>
452
489
  </GridItem>
453
490
  <GridItem>
454
- <FormGroup label='Of date' fieldId='date' key='date'>
455
- <DatePicker
456
- id="datePicker"
457
- style={{width: "100%"}}
458
- value={date}
459
- onChange={setDate}
460
- appendTo={() => document.querySelector("#datePicker")}
491
+ <FormGroup label="Of date" fieldId="date" key="date">
492
+ <DatePicker
493
+ id="datePicker"
494
+ style={{ width: '100%' }}
495
+ value={date}
496
+ onChange={setDate}
497
+ appendTo={() => document.querySelector('#datePicker')}
461
498
  />
462
499
  </FormGroup>
463
500
  </GridItem>
464
501
  </Grid>
465
502
  <ActionGroup>
466
- <Button variant="primary" type="submit" onClick={(e) => onSubmit(null, e)}>Submit</Button>
503
+ <Button variant="primary" type="submit" onClick={(e) => onSubmit(null, e)}>
504
+ Submit
505
+ </Button>
467
506
  {!!onClear && (
468
- <Button variant="link" type="reset" onClick={onClear}>Reset</Button>
507
+ <Button variant="link" type="reset" onClick={onClear}>
508
+ Reset
509
+ </Button>
469
510
  )}
470
511
  </ActionGroup>
471
512
  </Form>
@@ -484,7 +525,7 @@ AdvancedComposableSearchInput = () => {
484
525
  popperRef={advancedSearchPaneRef}
485
526
  isVisible={isAdvancedSearchOpen}
486
527
  enableFlip={false}
487
- appendTo={() => document.querySelector("#custom-advanced-search")}
528
+ appendTo={() => document.querySelector('#custom-advanced-search')}
488
529
  />
489
530
  );
490
531
  };
@@ -458,7 +458,7 @@ class WizardFullPageWithDrawerDemo extends React.Component {
458
458
  isDrawerExpanded: false
459
459
  });
460
460
  };
461
- this.onNavSelect = (result) => {
461
+ this.onNavSelect = (_event, result) => {
462
462
  this.setState({
463
463
  activeItem: result.itemId
464
464
  });
@@ -656,7 +656,7 @@ class WizardFullPageWithDrawerInfoStepDemo extends React.Component {
656
656
  isDrawerExpanded: false
657
657
  });
658
658
  };
659
- this.onNavSelect = (result) => {
659
+ this.onNavSelect = (_event, result) => {
660
660
  this.setState({
661
661
  activeItem: result.itemId
662
662
  });
@@ -42,7 +42,7 @@ export default class DashboardWrapper extends React.Component {
42
42
  activeItem: 1
43
43
  };
44
44
 
45
- this.onNavSelect = (result) => {
45
+ this.onNavSelect = (_event, result) => {
46
46
  this.setState({
47
47
  activeItem: result.itemId
48
48
  });
@@ -63,7 +63,6 @@ interface NavOnSelectProps {
63
63
  groupId: number | string;
64
64
  itemId: number | string;
65
65
  to: string;
66
- event: React.FormEvent<HTMLInputElement>;
67
66
  }
68
67
 
69
68
  export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent = () => {
@@ -79,7 +78,7 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
79
78
  const menuRef = React.useRef<HTMLDivElement>(null);
80
79
  const toggleRef = React.useRef<HTMLButtonElement>(null);
81
80
 
82
- const onNavSelect = (selectedItem: NavOnSelectProps) => {
81
+ const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => {
83
82
  typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId);
84
83
  };
85
84
 
@@ -51,7 +51,6 @@ interface NavOnSelectProps {
51
51
  groupId: number | string;
52
52
  itemId: number | string;
53
53
  to: string;
54
- event: React.FormEvent<HTMLInputElement>;
55
54
  }
56
55
 
57
56
  export const PageStickySectionBreadcrumb: React.FunctionComponent = () => {
@@ -60,7 +59,7 @@ export const PageStickySectionBreadcrumb: React.FunctionComponent = () => {
60
59
  const [isFullKebabDropdownOpen, setIsFullKebabDropdownOpen] = React.useState(false);
61
60
  const [activeItem, setActiveItem] = React.useState(1);
62
61
 
63
- const onNavSelect = (selectedItem: NavOnSelectProps) => {
62
+ const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => {
64
63
  typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId);
65
64
  };
66
65
 
@@ -51,7 +51,6 @@ interface NavOnSelectProps {
51
51
  groupId: number | string;
52
52
  itemId: number | string;
53
53
  to: string;
54
- event: React.FormEvent<HTMLInputElement>;
55
54
  }
56
55
 
57
56
  export const PageStickySectionGroup: React.FunctionComponent = () => {
@@ -60,7 +59,7 @@ export const PageStickySectionGroup: React.FunctionComponent = () => {
60
59
  const [isFullKebabDropdownOpen, setIsFullKebabDropdownOpen] = React.useState(false);
61
60
  const [activeItem, setActiveItem] = React.useState(1);
62
61
 
63
- const onNavSelect = (selectedItem: NavOnSelectProps) => {
62
+ const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => {
64
63
  typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId);
65
64
  };
66
65
 
@@ -53,7 +53,6 @@ interface NavOnSelectProps {
53
53
  groupId: number | string;
54
54
  itemId: number | string;
55
55
  to: string;
56
- event: React.FormEvent<HTMLInputElement>;
57
56
  }
58
57
 
59
58
  export const PageStickySectionGroupAlternate: React.FunctionComponent = () => {
@@ -62,7 +61,7 @@ export const PageStickySectionGroupAlternate: React.FunctionComponent = () => {
62
61
  const [isFullKebabDropdownOpen, setIsFullKebabDropdownOpen] = React.useState(false);
63
62
  const [activeItem, setActiveItem] = React.useState(1);
64
63
 
65
- const onNavSelect = (selectedItem: NavOnSelectProps) => {
64
+ const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => {
66
65
  typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId);
67
66
  };
68
67