@patternfly/react-core 5.0.0-alpha.85 → 5.0.0-alpha.86

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 (244) hide show
  1. package/CHANGELOG.md +10 -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/MultipleFileUpload.d.ts +2 -2
  48. package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.d.ts.map +1 -1
  49. package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.js +2 -2
  50. package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.js.map +1 -1
  51. package/dist/esm/components/MultipleFileUpload/package.json +1 -1
  52. package/dist/esm/components/Nav/package.json +1 -1
  53. package/dist/esm/components/NotificationBadge/package.json +1 -1
  54. package/dist/esm/components/NotificationDrawer/package.json +1 -1
  55. package/dist/esm/components/NumberInput/package.json +1 -1
  56. package/dist/esm/components/OverflowMenu/package.json +1 -1
  57. package/dist/esm/components/Page/package.json +1 -1
  58. package/dist/esm/components/Pagination/package.json +1 -1
  59. package/dist/esm/components/Panel/package.json +1 -1
  60. package/dist/esm/components/Popover/package.json +1 -1
  61. package/dist/esm/components/Progress/package.json +1 -1
  62. package/dist/esm/components/ProgressStepper/package.json +1 -1
  63. package/dist/esm/components/Radio/package.json +1 -1
  64. package/dist/esm/components/SearchInput/package.json +1 -1
  65. package/dist/esm/components/Select/package.json +1 -1
  66. package/dist/esm/components/Sidebar/package.json +1 -1
  67. package/dist/esm/components/SimpleList/package.json +1 -1
  68. package/dist/esm/components/Skeleton/package.json +1 -1
  69. package/dist/esm/components/SkipToContent/package.json +1 -1
  70. package/dist/esm/components/Slider/Slider.d.ts +2 -1
  71. package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
  72. package/dist/esm/components/Slider/Slider.js +7 -7
  73. package/dist/esm/components/Slider/Slider.js.map +1 -1
  74. package/dist/esm/components/Slider/package.json +1 -1
  75. package/dist/esm/components/Spinner/package.json +1 -1
  76. package/dist/esm/components/Switch/package.json +1 -1
  77. package/dist/esm/components/Tabs/package.json +1 -1
  78. package/dist/esm/components/Text/package.json +1 -1
  79. package/dist/esm/components/TextArea/package.json +1 -1
  80. package/dist/esm/components/TextInput/package.json +1 -1
  81. package/dist/esm/components/TextInputGroup/package.json +1 -1
  82. package/dist/esm/components/Tile/package.json +1 -1
  83. package/dist/esm/components/TimePicker/package.json +1 -1
  84. package/dist/esm/components/Timestamp/package.json +1 -1
  85. package/dist/esm/components/Title/package.json +1 -1
  86. package/dist/esm/components/ToggleGroup/package.json +1 -1
  87. package/dist/esm/components/Toolbar/package.json +1 -1
  88. package/dist/esm/components/Tooltip/package.json +1 -1
  89. package/dist/esm/components/TreeView/package.json +1 -1
  90. package/dist/esm/components/Truncate/package.json +1 -1
  91. package/dist/esm/components/Wizard/hooks/package.json +1 -1
  92. package/dist/esm/components/Wizard/package.json +1 -1
  93. package/dist/esm/components/package.json +1 -1
  94. package/dist/esm/deprecated/components/ApplicationLauncher/package.json +1 -1
  95. package/dist/esm/deprecated/components/ContextSelector/package.json +1 -1
  96. package/dist/esm/deprecated/components/Dropdown/package.json +1 -1
  97. package/dist/esm/deprecated/components/OptionsMenu/package.json +1 -1
  98. package/dist/esm/deprecated/components/PageHeader/package.json +1 -1
  99. package/dist/esm/deprecated/components/Select/package.json +1 -1
  100. package/dist/esm/deprecated/components/Wizard/package.json +1 -1
  101. package/dist/esm/deprecated/components/package.json +1 -1
  102. package/dist/esm/deprecated/package.json +1 -1
  103. package/dist/esm/helpers/Popper/thirdparty/popper-core/package.json +1 -1
  104. package/dist/esm/helpers/package.json +1 -1
  105. package/dist/esm/layouts/Bullseye/package.json +1 -1
  106. package/dist/esm/layouts/Flex/package.json +1 -1
  107. package/dist/esm/layouts/Gallery/package.json +1 -1
  108. package/dist/esm/layouts/Grid/package.json +1 -1
  109. package/dist/esm/layouts/Level/package.json +1 -1
  110. package/dist/esm/layouts/Split/package.json +1 -1
  111. package/dist/esm/layouts/Stack/package.json +1 -1
  112. package/dist/esm/layouts/package.json +1 -1
  113. package/dist/esm/next/components/package.json +1 -1
  114. package/dist/esm/next/package.json +1 -1
  115. package/dist/esm/package.json +1 -1
  116. package/dist/js/components/AboutModal/package.json +1 -1
  117. package/dist/js/components/Accordion/package.json +1 -1
  118. package/dist/js/components/ActionList/package.json +1 -1
  119. package/dist/js/components/Alert/package.json +1 -1
  120. package/dist/js/components/Avatar/package.json +1 -1
  121. package/dist/js/components/BackToTop/package.json +1 -1
  122. package/dist/js/components/Backdrop/package.json +1 -1
  123. package/dist/js/components/BackgroundImage/package.json +1 -1
  124. package/dist/js/components/Badge/package.json +1 -1
  125. package/dist/js/components/Banner/package.json +1 -1
  126. package/dist/js/components/Brand/package.json +1 -1
  127. package/dist/js/components/Breadcrumb/package.json +1 -1
  128. package/dist/js/components/Button/package.json +1 -1
  129. package/dist/js/components/CalendarMonth/package.json +1 -1
  130. package/dist/js/components/Card/package.json +1 -1
  131. package/dist/js/components/Checkbox/package.json +1 -1
  132. package/dist/js/components/Chip/package.json +1 -1
  133. package/dist/js/components/ClipboardCopy/package.json +1 -1
  134. package/dist/js/components/CodeBlock/package.json +1 -1
  135. package/dist/js/components/DataList/package.json +1 -1
  136. package/dist/js/components/DatePicker/package.json +1 -1
  137. package/dist/js/components/DescriptionList/package.json +1 -1
  138. package/dist/js/components/Divider/package.json +1 -1
  139. package/dist/js/components/DragDrop/package.json +1 -1
  140. package/dist/js/components/Drawer/package.json +1 -1
  141. package/dist/js/components/Dropdown/package.json +1 -1
  142. package/dist/js/components/DualListSelector/package.json +1 -1
  143. package/dist/js/components/EmptyState/package.json +1 -1
  144. package/dist/js/components/ExpandableSection/package.json +1 -1
  145. package/dist/js/components/FileUpload/package.json +1 -1
  146. package/dist/js/components/Form/package.json +1 -1
  147. package/dist/js/components/FormSelect/package.json +1 -1
  148. package/dist/js/components/HelperText/package.json +1 -1
  149. package/dist/js/components/Hint/package.json +1 -1
  150. package/dist/js/components/Icon/package.json +1 -1
  151. package/dist/js/components/InputGroup/package.json +1 -1
  152. package/dist/js/components/JumpLinks/package.json +1 -1
  153. package/dist/js/components/Label/package.json +1 -1
  154. package/dist/js/components/LabelGroup/package.json +1 -1
  155. package/dist/js/components/List/package.json +1 -1
  156. package/dist/js/components/LoginPage/package.json +1 -1
  157. package/dist/js/components/Masthead/package.json +1 -1
  158. package/dist/js/components/Menu/package.json +1 -1
  159. package/dist/js/components/MenuToggle/package.json +1 -1
  160. package/dist/js/components/Modal/package.json +1 -1
  161. package/dist/js/components/MultipleFileUpload/MultipleFileUpload.d.ts +2 -2
  162. package/dist/js/components/MultipleFileUpload/MultipleFileUpload.d.ts.map +1 -1
  163. package/dist/js/components/MultipleFileUpload/MultipleFileUpload.js +2 -2
  164. package/dist/js/components/MultipleFileUpload/MultipleFileUpload.js.map +1 -1
  165. package/dist/js/components/MultipleFileUpload/package.json +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/Slider.d.ts +2 -1
  185. package/dist/js/components/Slider/Slider.d.ts.map +1 -1
  186. package/dist/js/components/Slider/Slider.js +7 -7
  187. package/dist/js/components/Slider/Slider.js.map +1 -1
  188. package/dist/js/components/Slider/package.json +1 -1
  189. package/dist/js/components/Spinner/package.json +1 -1
  190. package/dist/js/components/Switch/package.json +1 -1
  191. package/dist/js/components/Tabs/package.json +1 -1
  192. package/dist/js/components/Text/package.json +1 -1
  193. package/dist/js/components/TextArea/package.json +1 -1
  194. package/dist/js/components/TextInput/package.json +1 -1
  195. package/dist/js/components/TextInputGroup/package.json +1 -1
  196. package/dist/js/components/Tile/package.json +1 -1
  197. package/dist/js/components/TimePicker/package.json +1 -1
  198. package/dist/js/components/Timestamp/package.json +1 -1
  199. package/dist/js/components/Title/package.json +1 -1
  200. package/dist/js/components/ToggleGroup/package.json +1 -1
  201. package/dist/js/components/Toolbar/package.json +1 -1
  202. package/dist/js/components/Tooltip/package.json +1 -1
  203. package/dist/js/components/TreeView/package.json +1 -1
  204. package/dist/js/components/Truncate/package.json +1 -1
  205. package/dist/js/components/Wizard/hooks/package.json +1 -1
  206. package/dist/js/components/Wizard/package.json +1 -1
  207. package/dist/js/components/package.json +1 -1
  208. package/dist/js/deprecated/components/ApplicationLauncher/package.json +1 -1
  209. package/dist/js/deprecated/components/ContextSelector/package.json +1 -1
  210. package/dist/js/deprecated/components/Dropdown/package.json +1 -1
  211. package/dist/js/deprecated/components/OptionsMenu/package.json +1 -1
  212. package/dist/js/deprecated/components/PageHeader/package.json +1 -1
  213. package/dist/js/deprecated/components/Select/package.json +1 -1
  214. package/dist/js/deprecated/components/Wizard/package.json +1 -1
  215. package/dist/js/deprecated/components/package.json +1 -1
  216. package/dist/js/deprecated/package.json +1 -1
  217. package/dist/js/helpers/Popper/thirdparty/popper-core/package.json +1 -1
  218. package/dist/js/helpers/package.json +1 -1
  219. package/dist/js/layouts/Bullseye/package.json +1 -1
  220. package/dist/js/layouts/Flex/package.json +1 -1
  221. package/dist/js/layouts/Gallery/package.json +1 -1
  222. package/dist/js/layouts/Grid/package.json +1 -1
  223. package/dist/js/layouts/Level/package.json +1 -1
  224. package/dist/js/layouts/Split/package.json +1 -1
  225. package/dist/js/layouts/Stack/package.json +1 -1
  226. package/dist/js/layouts/package.json +1 -1
  227. package/dist/js/next/components/package.json +1 -1
  228. package/dist/js/next/package.json +1 -1
  229. package/dist/js/package.json +1 -1
  230. package/dist/umd/react-core.min.js +1 -1
  231. package/package.json +2 -2
  232. package/src/components/MultipleFileUpload/MultipleFileUpload.tsx +3 -3
  233. package/src/components/MultipleFileUpload/examples/MultipleFileUpload.md +14 -0
  234. package/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx +2 -1
  235. package/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx +2 -1
  236. package/src/components/Slider/Slider.tsx +15 -7
  237. package/src/components/Slider/examples/Slider.md +26 -0
  238. package/src/components/Slider/examples/SliderActions.tsx +3 -2
  239. package/src/components/Slider/examples/SliderContinuous.tsx +8 -4
  240. package/src/components/Slider/examples/SliderDisabled.tsx +8 -3
  241. package/src/components/Slider/examples/SliderDiscrete.tsx +8 -8
  242. package/src/components/Slider/examples/SliderThumbValueInput.tsx +2 -1
  243. package/src/components/Slider/examples/SliderValueInput.tsx +8 -5
  244. package/src/demos/examples/MultipleFileUpload/MultipleFileUploadRejectedFile.tsx +13 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "5.0.0-alpha.85",
