@patternfly/react-core 5.0.0-alpha.85 → 5.0.0-alpha.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/esm/components/AboutModal/package.json +1 -1
- package/dist/esm/components/Accordion/package.json +1 -1
- package/dist/esm/components/ActionList/package.json +1 -1
- package/dist/esm/components/Alert/package.json +1 -1
- package/dist/esm/components/Avatar/package.json +1 -1
- package/dist/esm/components/BackToTop/package.json +1 -1
- package/dist/esm/components/Backdrop/package.json +1 -1
- package/dist/esm/components/BackgroundImage/package.json +1 -1
- package/dist/esm/components/Badge/package.json +1 -1
- package/dist/esm/components/Banner/package.json +1 -1
- package/dist/esm/components/Brand/package.json +1 -1
- package/dist/esm/components/Breadcrumb/package.json +1 -1
- package/dist/esm/components/Button/package.json +1 -1
- package/dist/esm/components/CalendarMonth/package.json +1 -1
- package/dist/esm/components/Card/package.json +1 -1
- package/dist/esm/components/Checkbox/package.json +1 -1
- package/dist/esm/components/Chip/package.json +1 -1
- package/dist/esm/components/ClipboardCopy/package.json +1 -1
- package/dist/esm/components/CodeBlock/package.json +1 -1
- package/dist/esm/components/DataList/package.json +1 -1
- package/dist/esm/components/DatePicker/package.json +1 -1
- package/dist/esm/components/DescriptionList/package.json +1 -1
- package/dist/esm/components/Divider/package.json +1 -1
- package/dist/esm/components/DragDrop/package.json +1 -1
- package/dist/esm/components/Drawer/package.json +1 -1
- package/dist/esm/components/Dropdown/package.json +1 -1
- package/dist/esm/components/DualListSelector/package.json +1 -1
- package/dist/esm/components/EmptyState/package.json +1 -1
- package/dist/esm/components/ExpandableSection/package.json +1 -1
- package/dist/esm/components/FileUpload/package.json +1 -1
- package/dist/esm/components/Form/package.json +1 -1
- package/dist/esm/components/FormSelect/package.json +1 -1
- package/dist/esm/components/HelperText/package.json +1 -1
- package/dist/esm/components/Hint/package.json +1 -1
- package/dist/esm/components/Icon/package.json +1 -1
- package/dist/esm/components/InputGroup/package.json +1 -1
- package/dist/esm/components/JumpLinks/package.json +1 -1
- package/dist/esm/components/Label/package.json +1 -1
- package/dist/esm/components/LabelGroup/package.json +1 -1
- package/dist/esm/components/List/package.json +1 -1
- package/dist/esm/components/LoginPage/package.json +1 -1
- package/dist/esm/components/Masthead/package.json +1 -1
- package/dist/esm/components/Menu/package.json +1 -1
- package/dist/esm/components/MenuToggle/package.json +1 -1
- package/dist/esm/components/Modal/package.json +1 -1
- package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.d.ts +2 -2
- package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.d.ts.map +1 -1
- package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.js +2 -2
- package/dist/esm/components/MultipleFileUpload/MultipleFileUpload.js.map +1 -1
- package/dist/esm/components/MultipleFileUpload/package.json +1 -1
- package/dist/esm/components/Nav/package.json +1 -1
- package/dist/esm/components/NotificationBadge/package.json +1 -1
- package/dist/esm/components/NotificationDrawer/package.json +1 -1
- package/dist/esm/components/NumberInput/package.json +1 -1
- package/dist/esm/components/OverflowMenu/package.json +1 -1
- package/dist/esm/components/Page/package.json +1 -1
- package/dist/esm/components/Pagination/package.json +1 -1
- package/dist/esm/components/Panel/package.json +1 -1
- package/dist/esm/components/Popover/package.json +1 -1
- package/dist/esm/components/Progress/package.json +1 -1
- package/dist/esm/components/ProgressStepper/package.json +1 -1
- package/dist/esm/components/Radio/package.json +1 -1
- package/dist/esm/components/SearchInput/package.json +1 -1
- package/dist/esm/components/Select/package.json +1 -1
- package/dist/esm/components/Sidebar/package.json +1 -1
- package/dist/esm/components/SimpleList/package.json +1 -1
- package/dist/esm/components/Skeleton/package.json +1 -1
- package/dist/esm/components/SkipToContent/package.json +1 -1
- package/dist/esm/components/Slider/Slider.d.ts +2 -1
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js +7 -7
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/esm/components/Slider/package.json +1 -1
- package/dist/esm/components/Spinner/package.json +1 -1
- package/dist/esm/components/Switch/package.json +1 -1
- package/dist/esm/components/Tabs/package.json +1 -1
- package/dist/esm/components/Text/package.json +1 -1
- package/dist/esm/components/TextArea/package.json +1 -1
- package/dist/esm/components/TextInput/package.json +1 -1
- package/dist/esm/components/TextInputGroup/package.json +1 -1
- package/dist/esm/components/Tile/package.json +1 -1
- package/dist/esm/components/TimePicker/package.json +1 -1
- package/dist/esm/components/Timestamp/package.json +1 -1
- package/dist/esm/components/Title/package.json +1 -1
- package/dist/esm/components/ToggleGroup/package.json +1 -1
- package/dist/esm/components/Toolbar/package.json +1 -1
- package/dist/esm/components/Tooltip/package.json +1 -1
- package/dist/esm/components/TreeView/package.json +1 -1
- package/dist/esm/components/Truncate/package.json +1 -1
- package/dist/esm/components/Wizard/hooks/package.json +1 -1
- package/dist/esm/components/Wizard/package.json +1 -1
- package/dist/esm/components/package.json +1 -1
- package/dist/esm/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/esm/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/esm/deprecated/components/Dropdown/package.json +1 -1
- package/dist/esm/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/esm/deprecated/components/PageHeader/package.json +1 -1
- package/dist/esm/deprecated/components/Select/package.json +1 -1
- package/dist/esm/deprecated/components/Wizard/package.json +1 -1
- package/dist/esm/deprecated/components/package.json +1 -1
- package/dist/esm/deprecated/package.json +1 -1
- package/dist/esm/helpers/Popper/thirdparty/popper-core/package.json +1 -1
- package/dist/esm/helpers/package.json +1 -1
- package/dist/esm/layouts/Bullseye/package.json +1 -1
- package/dist/esm/layouts/Flex/package.json +1 -1
- package/dist/esm/layouts/Gallery/package.json +1 -1
- package/dist/esm/layouts/Grid/package.json +1 -1
- package/dist/esm/layouts/Level/package.json +1 -1
- package/dist/esm/layouts/Split/package.json +1 -1
- package/dist/esm/layouts/Stack/package.json +1 -1
- package/dist/esm/layouts/package.json +1 -1
- package/dist/esm/next/components/package.json +1 -1
- package/dist/esm/next/package.json +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/js/components/AboutModal/package.json +1 -1
- package/dist/js/components/Accordion/package.json +1 -1
- package/dist/js/components/ActionList/package.json +1 -1
- package/dist/js/components/Alert/package.json +1 -1
- package/dist/js/components/Avatar/package.json +1 -1
- package/dist/js/components/BackToTop/package.json +1 -1
- package/dist/js/components/Backdrop/package.json +1 -1
- package/dist/js/components/BackgroundImage/package.json +1 -1
- package/dist/js/components/Badge/package.json +1 -1
- package/dist/js/components/Banner/package.json +1 -1
- package/dist/js/components/Brand/package.json +1 -1
- package/dist/js/components/Breadcrumb/package.json +1 -1
- package/dist/js/components/Button/package.json +1 -1
- package/dist/js/components/CalendarMonth/package.json +1 -1
- package/dist/js/components/Card/package.json +1 -1
- package/dist/js/components/Checkbox/package.json +1 -1
- package/dist/js/components/Chip/package.json +1 -1
- package/dist/js/components/ClipboardCopy/package.json +1 -1
- package/dist/js/components/CodeBlock/package.json +1 -1
- package/dist/js/components/DataList/package.json +1 -1
- package/dist/js/components/DatePicker/package.json +1 -1
- package/dist/js/components/DescriptionList/package.json +1 -1
- package/dist/js/components/Divider/package.json +1 -1
- package/dist/js/components/DragDrop/package.json +1 -1
- package/dist/js/components/Drawer/package.json +1 -1
- package/dist/js/components/Dropdown/package.json +1 -1
- package/dist/js/components/DualListSelector/package.json +1 -1
- package/dist/js/components/EmptyState/package.json +1 -1
- package/dist/js/components/ExpandableSection/package.json +1 -1
- package/dist/js/components/FileUpload/package.json +1 -1
- package/dist/js/components/Form/package.json +1 -1
- package/dist/js/components/FormSelect/package.json +1 -1
- package/dist/js/components/HelperText/package.json +1 -1
- package/dist/js/components/Hint/package.json +1 -1
- package/dist/js/components/Icon/package.json +1 -1
- package/dist/js/components/InputGroup/package.json +1 -1
- package/dist/js/components/JumpLinks/package.json +1 -1
- package/dist/js/components/Label/package.json +1 -1
- package/dist/js/components/LabelGroup/package.json +1 -1
- package/dist/js/components/List/package.json +1 -1
- package/dist/js/components/LoginPage/package.json +1 -1
- package/dist/js/components/Masthead/package.json +1 -1
- package/dist/js/components/Menu/package.json +1 -1
- package/dist/js/components/MenuToggle/package.json +1 -1
- package/dist/js/components/Modal/package.json +1 -1
- package/dist/js/components/MultipleFileUpload/MultipleFileUpload.d.ts +2 -2
- package/dist/js/components/MultipleFileUpload/MultipleFileUpload.d.ts.map +1 -1
- package/dist/js/components/MultipleFileUpload/MultipleFileUpload.js +2 -2
- package/dist/js/components/MultipleFileUpload/MultipleFileUpload.js.map +1 -1
- package/dist/js/components/MultipleFileUpload/package.json +1 -1
- package/dist/js/components/Nav/package.json +1 -1
- package/dist/js/components/NotificationBadge/package.json +1 -1
- package/dist/js/components/NotificationDrawer/package.json +1 -1
- package/dist/js/components/NumberInput/package.json +1 -1
- package/dist/js/components/OverflowMenu/package.json +1 -1
- package/dist/js/components/Page/package.json +1 -1
- package/dist/js/components/Pagination/package.json +1 -1
- package/dist/js/components/Panel/package.json +1 -1
- package/dist/js/components/Popover/package.json +1 -1
- package/dist/js/components/Progress/package.json +1 -1
- package/dist/js/components/ProgressStepper/package.json +1 -1
- package/dist/js/components/Radio/package.json +1 -1
- package/dist/js/components/SearchInput/package.json +1 -1
- package/dist/js/components/Select/package.json +1 -1
- package/dist/js/components/Sidebar/package.json +1 -1
- package/dist/js/components/SimpleList/package.json +1 -1
- package/dist/js/components/Skeleton/package.json +1 -1
- package/dist/js/components/SkipToContent/package.json +1 -1
- package/dist/js/components/Slider/Slider.d.ts +2 -1
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js +7 -7
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/Slider/package.json +1 -1
- package/dist/js/components/Spinner/package.json +1 -1
- package/dist/js/components/Switch/package.json +1 -1
- package/dist/js/components/Tabs/package.json +1 -1
- package/dist/js/components/Text/package.json +1 -1
- package/dist/js/components/TextArea/package.json +1 -1
- package/dist/js/components/TextInput/package.json +1 -1
- package/dist/js/components/TextInputGroup/package.json +1 -1
- package/dist/js/components/Tile/package.json +1 -1
- package/dist/js/components/TimePicker/package.json +1 -1
- package/dist/js/components/Timestamp/package.json +1 -1
- package/dist/js/components/Title/package.json +1 -1
- package/dist/js/components/ToggleGroup/package.json +1 -1
- package/dist/js/components/Toolbar/package.json +1 -1
- package/dist/js/components/Tooltip/package.json +1 -1
- package/dist/js/components/TreeView/package.json +1 -1
- package/dist/js/components/Truncate/package.json +1 -1
- package/dist/js/components/Wizard/hooks/package.json +1 -1
- package/dist/js/components/Wizard/package.json +1 -1
- package/dist/js/components/package.json +1 -1
- package/dist/js/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/js/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/js/deprecated/components/Dropdown/package.json +1 -1
- package/dist/js/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/js/deprecated/components/PageHeader/package.json +1 -1
- package/dist/js/deprecated/components/Select/package.json +1 -1
- package/dist/js/deprecated/components/Wizard/package.json +1 -1
- package/dist/js/deprecated/components/package.json +1 -1
- package/dist/js/deprecated/package.json +1 -1
- package/dist/js/helpers/Popper/thirdparty/popper-core/package.json +1 -1
- package/dist/js/helpers/package.json +1 -1
- package/dist/js/layouts/Bullseye/package.json +1 -1
- package/dist/js/layouts/Flex/package.json +1 -1
- package/dist/js/layouts/Gallery/package.json +1 -1
- package/dist/js/layouts/Grid/package.json +1 -1
- package/dist/js/layouts/Level/package.json +1 -1
- package/dist/js/layouts/Split/package.json +1 -1
- package/dist/js/layouts/Stack/package.json +1 -1
- package/dist/js/layouts/package.json +1 -1
- package/dist/js/next/components/package.json +1 -1
- package/dist/js/next/package.json +1 -1
- package/dist/js/package.json +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/MultipleFileUpload/MultipleFileUpload.tsx +3 -3
- package/src/components/MultipleFileUpload/examples/MultipleFileUpload.md +14 -0
- package/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx +2 -1
- package/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainer.tsx +2 -1
- package/src/components/Slider/Slider.tsx +15 -7
- package/src/components/Slider/examples/Slider.md +26 -0
- package/src/components/Slider/examples/SliderActions.tsx +3 -2
- package/src/components/Slider/examples/SliderContinuous.tsx +8 -4
- package/src/components/Slider/examples/SliderDisabled.tsx +8 -3
- package/src/components/Slider/examples/SliderDiscrete.tsx +8 -8
- package/src/components/Slider/examples/SliderThumbValueInput.tsx +2 -1
- package/src/components/Slider/examples/SliderValueInput.tsx +8 -5
- package/src/components/Tabs/examples/Tabs.md +120 -44
- package/src/components/Toolbar/examples/Toolbar.md +41 -19
- package/src/components/Toolbar/examples/ToolbarItems.tsx +1 -1
- 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.
|
|
3
|
+
"version": "5.0.0-alpha.87",
|
|
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": "
|
|
74
|
+
"gitHead": "696a96df36af68e169c0f4900b467e624114b9b2"
|
|
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
|
|
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
|
|
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
|
|
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>>
|