@patternfly/react-core 4.268.2 → 4.270.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 +27 -0
- package/components/DatePicker/DatePicker.d.ts +2 -2
- package/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/components/DatePicker/DatePicker.js +7 -7
- package/components/DatePicker/DatePicker.js.map +1 -1
- 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/DatePicker/DatePicker.d.ts +2 -2
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +7 -7
- package/dist/esm/components/DatePicker/DatePicker.js.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/DatePicker/DatePicker.d.ts +2 -2
- package/dist/js/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +7 -7
- package/dist/js/components/DatePicker/DatePicker.js.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 +2 -2
- package/package.json +2 -2
- package/src/components/DatePicker/DatePicker.tsx +9 -9
- package/src/components/DatePicker/examples/DatePickerBasic.tsx +2 -2
- package/src/components/DatePicker/examples/DatePickerControlled.tsx +1 -1
- 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.270.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": "78cd4be8d80842ed0236d9ac106f6e8ed56bb075"
|
|
75
75
|
}
|
|
@@ -42,9 +42,9 @@ export interface DatePickerProps
|
|
|
42
42
|
/** Error message to display when the text input cannot be parsed. */
|
|
43
43
|
invalidFormatText?: string;
|
|
44
44
|
/** Callback called every time the text input loses focus. */
|
|
45
|
-
onBlur?: (value: string, date?: Date) => void;
|
|
45
|
+
onBlur?: (event: any, value: string, date?: Date) => void;
|
|
46
46
|
/** Callback called every time the text input value changes. */
|
|
47
|
-
onChange?: (value: string, date?: Date) => void;
|
|
47
|
+
onChange?: (event: React.FormEvent<HTMLInputElement>, value: string, date?: Date) => void;
|
|
48
48
|
/** String to display in the empty text input as a hint for the expected date format. */
|
|
49
49
|
placeholder?: string;
|
|
50
50
|
/** Props to pass to the popover that contains the calendar month component. */
|
|
@@ -138,28 +138,28 @@ const DatePickerBase = (
|
|
|
138
138
|
setErrorText(validators.map(validator => validator(date)).join('\n') || '');
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
const onTextInput = (value: string) => {
|
|
141
|
+
const onTextInput = (value: string, event: React.FormEvent<HTMLInputElement>) => {
|
|
142
142
|
setValue(value);
|
|
143
143
|
setErrorText('');
|
|
144
144
|
const newValueDate = dateParse(value);
|
|
145
145
|
setValueDate(newValueDate);
|
|
146
146
|
if (isValidDate(newValueDate)) {
|
|
147
|
-
onChange(value, new Date(newValueDate));
|
|
147
|
+
onChange(event, value, new Date(newValueDate));
|
|
148
148
|
} else {
|
|
149
|
-
onChange(value);
|
|
149
|
+
onChange(event, value);
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
const onInputBlur = () => {
|
|
153
|
+
const onInputBlur = (event: any) => {
|
|
154
154
|
if (pristine) {
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
const newValueDate = dateParse(value);
|
|
158
158
|
if (isValidDate(newValueDate)) {
|
|
159
|
-
onBlur(value, new Date(newValueDate));
|
|
159
|
+
onBlur(event, value, new Date(newValueDate));
|
|
160
160
|
setError(newValueDate);
|
|
161
161
|
} else {
|
|
162
|
-
onBlur(value);
|
|
162
|
+
onBlur(event, value);
|
|
163
163
|
setErrorText(invalidFormatText);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
@@ -170,7 +170,7 @@ const DatePickerBase = (
|
|
|
170
170
|
setValueDate(newValueDate);
|
|
171
171
|
setError(newValueDate);
|
|
172
172
|
setPopoverOpen(false);
|
|
173
|
-
onChange(newValue, new Date(newValueDate));
|
|
173
|
+
onChange(null, newValue, new Date(newValueDate));
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
const onKeyPress = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
|
@@ -4,8 +4,8 @@ import { DatePicker } from '@patternfly/react-core';
|
|
|
4
4
|
export const DatePickerBasic: React.FunctionComponent = () => (
|
|
5
5
|
<DatePicker
|
|
6
6
|
// eslint-disable-next-line no-console
|
|
7
|
-
onBlur={(str, date) => console.log('onBlur', str, date)}
|
|
7
|
+
onBlur={(_event, str, date) => console.log('onBlur', str, date)}
|
|
8
8
|
// eslint-disable-next-line no-console
|
|
9
|
-
onChange={(str, date) => console.log('onChange', str, date)}
|
|
9
|
+
onChange={(_event, str, date) => console.log('onChange', str, date)}
|
|
10
10
|
/>
|
|
11
11
|
);
|
|
@@ -7,7 +7,7 @@ export const DatePickerControlled: React.FunctionComponent = () => {
|
|
|
7
7
|
return (
|
|
8
8
|
<React.Fragment>
|
|
9
9
|
<Button onClick={() => setValue(initialValue)}>Reset date</Button>
|
|
10
|
-
<DatePicker value={value} onChange={value => setValue(value)} />
|
|
10
|
+
<DatePicker value={value} onChange={(_event, value) => setValue(value)} />
|
|
11
11
|
</React.Fragment>
|
|
12
12
|
);
|
|
13
13
|
};
|
|
@@ -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}>
|