3
+ "version": "5.0.0-alpha.86",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -71,5 +71,5 @@
71
71
  "react": "^17 || ^18",
72
72
  "react-dom": "^17 || ^18"
73
73
  },
74
- "gitHead": "2161ca8ccb09609f0a72a68e70bd86cda585ea97"
74
+ "gitHead": "ba1717602667f1cba6fe191e752264c78327ae4b"
75
75
  }
@@ -18,7 +18,7 @@ export interface MultipleFileUploadProps extends Omit<React.HTMLProps<HTMLDivEle
18
18
  /** Flag setting the component to horizontal styling mode */
19
19
  isHorizontal?: boolean;
20
20
  /** When files are dropped or uploaded this callback will be called with all accepted files */
21
- onFileDrop?: (data: File[]) => void;
21
+ onFileDrop?: (event: DropEvent, data: File[]) => void;
22
22
  }
23
23
 
24
24
  export const MultipleFileUploadContext = React.createContext({
@@ -34,7 +34,7 @@ export const MultipleFileUpload: React.FunctionComponent<MultipleFileUploadProps
34
34
  ...props
35
35
  }: MultipleFileUploadProps) => {
36
36
  const onDropAccepted = (acceptedFiles: File[], event: DropEvent) => {
37
- onFileDrop(acceptedFiles);
37
+ onFileDrop(event, acceptedFiles);
38
38
  // allow users to set a custom drop accepted handler rather than using on data change
39
39
  dropzoneProps.onDropAccepted && dropzoneProps.onDropAccepted(acceptedFiles, event);
40
40
  };
@@ -47,7 +47,7 @@ export const MultipleFileUpload: React.FunctionComponent<MultipleFileUploadProps
47
47
 
48
48
  const rootProps = getRootProps({
49
49
  ...props,
50
- onClick: event => event.preventDefault() // Prevents clicking TextArea from opening file dialog
50
+ onClick: (event) => event.preventDefault() // Prevents clicking TextArea from opening file dialog
51
51
  });
52
52
 
53
53
  return (
@@ -50,4 +50,18 @@ The "Show as horizontal" checkbox can be used to easily toggle the `isHorizontal
50
50
  The "Demonstrate error reporting by forcing uploads to fail" checkbox shows how our `progressHelperText` prop can be used to provide status messages to users, such as when a file fails to upload. While this checkbox is checked it will cause any file uploaded to automatically fail the file reading process, and helper text will be dynamically rendered which informs the user of that error.
51
51
 
52
52
  ```ts file="./MultipleFileUploadBasic.tsx"
53
+
53
54
  ```
55
+
56
+ ## Types
57
+
58
+ Multiple file upload uses both the `DropEvent` and `DropzoneOptions` types from react-dropzone. The `DropEvent` type is a union comprised of the following types:
59
+
60
+ ```noLive
61
+ React.DragEvent<HTMLElement>
62
+ | React.ChangeEvent<HTMLInputElement>
63
+ | DragEvent
64
+ | Event
65
+ ```
66
+
67
+ `DropzoneOptions` is comprised of additional props with their own types. For more information on using `DropzoneOptions` visit [react-dropzone props and methods](https://react-dropzone.js.org/#src).
@@ -8,6 +8,7 @@ import {
8
8
  HelperText,
9
9
  HelperTextItem
10
10
  } from '@patternfly/react-core';
11
+ import { DropEvent } from 'react-dropzone';
11
12
  import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon';
12
13
 
13
14
  interface readFile {
@@ -68,7 +69,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
68
69
  };
69
70
 
70
71
  // callback that will be called by the react dropzone with the newly dropped file objects
71
- const handleFileDrop = (droppedFiles: File[]) => {
72
+ const handleFileDrop = (_event: DropEvent, droppedFiles: File[]) => {
72
73
  // identify what, if any, files are re-uploads of already uploaded files
73
74
  const currentFileNames = currentFiles.map((file) => file.name);
74
75
  const reUploads = droppedFiles.filter((droppedFile) => currentFileNames.includes(droppedFile.name));
@@ -8,6 +8,7 @@ import {
8
8
  OverflowMenuDropdownItem,
9
9
  MenuToggle,
10
10
  Slider,
11
+ SliderOnChangeEvent,
11
12
  Dropdown,
12
13
  DropdownList
13
14
  } from '@patternfly/react-core';
@@ -26,7 +27,7 @@ export const OverflowMenuBreakpointOnContainer: React.FunctionComponent = () =>
26
27
  setIsOpen(!isOpen);
27
28
  };
28
29
 
29
- const onChange = (value: number) => {
30
+ const onChange = (_event: SliderOnChangeEvent, value: number) => {
30
31
  setContainerWidth(value);
31
32
  };
32
33
 
@@ -19,6 +19,13 @@ export interface SliderStepObject {
19
19
  value: number;
20
20
  }
21
21
 
22
+ export type SliderOnChangeEvent =
23
+ | React.MouseEvent
24
+ | React.KeyboardEvent
25
+ | React.FormEvent<HTMLInputElement>
26
+ | React.TouchEvent
27
+ | React.FocusEvent<HTMLInputElement>;
28
+
22
29
  /** The main slider component. */
23
30
  export interface SliderProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {
24
31
  /** Flag indicating if the slider is discrete for custom steps. This will cause the slider
@@ -55,6 +62,7 @@ export interface SliderProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onCh
55
62
  min?: number;
56
63
  /** Value change callback. This is called when the slider value changes. */
57
64
  onChange?: (
65
+ event: SliderOnChangeEvent,
58
66
  value: number,
59
67
  inputValue?: number,
60
68
  setLocalInputValue?: React.Dispatch<React.SetStateAction<number>>
@@ -131,7 +139,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
131
139
  if (event.key === 'Enter') {
132
140
  event.preventDefault();
133
141
  if (onChange) {
134
- onChange(localValue, localInputValue, setLocalInputValue);
142
+ onChange(event, localValue, localInputValue, setLocalInputValue);
135
143
  }
136
144
  }
137
145
  };
@@ -144,9 +152,9 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
144
152
  thumbRef.current.focus();
145
153
  };
146
154
 
147
- const onBlur = () => {
155
+ const onBlur = (event: React.FocusEvent<HTMLInputElement>) => {
148
156
  if (onChange) {
149
- onChange(localValue, localInputValue, setLocalInputValue);
157
+ onChange(event, localValue, localInputValue, setLocalInputValue);
150
158
  }
151
159
  };
152
160
 
@@ -196,7 +204,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
196
204
  thumbRef.current.style.setProperty('--pf-c-slider--value', `${snapValue}%`);
197
205
  setValue(snapValue);
198
206
  if (onChange) {
199
- onChange(snapValue);
207
+ onChange(e, snapValue);
200
208
  }
201
209
  }
202
210
  };
@@ -260,9 +268,9 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
260
268
  // Call onchange callback
261
269
  if (onChange) {
262
270
  if (snapValue !== undefined) {
263
- onChange(snapValue);
271
+ onChange(e, snapValue);
264
272
  } else {
265
- onChange(newValue);
273
+ onChange(e, newValue);
266
274
  }
267
275
  }
268
276
  };
@@ -302,7 +310,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
302
310
  thumbRef.current.style.setProperty('--pf-c-slider--value', `${newValue}%`);
303
311
  setValue(newValue);
304
312
  if (onChange) {
305
- onChange(newValue);
313
+ onChange(e, newValue);
306
314
  }
307
315
  }
308
316
  };
@@ -16,29 +16,55 @@ import LockOpenIcon from '@patternfly/react-icons/dist/esm/icons/lock-open-icon'
16
16
  ### Discrete
17
17
 
18
18
  ```ts file="./SliderDiscrete.tsx"
19
+
19
20
  ```
20
21
 
21
22
  ### Continuous
22
23
 
23
24
  ```ts file="./SliderContinuous.tsx"
25
+
24
26
  ```
25
27
 
26
28
  ### Value input
27
29
 
28
30
  ```ts file="./SliderValueInput.tsx"
31
+
29
32
  ```
30
33
 
31
34
  ### Thumb value input
32
35
 
33
36
  ```ts file="./SliderThumbValueInput.tsx"
37
+
34
38
  ```
35
39
 
36
40
  ### Actions
37
41
 
38
42
  ```ts file="./SliderActions.tsx"
43
+
39
44
  ```
40
45
 
41
46
  ### Disabled
42
47
 
43
48
  ```ts file="./SliderDisabled.tsx"
49
+
50
+ ```
51
+
52
+ ## Types
53
+
54
+ ### SliderOnChangeEvent
55
+
56
+ The slider's `onChange` prop accepts an `event` parameter of the following types:
57
+
58
+ - `React.MouseEvent`
59
+ - `React.KeyboardEvent`
60
+ - `React.FormEvent<HTMLInputElement>`
61
+ - `React.TouchEvent`
62
+ - `React.FocusEvent<HTMLInputElement>`
63
+
64
+ The `SliderOnChangeEvent` type is a union of the above event types, and can be imported and used in your code like in the following code snippet:
65
+
66
+ ```noLive
67
+ import { Slider, SliderOnChangeEvent } from '@patternfly/react-core';
68
+
69
+ <Slider onChange={(event: SliderOnChangeEvent) => {}} />
44
70
  ```
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Slider, Button, Text, TextVariants } from '@patternfly/react-core';
2
+ import { Slider, SliderOnChangeEvent, Button, Text, TextVariants } from '@patternfly/react-core';
3
3
  import MinusIcon from '@patternfly/react-icons/dist/esm/icons/minus-icon';
4
4
  import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon';
5
5
  import LockIcon from '@patternfly/react-icons/dist/esm/icons/lock-icon';
@@ -11,11 +11,12 @@ export const SliderActions: React.FunctionComponent = () => {
11
11
  const [inputValue, setInputValue] = React.useState(50);
12
12
  const [isDisabled, setIsDisabled] = React.useState(false);
13
13
 
14
- const onChange1 = (value: number) => {
14
+ const onChange1 = (_event: SliderOnChangeEvent, value: number) => {
15
15
  setValue1(Math.floor(Number(value)));
16
16
  };
17
17
 
18
18
  const onChange2 = (
19
+ _event: SliderOnChangeEvent,
19
20
  value: number,
20
21
  inputValue: number,
21
22
  setLocalInputValue: React.Dispatch<React.SetStateAction<number>>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Checkbox, Slider, Text, TextVariants } from '@patternfly/react-core';
2
+ import { Checkbox, Slider, SliderOnChangeEvent, Text, TextVariants } from '@patternfly/react-core';
3
3
 
4
4
  export const SliderContinuous: React.FunctionComponent = () => {
5
5
  const [hasTooltipOverThumb, setHasTooltipOverThumb] = React.useState(false);
@@ -12,15 +12,19 @@ export const SliderContinuous: React.FunctionComponent = () => {
12
12
  id="thumb-has-tooltip"
13
13
  label="hasTooltipOverThumb"
14
14
  isChecked={hasTooltipOverThumb}
15
- onChange={(_event, checked) => setHasTooltipOverThumb(checked)}
15
+ onChange={(_event: React.FormEvent<HTMLInputElement>, checked: boolean) => setHasTooltipOverThumb(checked)}
16
16
  style={{ marginBottom: 20 }}
17
17
  />
18
18
  <Text component={TextVariants.h3}>Slider Value is: {value}</Text>
19
- <Slider hasTooltipOverThumb={hasTooltipOverThumb} value={value} onChange={setValue} />
19
+ <Slider
20
+ hasTooltipOverThumb={hasTooltipOverThumb}
21
+ value={value}
22
+ onChange={(_event: SliderOnChangeEvent, value: number) => setValue(value)}
23
+ />
20
24
  <br />
21
25
  <Text component={TextVariants.h3}>Slider value is: {valueCustom}</Text>
22
26
  <Slider
23
- onChange={setValueCustom}
27
+ onChange={(_event: SliderOnChangeEvent, value: number) => setValueCustom(value)}
24
28
  value={valueCustom}
25
29
  areCustomStepsContinuous
26
30
  hasTooltipOverThumb={hasTooltipOverThumb}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Slider, Text, TextVariants } from '@patternfly/react-core';
2
+ import { Slider, SliderOnChangeEvent, Text, TextVariants } from '@patternfly/react-core';
3
3
 
4
4
  export const SliderDisabled: React.FunctionComponent = () => {
5
5
  const [value, setValue] = React.useState(50);
@@ -16,14 +16,19 @@ export const SliderDisabled: React.FunctionComponent = () => {
16
16
  ];
17
17
 
18
18
  const displayValue = () => {
19
- const step = steps.find(step => step.value === value);
19
+ const step = steps.find((step) => step.value === value);
20
20
  return step ? step.label : 0;
21
21
  };
22
22
 
23
23
  return (
24
24
  <>
25
25
  <Text component={TextVariants.h3}>Slider value is: {displayValue()}</Text>
26
- <Slider isDisabled value={value} onChange={setValue} customSteps={steps} />
26
+ <Slider
27
+ isDisabled
28
+ value={value}
29
+ onChange={(_event: SliderOnChangeEvent, value: number) => setValue(value)}
30
+ customSteps={steps}
31
+ />
27
32
  </>
28
33
  );
29
34
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Slider, Text, TextVariants } from '@patternfly/react-core';
2
+ import { Slider, SliderOnChangeEvent, Text, TextVariants } from '@patternfly/react-core';
3
3
 
4
4
  export const SliderDiscrete: React.FunctionComponent = () => {
5
5
  const initialValues = {
@@ -53,7 +53,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
53
53
  <Text component={TextVariants.h3}>Slider value is: {numValue.value1}</Text>
54
54
  <Slider
55
55
  value={initialValues.value1}
56
- onChange={(value: number) => handleChange(value, 'value1')}
56
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value1')}
57
57
  customSteps={steps}
58
58
  />
59
59
  <br />
@@ -61,7 +61,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
61
61
  <Text component={TextVariants.small}>(min = 0, max = 200, step = 50) </Text>
62
62
  <Slider
63
63
  value={initialValues.value2}
64
- onChange={(value: number) => handleChange(value, 'value2')}
64
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value2')}
65
65
  max={200}
66
66
  step={50}
67
67
  showTicks
@@ -71,7 +71,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
71
71
  <Text component={TextVariants.small}>(min = -25, max = 75, step = 10, boundaries not shown) </Text>
72
72
  <Slider
73
73
  value={initialValues.value3}
74
- onChange={(value: number) => handleChange(value, 'value3')}
74
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value3')}
75
75
  min={-25}
76
76
  max={75}
77
77
  step={10}
@@ -83,7 +83,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
83
83
  <Text component={TextVariants.small}>(min = -25, max = 75, step = 10, boundaries shown) </Text>
84
84
  <Slider
85
85
  value={initialValues.value4}
86
- onChange={(value: number) => handleChange(value, 'value4')}
86
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value4')}
87
87
  min={-25}
88
88
  max={75}
89
89
  step={10}
@@ -94,7 +94,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
94
94
  <Text component={TextVariants.small}>(min = -25, max = 75, step = 10, boundaries shown, ticks not shown) </Text>
95
95
  <Slider
96
96
  value={initialValues.value5}
97
- onChange={(value: number) => handleChange(value, 'value5')}
97
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value5')}
98
98
  min={-25}
99
99
  max={75}
100
100
  step={10}
@@ -107,7 +107,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
107
107
  showTicks
108
108
  max={5}
109
109
  customSteps={stepsDiscreteWithMax}
110
- onChange={(value: number) => handleChange(value, 'value6')}
110
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value6')}
111
111
  />
112
112
  <br />
113
113
  <Text component={TextVariants.h3}>Slider value is: {Math.floor(numValue.value7)}</Text>
@@ -116,7 +116,7 @@ export const SliderDiscrete: React.FunctionComponent = () => {
116
116
  value={initialValues.value7}
117
117
  showTicks
118
118
  customSteps={stepsDiscreteNoLinearWithMaxMin}
119
- onChange={(value: number) => handleChange(value, 'value7')}
119
+ onChange={(_event: SliderOnChangeEvent, value: number) => handleChange(value, 'value7')}
120
120
  min={12}
121
121
  max={86}
122
122
  />
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
- import { Slider } from '@patternfly/react-core';
2
+ import { Slider, SliderOnChangeEvent } from '@patternfly/react-core';
3
3
 
4
4
  export const SliderThumbValueInput: React.FunctionComponent = () => {
5
5
  const [value, setValue] = React.useState(50);
6
6
  const [inputValue, setInputValue] = React.useState(50);
7
7
 
8
8
  const onChange = (
9
+ _event: SliderOnChangeEvent,
9
10
  value: number,
10
11
  inputValue: number,
11
12
  setLocalInputValue: React.Dispatch<React.SetStateAction<number>>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Slider } from '@patternfly/react-core';
2
+ import { Slider, SliderOnChangeEvent } from '@patternfly/react-core';
3
3
 
4
4
  export const SliderValueInput: React.FunctionComponent = () => {
5
5
  const [valueDiscrete, setValueDiscrete] = React.useState(62.5);
@@ -29,6 +29,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
29
29
  ];
30
30
 
31
31
  const onChangeDiscrete = (
32
+ _event: SliderOnChangeEvent,
32
33
  value: number,
33
34
  inputValue: number,
34
35
  setLocalInputValue: React.Dispatch<React.SetStateAction<number>>
@@ -37,7 +38,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
37
38
  let newInputValue;
38
39
 
39
40
  if (inputValue === undefined) {
40
- const step = stepsDiscrete.find(step => step.value === value);
41
+ const step = stepsDiscrete.find((step) => step.value === value);
41
42
  newInputValue = step ? step.label : 0;
42
43
  newInputValue = Number(newInputValue);
43
44
  newValue = value;
@@ -54,7 +55,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
54
55
  newInputValue = minValue;
55
56
  setLocalInputValue(minValue);
56
57
  } else {
57
- const stepIndex = stepsDiscrete.findIndex(step => Number(step.label) >= inputValue);
58
+ const stepIndex = stepsDiscrete.findIndex((step) => Number(step.label) >= inputValue);
58
59
  if (Number(stepsDiscrete[stepIndex].label) === inputValue) {
59
60
  newValue = stepsDiscrete[stepIndex].value;
60
61
  newInputValue = inputValue;
@@ -77,6 +78,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
77
78
  };
78
79
 
79
80
  const onChangePercent = (
81
+ _event: SliderOnChangeEvent,
80
82
  value: number,
81
83
  inputValue: number,
82
84
  setLocalInputValue: React.Dispatch<React.SetStateAction<number>>
@@ -85,7 +87,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
85
87
  let newInputValue;
86
88
 
87
89
  if (inputValue === undefined) {
88
- const step = stepsPercent.find(step => step.value === value);
90
+ const step = stepsPercent.find((step) => step.value === value);
89
91
  newInputValue = step ? step.label.slice(0, -1) : 0;
90
92
  newInputValue = Number(newInputValue);
91
93
  newValue = value;
@@ -101,7 +103,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
101
103
  newValue = minValue;
102
104
  setLocalInputValue(minValue);
103
105
  } else {
104
- const stepIndex = stepsPercent.findIndex(step => Number(step.label.slice(0, -1)) >= inputValue);
106
+ const stepIndex = stepsPercent.findIndex((step) => Number(step.label.slice(0, -1)) >= inputValue);
105
107
  if (Number(stepsPercent[stepIndex].label.slice(0, -1)) === inputValue) {
106
108
  newValue = stepsPercent[stepIndex].value;
107
109
  newInputValue = inputValue;
@@ -127,6 +129,7 @@ export const SliderValueInput: React.FunctionComponent = () => {
127
129
  };
128
130
 
129
131
  const onChangeContinuous = (
132
+ _event: SliderOnChangeEvent,
130
133
  value: number,
131
134
  inputValue: number,
132
135
  setLocalInputValue: React.Dispatch<React.SetStateAction<number>>
@@ -8,6 +8,7 @@ import {
8
8
  Modal,
9
9
  Checkbox
10
10
  } from '@patternfly/react-core';
11
+ import { DropEvent } from 'react-dropzone';
11
12
  import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon';
12
13
 
13
14
  interface readFile {
@@ -34,7 +35,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
34
35
  React.useEffect(() => {
35
36
  if (readFileData.length < currentFiles.length) {
36
37
  setStatusIcon('inProgress');
37
- } else if (readFileData.every(file => file.loadResult === 'success')) {
38
+ } else if (readFileData.every((file) => file.loadResult === 'success')) {
38
39
  setStatusIcon('success');
39
40
  } else {
40
41
  setStatusIcon('danger');
@@ -44,39 +45,39 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
44
45
  // remove files from both state arrays based on their name
45
46
  const removeFiles = (namesOfFilesToRemove: string[]) => {
46
47
  const newCurrentFiles = currentFiles.filter(
47
- currentFile => !namesOfFilesToRemove.some(fileName => fileName === currentFile.name)
48
+ (currentFile) => !namesOfFilesToRemove.some((fileName) => fileName === currentFile.name)
48
49
  );
49
50
 
50
51
  setCurrentFiles(newCurrentFiles);
51
52
 
52
53
  const newReadFiles = readFileData.filter(
53
- readFile => !namesOfFilesToRemove.some(fileName => fileName === readFile.fileName)
54
+ (readFile) => !namesOfFilesToRemove.some((fileName) => fileName === readFile.fileName)
54
55
  );
55
56
 
56
57
  setReadFileData(newReadFiles);
57
58
  };
58
59
 
59
60
  // callback that will be called by the react dropzone with the newly dropped file objects
60
- const handleFileDrop = (droppedFiles: File[]) => {
61
+ const handleFileDrop = (_event: DropEvent, droppedFiles: File[]) => {
61
62
  // identify what, if any, files are re-uploads of already uploaded files
62
- const currentFileNames = currentFiles.map(file => file.name);
63
- const reUploads = droppedFiles.filter(droppedFile => currentFileNames.includes(droppedFile.name));
63
+ const currentFileNames = currentFiles.map((file) => file.name);
64
+ const reUploads = droppedFiles.filter((droppedFile) => currentFileNames.includes(droppedFile.name));
64
65
 
65
66
  /** this promise chain is needed because if the file removal is done at the same time as the file adding react
66
67
  * won't realize that the status items for the re-uploaded files needs to be re-rendered */
67
68
  Promise.resolve()
68
- .then(() => removeFiles(reUploads.map(file => file.name)))
69
- .then(() => setCurrentFiles(prevFiles => [...prevFiles, ...droppedFiles]));
69
+ .then(() => removeFiles(reUploads.map((file) => file.name)))
70
+ .then(() => setCurrentFiles((prevFiles) => [...prevFiles, ...droppedFiles]));
70
71
  };
71
72
 
72
73
  // callback called by the status item when a file is successfully read with the built-in file reader
73
74
  const handleReadSuccess = (data: string, file: File) => {
74
- setReadFileData(prevReadFiles => [...prevReadFiles, { data, fileName: file.name, loadResult: 'success' }]);
75
+ setReadFileData((prevReadFiles) => [...prevReadFiles, { data, fileName: file.name, loadResult: 'success' }]);
75
76
  };
76
77
 
77
78
  // callback called by the status item when a file encounters an error while being read with the built-in file reader
78
79
  const handleReadFail = (error: DOMException, file: File) => {
79
- setReadFileData(prevReadFiles => [
80
+ setReadFileData((prevReadFiles) => [
80
81
  ...prevReadFiles,
81
82
  { loadError: error, fileName: file.name, loadResult: 'danger' }
82
83
  ]);
@@ -95,7 +96,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
95
96
  }
96
97
  };
97
98
 
98
- const successfullyReadFileCount = readFileData.filter(fileData => fileData.loadResult === 'success').length;
99
+ const successfullyReadFileCount = readFileData.filter((fileData) => fileData.loadResult === 'success').length;
99
100
 
100
101
  return (
101
102
  <>
@@ -123,7 +124,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
123
124
  statusToggleText={`${successfullyReadFileCount} of ${currentFiles.length} files uploaded`}
124
125
  statusToggleIcon={statusIcon}
125
126
  >
126
- {currentFiles.map(file => (
127
+ {currentFiles.map((file) => (
127
128
  <MultipleFileUploadStatusItem
128
129
  file={file}
129
130
  key={file.name}