@patternfly/react-core 4.243.0 → 4.244.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/esm/components/Alert/Alert.d.ts +41 -34
- package/dist/esm/components/Alert/Alert.d.ts.map +1 -1
- package/dist/esm/components/Alert/Alert.js.map +1 -1
- package/dist/esm/components/Alert/AlertActionCloseButton.d.ts +8 -5
- package/dist/esm/components/Alert/AlertActionCloseButton.d.ts.map +1 -1
- package/dist/esm/components/Alert/AlertActionCloseButton.js.map +1 -1
- package/dist/esm/components/Alert/AlertActionLink.d.ts +5 -2
- package/dist/esm/components/Alert/AlertActionLink.d.ts.map +1 -1
- package/dist/esm/components/Alert/AlertActionLink.js.map +1 -1
- package/dist/esm/components/Alert/AlertIcon.d.ts +4 -4
- package/dist/esm/components/Alert/AlertIcon.d.ts.map +1 -1
- package/dist/esm/components/Alert/AlertToggleExpandButton.d.ts +5 -5
- package/dist/esm/components/Alert/AlertToggleExpandButton.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts +34 -28
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +1 -0
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.d.ts +43 -36
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts +34 -24
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts +10 -5
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
- package/dist/esm/components/FileUpload/FileUpload.d.ts +53 -47
- package/dist/esm/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.d.ts +51 -46
- package/dist/esm/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/esm/components/Modal/Modal.d.ts +57 -48
- package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Modal/ModalBox.d.ts +12 -12
- package/dist/esm/components/Modal/ModalBox.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxBody.d.ts +2 -2
- package/dist/esm/components/Modal/ModalBoxBody.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts +2 -2
- package/dist/esm/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxDescription.d.ts +3 -3
- package/dist/esm/components/Modal/ModalBoxDescription.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxFooter.d.ts +2 -2
- package/dist/esm/components/Modal/ModalBoxFooter.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxHeader.d.ts +3 -3
- package/dist/esm/components/Modal/ModalBoxHeader.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxTitle.d.ts +8 -9
- package/dist/esm/components/Modal/ModalBoxTitle.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalBoxTitle.js.map +1 -1
- package/dist/esm/components/Modal/ModalContent.d.ts +56 -48
- package/dist/esm/components/Modal/ModalContent.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalContent.js.map +1 -1
- package/dist/esm/components/NotificationBadge/NotificationBadge.d.ts +17 -13
- package/dist/esm/components/NotificationBadge/NotificationBadge.d.ts.map +1 -1
- package/dist/esm/components/NotificationBadge/NotificationBadge.js +3 -3
- package/dist/esm/components/NotificationBadge/NotificationBadge.js.map +1 -1
- package/dist/esm/components/Pagination/Navigation.d.ts +33 -33
- package/dist/esm/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/esm/components/Pagination/OptionsToggle.d.ts +27 -26
- package/dist/esm/components/Pagination/OptionsToggle.d.ts.map +1 -1
- package/dist/esm/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +76 -65
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +1 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts +22 -18
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/esm/components/Pagination/ToggleTemplate.d.ts +3 -0
- package/dist/esm/components/Pagination/ToggleTemplate.d.ts.map +1 -1
- package/dist/esm/components/Pagination/ToggleTemplate.js.map +1 -1
- package/dist/esm/components/Popover/Popover.d.ts +88 -73
- package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts +27 -26
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts +71 -60
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Slider/Slider.d.ts +45 -39
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/esm/components/Slider/SliderStep.d.ts +10 -10
- package/dist/esm/components/Slider/SliderStep.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeView.d.ts +65 -53
- package/dist/esm/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeView.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewList.d.ts +4 -4
- package/dist/esm/components/TreeView/TreeViewList.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.d.ts +46 -39
- package/dist/esm/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewRoot.d.ts +4 -4
- package/dist/esm/components/TreeView/TreeViewRoot.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewSearch.d.ts +11 -8
- package/dist/esm/components/TreeView/TreeViewSearch.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewSearch.js.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js +8 -8
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/components/Alert/Alert.d.ts +41 -34
- package/dist/js/components/Alert/Alert.d.ts.map +1 -1
- package/dist/js/components/Alert/Alert.js.map +1 -1
- package/dist/js/components/Alert/AlertActionCloseButton.d.ts +8 -5
- package/dist/js/components/Alert/AlertActionCloseButton.d.ts.map +1 -1
- package/dist/js/components/Alert/AlertActionCloseButton.js.map +1 -1
- package/dist/js/components/Alert/AlertActionLink.d.ts +5 -2
- package/dist/js/components/Alert/AlertActionLink.d.ts.map +1 -1
- package/dist/js/components/Alert/AlertActionLink.js.map +1 -1
- package/dist/js/components/Alert/AlertIcon.d.ts +4 -4
- package/dist/js/components/Alert/AlertIcon.d.ts.map +1 -1
- package/dist/js/components/Alert/AlertToggleExpandButton.d.ts +5 -5
- package/dist/js/components/Alert/AlertToggleExpandButton.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts +34 -28
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +1 -0
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.d.ts +43 -36
- package/dist/js/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts +34 -24
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts +10 -5
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.d.ts +53 -47
- package/dist/js/components/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.d.ts +51 -46
- package/dist/js/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/js/components/Modal/Modal.d.ts +57 -48
- package/dist/js/components/Modal/Modal.d.ts.map +1 -1
- package/dist/js/components/Modal/Modal.js.map +1 -1
- package/dist/js/components/Modal/ModalBox.d.ts +12 -12
- package/dist/js/components/Modal/ModalBox.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxBody.d.ts +2 -2
- package/dist/js/components/Modal/ModalBoxBody.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts +2 -2
- package/dist/js/components/Modal/ModalBoxCloseButton.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxDescription.d.ts +3 -3
- package/dist/js/components/Modal/ModalBoxDescription.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxFooter.d.ts +2 -2
- package/dist/js/components/Modal/ModalBoxFooter.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxHeader.d.ts +3 -3
- package/dist/js/components/Modal/ModalBoxHeader.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxTitle.d.ts +8 -9
- package/dist/js/components/Modal/ModalBoxTitle.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalBoxTitle.js.map +1 -1
- package/dist/js/components/Modal/ModalContent.d.ts +56 -48
- package/dist/js/components/Modal/ModalContent.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalContent.js.map +1 -1
- package/dist/js/components/NotificationBadge/NotificationBadge.d.ts +17 -13
- package/dist/js/components/NotificationBadge/NotificationBadge.d.ts.map +1 -1
- package/dist/js/components/NotificationBadge/NotificationBadge.js +3 -3
- package/dist/js/components/NotificationBadge/NotificationBadge.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.d.ts +33 -33
- package/dist/js/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/js/components/Pagination/OptionsToggle.d.ts +27 -26
- package/dist/js/components/Pagination/OptionsToggle.d.ts.map +1 -1
- package/dist/js/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +76 -65
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +1 -1
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts +22 -18
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/js/components/Pagination/ToggleTemplate.d.ts +3 -0
- package/dist/js/components/Pagination/ToggleTemplate.d.ts.map +1 -1
- package/dist/js/components/Pagination/ToggleTemplate.js.map +1 -1
- package/dist/js/components/Popover/Popover.d.ts +88 -73
- package/dist/js/components/Popover/Popover.d.ts.map +1 -1
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts +27 -26
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts +71 -60
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/Slider/Slider.d.ts +45 -39
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/Slider/SliderStep.d.ts +10 -10
- package/dist/js/components/Slider/SliderStep.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeView.d.ts +65 -53
- package/dist/js/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeView.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewList.d.ts +4 -4
- package/dist/js/components/TreeView/TreeViewList.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.d.ts +46 -39
- package/dist/js/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewRoot.d.ts +4 -4
- package/dist/js/components/TreeView/TreeViewRoot.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewSearch.d.ts +11 -8
- package/dist/js/components/TreeView/TreeViewSearch.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewSearch.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.js +8 -8
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.min.css +3498 -3498
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +2 -2
- package/src/components/Alert/Alert.tsx +42 -34
- package/src/components/Alert/AlertActionCloseButton.tsx +9 -5
- package/src/components/Alert/AlertActionLink.tsx +6 -2
- package/src/components/Alert/AlertIcon.tsx +4 -4
- package/src/components/Alert/AlertToggleExpandButton.tsx +5 -5
- package/src/components/Badge/__tests__/Badge.test.tsx +45 -8
- package/src/components/Badge/__tests__/__snapshots__/Badge.test.tsx.snap +2 -12
- package/src/components/CalendarMonth/CalendarMonth.tsx +36 -28
- package/src/components/DatePicker/DatePicker.tsx +45 -36
- package/src/components/ExpandableSection/ExpandableSection.tsx +35 -24
- package/src/components/ExpandableSection/ExpandableSectionToggle.tsx +11 -5
- package/src/components/FileUpload/FileUpload.tsx +56 -49
- package/src/components/FileUpload/FileUploadField.tsx +56 -50
- package/src/components/Modal/Modal.tsx +57 -48
- package/src/components/Modal/ModalBox.tsx +12 -12
- package/src/components/Modal/ModalBoxBody.tsx +2 -2
- package/src/components/Modal/ModalBoxCloseButton.tsx +2 -2
- package/src/components/Modal/ModalBoxDescription.tsx +3 -3
- package/src/components/Modal/ModalBoxFooter.tsx +2 -2
- package/src/components/Modal/ModalBoxHeader.tsx +3 -3
- package/src/components/Modal/ModalBoxTitle.tsx +8 -9
- package/src/components/Modal/ModalContent.tsx +56 -48
- package/src/components/Modal/examples/Modal.md +1 -3
- package/src/components/NotificationBadge/NotificationBadge.tsx +22 -15
- package/src/components/NotificationBadge/__tests__/NotificationBadge.test.tsx +25 -1
- package/src/components/NotificationBadge/__tests__/__snapshots__/NotificationBadge.test.tsx.snap +5 -0
- package/src/components/NotificationBadge/examples/NotificationBadge.md +16 -3
- package/src/components/NotificationBadge/examples/NotificationBadgeBasic.tsx +26 -13
- package/src/components/NotificationBadge/examples/NotificationBadgeWithCount.tsx +28 -18
- package/src/components/NumberInput/examples/NumberInput.md +9 -448
- package/src/components/NumberInput/examples/NumberInputCustomStep.tsx +29 -0
- package/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx +52 -0
- package/src/components/NumberInput/examples/NumberInputDefault.tsx +34 -0
- package/src/components/NumberInput/examples/NumberInputDisabled.tsx +40 -0
- package/src/components/NumberInput/examples/NumberInputUnit.tsx +57 -0
- package/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx +55 -0
- package/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx +80 -0
- package/src/components/NumberInput/examples/{WithStatus.tsx → NumberInputWithStatus.tsx} +4 -3
- package/src/components/Pagination/Navigation.tsx +33 -33
- package/src/components/Pagination/OptionsToggle.tsx +27 -26
- package/src/components/Pagination/Pagination.tsx +79 -65
- package/src/components/Pagination/PaginationOptionsMenu.tsx +22 -18
- package/src/components/Pagination/ToggleTemplate.tsx +4 -0
- package/src/components/Popover/Popover.tsx +89 -73
- package/src/components/SearchInput/AdvancedSearchMenu.tsx +29 -28
- package/src/components/SearchInput/SearchInput.tsx +76 -62
- package/src/components/Slider/Slider.tsx +47 -41
- package/src/components/Slider/SliderStep.tsx +10 -10
- package/src/components/TreeView/TreeView.tsx +67 -53
- package/src/components/TreeView/TreeViewList.tsx +4 -4
- package/src/components/TreeView/TreeViewListItem.tsx +46 -39
- package/src/components/TreeView/TreeViewRoot.tsx +4 -4
- package/src/components/TreeView/TreeViewSearch.tsx +12 -8
- package/src/demos/Masthead.md +9 -193
- package/src/demos/NotificationDrawer/NotificationDrawer.md +2 -0
- package/src/demos/examples/Masthead/MastheadWithUtilitiesAndUserDropdownMenu.tsx +305 -0
- package/src/helpers/Popper/Popper.tsx +8 -8
|
@@ -9,479 +9,40 @@ propComponents: ['NumberInput']
|
|
|
9
9
|
|
|
10
10
|
### Default
|
|
11
11
|
|
|
12
|
-
```
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
15
|
-
|
|
16
|
-
class BasicNumberInput extends React.Component {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this.state = {
|
|
20
|
-
value: 90
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
this.onMinus = () => {
|
|
24
|
-
this.setState({
|
|
25
|
-
value: this.state.value - 1
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
this.onChange = event => {
|
|
30
|
-
this.setState({
|
|
31
|
-
value: Number(event.target.value)
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
this.onPlus = () => {
|
|
36
|
-
this.setState({
|
|
37
|
-
value: this.state.value + 1
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
render() {
|
|
43
|
-
const { value } = this.state;
|
|
44
|
-
return (
|
|
45
|
-
<NumberInput
|
|
46
|
-
value={value}
|
|
47
|
-
onMinus={this.onMinus}
|
|
48
|
-
onChange={this.onChange}
|
|
49
|
-
onPlus={this.onPlus}
|
|
50
|
-
inputName="input"
|
|
51
|
-
inputAriaLabel="number input"
|
|
52
|
-
minusBtnAriaLabel="minus"
|
|
53
|
-
plusBtnAriaLabel="plus"
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
12
|
+
```ts file="./NumberInputDefault.tsx"
|
|
58
13
|
```
|
|
59
14
|
|
|
60
15
|
### With unit
|
|
61
16
|
|
|
62
|
-
```
|
|
63
|
-
import React from 'react';
|
|
64
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
65
|
-
|
|
66
|
-
class UnitNumberInput extends React.Component {
|
|
67
|
-
constructor(props) {
|
|
68
|
-
super(props);
|
|
69
|
-
this.state = {
|
|
70
|
-
value1: 90,
|
|
71
|
-
value2: (1.0).toFixed(2)
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
this.onMinus1 = () => {
|
|
75
|
-
this.setState({
|
|
76
|
-
value1: this.state.value1 - 1
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
this.onChange1 = event => {
|
|
81
|
-
this.setState({
|
|
82
|
-
value1: Number(event.target.value)
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
this.onPlus1 = () => {
|
|
87
|
-
this.setState({
|
|
88
|
-
value1: this.state.value1 + 1
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
this.onMinus2 = () => {
|
|
93
|
-
this.setState({
|
|
94
|
-
value2: (Number(this.state.value2) - 0.01).toFixed(2)
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
this.onChange2 = event => {
|
|
99
|
-
this.setState({
|
|
100
|
-
value2: event.target.value
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
this.onPlus2 = () => {
|
|
105
|
-
this.setState({
|
|
106
|
-
value2: (Number(this.state.value2) + 0.01).toFixed(2)
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
render() {
|
|
112
|
-
const { value1, value2 } = this.state;
|
|
113
|
-
return (
|
|
114
|
-
<React.Fragment>
|
|
115
|
-
<NumberInput
|
|
116
|
-
value={value1}
|
|
117
|
-
onMinus={this.onMinus1}
|
|
118
|
-
onChange={this.onChange1}
|
|
119
|
-
onPlus={this.onPlus1}
|
|
120
|
-
inputName="input 1"
|
|
121
|
-
inputAriaLabel="number input 1"
|
|
122
|
-
minusBtnAriaLabel="minus 1"
|
|
123
|
-
plusBtnAriaLabel="plus 1"
|
|
124
|
-
unit="%"
|
|
125
|
-
/>
|
|
126
|
-
<br />
|
|
127
|
-
<br />
|
|
128
|
-
<NumberInput
|
|
129
|
-
value={value2}
|
|
130
|
-
onMinus={this.onMinus2}
|
|
131
|
-
onChange={this.onChange2}
|
|
132
|
-
onPlus={this.onPlus2}
|
|
133
|
-
inputName="input 2"
|
|
134
|
-
inputAriaLabel="number input 2"
|
|
135
|
-
minusBtnAriaLabel="minus 0.01"
|
|
136
|
-
plusBtnAriaLabel="plus 0.01"
|
|
137
|
-
unit="$"
|
|
138
|
-
unitPosition="before"
|
|
139
|
-
/>
|
|
140
|
-
</React.Fragment>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
17
|
+
```ts file="./NumberInputUnit.tsx"
|
|
144
18
|
```
|
|
145
19
|
|
|
146
20
|
### With unit and thresholds
|
|
147
21
|
|
|
148
|
-
```
|
|
149
|
-
import React from 'react';
|
|
150
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
151
|
-
|
|
152
|
-
class UnitThresholdNumberInput extends React.Component {
|
|
153
|
-
constructor(props) {
|
|
154
|
-
super(props);
|
|
155
|
-
this.state = {
|
|
156
|
-
value: 0
|
|
157
|
-
};
|
|
158
|
-
this.minValue = 0;
|
|
159
|
-
this.maxValue = 10;
|
|
160
|
-
|
|
161
|
-
this.normalizeBetween = (value, min, max) => {
|
|
162
|
-
if (min !== undefined && max !== undefined) {
|
|
163
|
-
return Math.max(Math.min(value, max), min);
|
|
164
|
-
} else if (value <= min) {
|
|
165
|
-
return min;
|
|
166
|
-
} else if (value >= max) {
|
|
167
|
-
return max;
|
|
168
|
-
}
|
|
169
|
-
return value;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
this.onMinus = () => {
|
|
173
|
-
this.setState({
|
|
174
|
-
value: this.normalizeBetween(this.state.value - 1, this.minValue, this.maxValue)
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
this.onChange = event => {
|
|
179
|
-
const newValue = isNaN(event.target.value) ? 0 : Number(event.target.value);
|
|
180
|
-
this.setState({
|
|
181
|
-
value: newValue > this.maxValue ? this.maxValue : newValue < this.minValue ? this.minValue : newValue
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
this.onPlus = () => {
|
|
186
|
-
this.setState({
|
|
187
|
-
value: this.normalizeBetween(this.state.value + 1, this.minValue, this.maxValue)
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
render() {
|
|
193
|
-
const { value } = this.state;
|
|
194
|
-
|
|
195
|
-
return (
|
|
196
|
-
<React.Fragment>
|
|
197
|
-
With a minimum value of 0 and maximum value of 10
|
|
198
|
-
<br />
|
|
199
|
-
<NumberInput
|
|
200
|
-
value={value}
|
|
201
|
-
min={this.minValue}
|
|
202
|
-
max={this.maxValue}
|
|
203
|
-
onMinus={this.onMinus}
|
|
204
|
-
onChange={this.onChange}
|
|
205
|
-
onPlus={this.onPlus}
|
|
206
|
-
inputName="input"
|
|
207
|
-
inputAriaLabel="number input"
|
|
208
|
-
minusBtnAriaLabel="minus"
|
|
209
|
-
plusBtnAriaLabel="plus"
|
|
210
|
-
unit="%"
|
|
211
|
-
/>
|
|
212
|
-
</React.Fragment>
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
22
|
+
```ts file="./NumberInputUnitThreshold.tsx"
|
|
216
23
|
```
|
|
217
24
|
|
|
218
25
|
### Disabled
|
|
219
26
|
|
|
220
|
-
```
|
|
221
|
-
import React from 'react';
|
|
222
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
223
|
-
|
|
224
|
-
class DisabledNumberInput extends React.Component {
|
|
225
|
-
constructor(props) {
|
|
226
|
-
super(props);
|
|
227
|
-
this.state = {
|
|
228
|
-
value: 100
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
this.onMinus = () => {
|
|
232
|
-
this.setState({
|
|
233
|
-
value: this.state.value - 1
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
this.onChange = event => {
|
|
238
|
-
this.setState({
|
|
239
|
-
value: Number(event.target.value)
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
this.onPlus = () => {
|
|
244
|
-
this.setState({
|
|
245
|
-
value: this.state.value + 1
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
render() {
|
|
251
|
-
const { value } = this.state;
|
|
252
|
-
const minValue = 0;
|
|
253
|
-
const maxValue = 100;
|
|
254
|
-
|
|
255
|
-
return (
|
|
256
|
-
<NumberInput
|
|
257
|
-
value={value}
|
|
258
|
-
min={minValue}
|
|
259
|
-
max={maxValue}
|
|
260
|
-
onMinus={this.onMinus}
|
|
261
|
-
onChange={this.onChange}
|
|
262
|
-
onPlus={this.onPlus}
|
|
263
|
-
inputName="input"
|
|
264
|
-
inputAriaLabel="number input"
|
|
265
|
-
minusBtnAriaLabel="minus"
|
|
266
|
-
plusBtnAriaLabel="plus"
|
|
267
|
-
unit="%"
|
|
268
|
-
isDisabled
|
|
269
|
-
/>
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
27
|
+
```ts file="./NumberInputDisabled.tsx"
|
|
274
28
|
```
|
|
29
|
+
|
|
275
30
|
### With status
|
|
276
31
|
|
|
277
|
-
```ts file="./
|
|
32
|
+
```ts file="./NumberInputWithStatus.tsx"
|
|
278
33
|
```
|
|
279
34
|
|
|
280
35
|
### Varying sizes
|
|
281
36
|
|
|
282
|
-
```
|
|
283
|
-
import React from 'react';
|
|
284
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
285
|
-
|
|
286
|
-
class NumberInputSizes extends React.Component {
|
|
287
|
-
constructor(props) {
|
|
288
|
-
super(props);
|
|
289
|
-
this.state = {
|
|
290
|
-
input1Value: 1,
|
|
291
|
-
input2Value: 1234567890,
|
|
292
|
-
input3Value: 5,
|
|
293
|
-
input4Value: 12345
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
this.onChange = event => {
|
|
297
|
-
this.setState({
|
|
298
|
-
[`${event.target.name}Value`]: Number(event.target.value)
|
|
299
|
-
});
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
this.onMinus = (e, inputName) => {
|
|
303
|
-
this.setState({
|
|
304
|
-
[`${inputName}Value`]: this.state[`${inputName}Value`] - 1
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
this.onPlus = (e, inputName) => {
|
|
309
|
-
this.setState({
|
|
310
|
-
[`${inputName}Value`]: this.state[`${inputName}Value`] + 1
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
render() {
|
|
316
|
-
const { input1Value, input2Value, input3Value, input4Value } = this.state;
|
|
317
|
-
|
|
318
|
-
return (
|
|
319
|
-
<React.Fragment>
|
|
320
|
-
<NumberInput
|
|
321
|
-
value={input1Value}
|
|
322
|
-
onMinus={this.onMinus}
|
|
323
|
-
onChange={this.onChange}
|
|
324
|
-
onPlus={this.onPlus}
|
|
325
|
-
inputName="input1"
|
|
326
|
-
inputAriaLabel="number input 1"
|
|
327
|
-
minusBtnAriaLabel="input 2 minus"
|
|
328
|
-
plusBtnAriaLabel="input 2 plus"
|
|
329
|
-
widthChars={1}
|
|
330
|
-
/>
|
|
331
|
-
<br />
|
|
332
|
-
<br />
|
|
333
|
-
<NumberInput
|
|
334
|
-
value={input2Value}
|
|
335
|
-
onMinus={this.onMinus}
|
|
336
|
-
onChange={this.onChange}
|
|
337
|
-
onPlus={this.onPlus}
|
|
338
|
-
inputName="input2"
|
|
339
|
-
inputAriaLabel="number input 2"
|
|
340
|
-
minusBtnAriaLabel="input 2 minus"
|
|
341
|
-
plusBtnAriaLabel="input 2 plus"
|
|
342
|
-
widthChars={10}
|
|
343
|
-
/>
|
|
344
|
-
<br />
|
|
345
|
-
<br />
|
|
346
|
-
<NumberInput
|
|
347
|
-
value={input3Value}
|
|
348
|
-
onMinus={this.onMinus}
|
|
349
|
-
onChange={this.onChange}
|
|
350
|
-
onPlus={this.onPlus}
|
|
351
|
-
inputName="input3"
|
|
352
|
-
inputAriaLabel="number input 3"
|
|
353
|
-
minusBtnAriaLabel="input 3 minus"
|
|
354
|
-
plusBtnAriaLabel="input 3 plus"
|
|
355
|
-
widthChars={5}
|
|
356
|
-
/>
|
|
357
|
-
<br />
|
|
358
|
-
<br />
|
|
359
|
-
<NumberInput
|
|
360
|
-
value={input4Value}
|
|
361
|
-
onMinus={this.onMinus}
|
|
362
|
-
onChange={this.onChange}
|
|
363
|
-
onPlus={this.onPlus}
|
|
364
|
-
inputName="input4"
|
|
365
|
-
inputAriaLabel="number input 4"
|
|
366
|
-
minusBtnAriaLabel="input 4 minus"
|
|
367
|
-
plusBtnAriaLabel="input 4 plus"
|
|
368
|
-
widthChars={5}
|
|
369
|
-
/>
|
|
370
|
-
</React.Fragment>
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
37
|
+
```ts file="./NumberInputVaryingSizes.tsx"
|
|
374
38
|
```
|
|
375
39
|
|
|
376
40
|
### Custom increment/decrement
|
|
377
41
|
|
|
378
|
-
```
|
|
379
|
-
import React from 'react';
|
|
380
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
381
|
-
|
|
382
|
-
class CustomStepNumberInput extends React.Component {
|
|
383
|
-
constructor(props) {
|
|
384
|
-
super(props);
|
|
385
|
-
this.state = {
|
|
386
|
-
value: 90,
|
|
387
|
-
step: 3
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
this.stepper = step => () => {
|
|
391
|
-
this.setState(prev => ({ ...prev, value: prev.value + step }));
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
this.onChange = event => {
|
|
395
|
-
this.setState({
|
|
396
|
-
value: Number(event.target.value)
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
render() {
|
|
402
|
-
const { value } = this.state;
|
|
403
|
-
return (
|
|
404
|
-
<NumberInput
|
|
405
|
-
value={value}
|
|
406
|
-
onMinus={this.stepper(-3)}
|
|
407
|
-
onChange={this.onChange}
|
|
408
|
-
onPlus={this.stepper(3)}
|
|
409
|
-
inputName="input"
|
|
410
|
-
inputAriaLabel="number input"
|
|
411
|
-
minusBtnAriaLabel="minus"
|
|
412
|
-
plusBtnAriaLabel="plus"
|
|
413
|
-
/>
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
42
|
+
```ts file="./NumberInputCustomStep.tsx"
|
|
417
43
|
```
|
|
418
44
|
|
|
419
45
|
### Custom increment/decrement and thresholds
|
|
420
46
|
|
|
421
|
-
```
|
|
422
|
-
import React from 'react';
|
|
423
|
-
import { NumberInput } from '@patternfly/react-core';
|
|
424
|
-
|
|
425
|
-
class CustomStepNumberInput extends React.Component {
|
|
426
|
-
constructor(props) {
|
|
427
|
-
super(props);
|
|
428
|
-
this.state = {
|
|
429
|
-
value: 90,
|
|
430
|
-
step: 3
|
|
431
|
-
};
|
|
432
|
-
this.minValue = 90;
|
|
433
|
-
this.maxValue = 100;
|
|
434
|
-
|
|
435
|
-
this.normalizeBetween = (value, min, max) => {
|
|
436
|
-
if (min !== undefined && max !== undefined) {
|
|
437
|
-
return Math.max(Math.min(value, max), min);
|
|
438
|
-
} else if (value <= min) {
|
|
439
|
-
return min;
|
|
440
|
-
} else if (value >= max) {
|
|
441
|
-
return max;
|
|
442
|
-
}
|
|
443
|
-
return value;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
this.stepper = step => () => {
|
|
447
|
-
this.setState(prev => ({
|
|
448
|
-
...prev,
|
|
449
|
-
value: this.normalizeBetween(prev.value + step, this.minValue, this.maxValue)
|
|
450
|
-
}));
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
this.onChange = event => {
|
|
454
|
-
const newValue = isNaN(event.target.value) ? 0 : Number(event.target.value);
|
|
455
|
-
this.setState({
|
|
456
|
-
value: newValue
|
|
457
|
-
});
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
this.onBlur = event => {
|
|
461
|
-
const newValue = isNaN(event.target.value) ? 0 : Number(event.target.value);
|
|
462
|
-
this.setState({
|
|
463
|
-
value: newValue > this.maxValue ? this.maxValue : newValue < this.minValue ? this.minValue : newValue
|
|
464
|
-
});
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
render() {
|
|
469
|
-
const { value } = this.state;
|
|
470
|
-
return (
|
|
471
|
-
<NumberInput
|
|
472
|
-
value={value}
|
|
473
|
-
min={this.minValue}
|
|
474
|
-
max={this.maxValue}
|
|
475
|
-
onMinus={this.stepper(-3)}
|
|
476
|
-
onChange={this.onChange}
|
|
477
|
-
onBlur={this.onBlur}
|
|
478
|
-
onPlus={this.stepper(3)}
|
|
479
|
-
inputName="input"
|
|
480
|
-
inputAriaLabel="number input"
|
|
481
|
-
minusBtnAriaLabel="minus"
|
|
482
|
-
plusBtnAriaLabel="plus"
|
|
483
|
-
/>
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
47
|
+
```ts file="./NumberInputCustomStepAndThreshold.tsx"
|
|
487
48
|
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const NumberInputCustomStep: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState(90);
|
|
6
|
+
const step = 3;
|
|
7
|
+
|
|
8
|
+
const stepper = (stepValue: number) => {
|
|
9
|
+
setValue(value + stepValue);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const onChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
13
|
+
const target = event.target as HTMLInputElement;
|
|
14
|
+
setValue(Number(target.value));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<NumberInput
|
|
19
|
+
value={value}
|
|
20
|
+
onMinus={() => stepper(-step)}
|
|
21
|
+
onChange={onChange}
|
|
22
|
+
onPlus={() => stepper(step)}
|
|
23
|
+
inputName="input"
|
|
24
|
+
inputAriaLabel="number input"
|
|
25
|
+
minusBtnAriaLabel="minus"
|
|
26
|
+
plusBtnAriaLabel="plus"
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const NumberInputCustomStepAndThreshold: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState(90);
|
|
6
|
+
const minValue = 90;
|
|
7
|
+
const maxValue = 100;
|
|
8
|
+
const step = 3;
|
|
9
|
+
|
|
10
|
+
const normalizeBetween = (value, min, max) => {
|
|
11
|
+
if (min !== undefined && max !== undefined) {
|
|
12
|
+
return Math.max(Math.min(value, max), min);
|
|
13
|
+
} else if (value <= min) {
|
|
14
|
+
return min;
|
|
15
|
+
} else if (value >= max) {
|
|
16
|
+
return max;
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const stepper = (stepValue: number) => {
|
|
22
|
+
setValue(value + stepValue);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
26
|
+
const target = event.target as HTMLInputElement;
|
|
27
|
+
const newValue = normalizeBetween(isNaN(+target.value) ? 0 : Number(target.value), minValue, maxValue);
|
|
28
|
+
setValue(newValue);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const onBlur = (event: React.FormEvent<HTMLInputElement>) => {
|
|
32
|
+
const target = event.target as HTMLInputElement;
|
|
33
|
+
const newValue = normalizeBetween(isNaN(+target.value) ? 0 : Number(target.value), minValue, maxValue);
|
|
34
|
+
setValue(newValue);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<NumberInput
|
|
39
|
+
value={value}
|
|
40
|
+
min={minValue}
|
|
41
|
+
max={maxValue}
|
|
42
|
+
onMinus={() => stepper(-step)}
|
|
43
|
+
onChange={onChange}
|
|
44
|
+
onBlur={onBlur}
|
|
45
|
+
onPlus={() => stepper(step)}
|
|
46
|
+
inputName="input"
|
|
47
|
+
inputAriaLabel="number input"
|
|
48
|
+
minusBtnAriaLabel="minus"
|
|
49
|
+
plusBtnAriaLabel="plus"
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const NumberInputDefault: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState(90);
|
|
6
|
+
|
|
7
|
+
const onMinus = () => {
|
|
8
|
+
const newValue = value - 1;
|
|
9
|
+
setValue(newValue);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const onChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
13
|
+
const target = event.target as HTMLInputElement;
|
|
14
|
+
setValue(Number(target.value));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const onPlus = () => {
|
|
18
|
+
const newValue = value + 1;
|
|
19
|
+
setValue(newValue);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<NumberInput
|
|
24
|
+
value={value}
|
|
25
|
+
onMinus={onMinus}
|
|
26
|
+
onChange={onChange}
|
|
27
|
+
onPlus={onPlus}
|
|
28
|
+
inputName="input"
|
|
29
|
+
inputAriaLabel="number input"
|
|
30
|
+
minusBtnAriaLabel="minus"
|
|
31
|
+
plusBtnAriaLabel="plus"
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const NumberInputDisabled: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState(100);
|
|
6
|
+
const minValue = 0;
|
|
7
|
+
const maxValue = 100;
|
|
8
|
+
|
|
9
|
+
const onMinus = () => {
|
|
10
|
+
const newValue = value - 1;
|
|
11
|
+
setValue(newValue);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
15
|
+
const target = event.target as HTMLInputElement;
|
|
16
|
+
setValue(Number(target.value));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const onPlus = () => {
|
|
20
|
+
const newValue = value + 1;
|
|
21
|
+
setValue(newValue);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<NumberInput
|
|
26
|
+
value={value}
|
|
27
|
+
min={minValue}
|
|
28
|
+
max={maxValue}
|
|
29
|
+
onMinus={onMinus}
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
onPlus={onPlus}
|
|
32
|
+
inputName="input"
|
|
33
|
+
inputAriaLabel="number input"
|
|
34
|
+
minusBtnAriaLabel="minus"
|
|
35
|
+
plusBtnAriaLabel="plus"
|
|
36
|
+
unit="%"
|
|
37
|
+
isDisabled
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const NumberInputUnit: React.FunctionComponent = () => {
|
|
5
|
+
const [value1, setValue1] = React.useState(90);
|
|
6
|
+
const [value2, setValue2] = React.useState(Number((1.0).toFixed(2)));
|
|
7
|
+
|
|
8
|
+
const onMinus1 = () => setValue1(value1 - 1);
|
|
9
|
+
const onChange1 = (event: React.FormEvent<HTMLInputElement>) => {
|
|
10
|
+
const target = event.target as HTMLInputElement;
|
|
11
|
+
setValue1(Number(target.value));
|
|
12
|
+
};
|
|
13
|
+
const onPlus1 = () => setValue1(value1 + 1);
|
|
14
|
+
|
|
15
|
+
const onMinus2 = () => {
|
|
16
|
+
const newValue = Number((value2 - 0.01).toFixed(2));
|
|
17
|
+
setValue2(newValue);
|
|
18
|
+
};
|
|
19
|
+
const onChange2 = (event: React.FormEvent<HTMLInputElement>) => {
|
|
20
|
+
const target = event.target as HTMLInputElement;
|
|
21
|
+
setValue2(Number(target.value));
|
|
22
|
+
};
|
|
23
|
+
const onPlus2 = () => {
|
|
24
|
+
const newValue = Number((value2 + 0.01).toFixed(2));
|
|
25
|
+
setValue2(newValue);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<React.Fragment>
|
|
30
|
+
<NumberInput
|
|
31
|
+
value={value1}
|
|
32
|
+
onMinus={onMinus1}
|
|
33
|
+
onChange={onChange1}
|
|
34
|
+
onPlus={onPlus1}
|
|
35
|
+
inputName="input 1"
|
|
36
|
+
inputAriaLabel="number input 1"
|
|
37
|
+
minusBtnAriaLabel="minus 1"
|
|
38
|
+
plusBtnAriaLabel="plus 1"
|
|
39
|
+
unit="%"
|
|
40
|
+
/>
|
|
41
|
+
<br />
|
|
42
|
+
<br />
|
|
43
|
+
<NumberInput
|
|
44
|
+
value={value2}
|
|
45
|
+
onMinus={onMinus2}
|
|
46
|
+
onChange={onChange2}
|
|
47
|
+
onPlus={onPlus2}
|
|
48
|
+
inputName="input 2"
|
|
49
|
+
inputAriaLabel="number input 2"
|
|
50
|
+
minusBtnAriaLabel="minus 0.01"
|
|
51
|
+
plusBtnAriaLabel="plus 0.01"
|
|
52
|
+
unit="$"
|
|
53
|
+
unitPosition="before"
|
|
54
|
+
/>
|
|
55
|
+
</React.Fragment>
|
|
56
|
+
);
|
|
57
|
+
};
|