@patternfly/react-core 4.268.2 → 4.269.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 +16 -0
- package/components/NumberInput/NumberInput.d.ts +2 -0
- package/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/components/NumberInput/NumberInput.js +4 -1
- package/components/NumberInput/NumberInput.js.map +1 -1
- package/components/Tabs/Tabs.d.ts +1 -1
- package/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts +2 -0
- package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.js +4 -1
- package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts +2 -0
- package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.js +4 -1
- package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/NumberInput/NumberInput.tsx +6 -0
- package/src/components/NumberInput/__tests__/NumberInput.test.tsx +7 -1
- package/src/components/NumberInput/examples/NumberInputCustomStep.tsx +1 -0
- package/src/components/NumberInput/examples/NumberInputCustomStepAndThreshold.tsx +1 -0
- package/src/components/NumberInput/examples/NumberInputDefault.tsx +1 -0
- package/src/components/NumberInput/examples/NumberInputDisabled.tsx +1 -0
- package/src/components/NumberInput/examples/NumberInputUnit.tsx +2 -0
- package/src/components/NumberInput/examples/NumberInputUnitThreshold.tsx +1 -0
- package/src/components/NumberInput/examples/NumberInputVaryingSizes.tsx +4 -0
- package/src/components/NumberInput/examples/NumberInputWithStatus.tsx +1 -0
- package/src/components/Tabs/Tabs.tsx +1 -1
- package/src/demos/examples/AlertGroup/AlertGroupToastWithNotificationDrawer.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.269.0",
|
|
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": "^16.8 || ^17 || ^18",
|
|
72
72
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "bf9cf833bd7117fcfdb71fc68cab3d2453374336"
|
|
75
75
|
}
|
|
@@ -51,6 +51,8 @@ export interface NumberInputProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
51
51
|
minusBtnProps?: ButtonProps;
|
|
52
52
|
/** Additional properties added to the plus button */
|
|
53
53
|
plusBtnProps?: ButtonProps;
|
|
54
|
+
/** Allow the user to clear out the input to an empty string (recommended) */
|
|
55
|
+
allowEmptyInput?: boolean;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
type DefaultKeyDownHandlerArgs = Pick<NumberInputProps, 'inputName' | 'onMinus' | 'onPlus'>;
|
|
@@ -87,8 +89,12 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
87
89
|
inputProps,
|
|
88
90
|
minusBtnProps,
|
|
89
91
|
plusBtnProps,
|
|
92
|
+
allowEmptyInput = false,
|
|
90
93
|
...props
|
|
91
94
|
}: NumberInputProps) => {
|
|
95
|
+
if (!allowEmptyInput) {
|
|
96
|
+
value = value || 0;
|
|
97
|
+
}
|
|
92
98
|
const numberInputUnit = <div className={css(styles.numberInputUnit)}>{unit}</div>;
|
|
93
99
|
const keyDownHandler =
|
|
94
100
|
inputProps && inputProps.onKeyDown ? inputProps.onKeyDown : defaultKeyDownHandler({ inputName, onMinus, onPlus });
|
|
@@ -207,9 +207,15 @@ describe('numberInput', () => {
|
|
|
207
207
|
expect(input).toHaveDisplayValue('0');
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
test('renders
|
|
210
|
+
test('renders 0 if null value passed without allow empty', () => {
|
|
211
211
|
render(<NumberInput value={null} />);
|
|
212
212
|
const input = screen.getByRole('spinbutton');
|
|
213
|
+
expect(input).toHaveDisplayValue('0');
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('renders nothing if null value passed with allow empty', () => {
|
|
217
|
+
render(<NumberInput allowEmptyInput value={null} />);
|
|
218
|
+
const input = screen.getByRole('spinbutton');
|
|
213
219
|
expect(input).toHaveDisplayValue('');
|
|
214
220
|
});
|
|
215
221
|
|
|
@@ -37,6 +37,7 @@ export const NumberInputUnit: React.FunctionComponent = () => {
|
|
|
37
37
|
minusBtnAriaLabel="minus 1"
|
|
38
38
|
plusBtnAriaLabel="plus 1"
|
|
39
39
|
unit="%"
|
|
40
|
+
allowEmptyInput
|
|
40
41
|
/>
|
|
41
42
|
<br />
|
|
42
43
|
<br />
|
|
@@ -51,6 +52,7 @@ export const NumberInputUnit: React.FunctionComponent = () => {
|
|
|
51
52
|
plusBtnAriaLabel="plus 0.01"
|
|
52
53
|
unit="$"
|
|
53
54
|
unitPosition="before"
|
|
55
|
+
allowEmptyInput
|
|
54
56
|
/>
|
|
55
57
|
</React.Fragment>
|
|
56
58
|
);
|
|
@@ -35,6 +35,7 @@ export const NumberInputVaryingSizes: React.FunctionComponent = () => {
|
|
|
35
35
|
minusBtnAriaLabel="input 2 minus"
|
|
36
36
|
plusBtnAriaLabel="input 2 plus"
|
|
37
37
|
widthChars={1}
|
|
38
|
+
allowEmptyInput
|
|
38
39
|
/>
|
|
39
40
|
<br />
|
|
40
41
|
<br />
|
|
@@ -48,6 +49,7 @@ export const NumberInputVaryingSizes: React.FunctionComponent = () => {
|
|
|
48
49
|
minusBtnAriaLabel="input 2 minus"
|
|
49
50
|
plusBtnAriaLabel="input 2 plus"
|
|
50
51
|
widthChars={10}
|
|
52
|
+
allowEmptyInput
|
|
51
53
|
/>
|
|
52
54
|
<br />
|
|
53
55
|
<br />
|
|
@@ -61,6 +63,7 @@ export const NumberInputVaryingSizes: React.FunctionComponent = () => {
|
|
|
61
63
|
minusBtnAriaLabel="input 3 minus"
|
|
62
64
|
plusBtnAriaLabel="input 3 plus"
|
|
63
65
|
widthChars={5}
|
|
66
|
+
allowEmptyInput
|
|
64
67
|
/>
|
|
65
68
|
<br />
|
|
66
69
|
<br />
|
|
@@ -74,6 +77,7 @@ export const NumberInputVaryingSizes: React.FunctionComponent = () => {
|
|
|
74
77
|
minusBtnAriaLabel="input 4 minus"
|
|
75
78
|
plusBtnAriaLabel="input 4 plus"
|
|
76
79
|
widthChars={5}
|
|
80
|
+
allowEmptyInput
|
|
77
81
|
/>
|
|
78
82
|
</React.Fragment>
|
|
79
83
|
);
|
|
@@ -45,7 +45,7 @@ export interface TabsProps extends Omit<React.HTMLProps<HTMLElement | HTMLDivEle
|
|
|
45
45
|
/** @beta Callback to handle tab closing and adds a basic close button to all tabs. This is overridden by the tab actions property. */
|
|
46
46
|
onClose?: (event: React.MouseEvent<HTMLElement, MouseEvent>, eventKey: number | string) => void;
|
|
47
47
|
/** @beta Callback for the add button. Passing this property inserts the add button */
|
|
48
|
-
onAdd?: () => void;
|
|
48
|
+
onAdd?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
49
49
|
/** @beta Aria-label for the add button */
|
|
50
50
|
addButtonAriaLabel?: string;
|
|
51
51
|
/** Uniquely identifies the tabs */
|
|
@@ -344,6 +344,7 @@ export const AlertGroupToastWithNotificationDrawer: React.FunctionComponent = ()
|
|
|
344
344
|
minusBtnAriaLabel="minus"
|
|
345
345
|
plusBtnAriaLabel="plus"
|
|
346
346
|
style={{ margin: '12px 0' }}
|
|
347
|
+
allowEmptyInput
|
|
347
348
|
/>
|
|
348
349
|
</PageSection>
|
|
349
350
|
<PageSection variant={PageSectionVariants.light}>
|