@patternfly/react-core 4.235.3 → 4.235.6
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 +33 -0
- package/dist/esm/components/NumberInput/NumberInput.d.ts +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.js +2 -1
- package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.js +2 -1
- package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/umd/react-core.min.css +776 -776
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/DualListSelector/examples/DualListSelectorComposableDragDrop.tsx +1 -1
- package/src/components/NumberInput/NumberInput.tsx +3 -2
- package/src/components/NumberInput/__tests__/NumberInput.test.tsx +52 -15
- package/src/demos/ComposableMenu/examples/ComposableActionsMenu.tsx +1 -1
- package/src/demos/ComposableMenu/examples/ComposableFlyout.tsx +4 -3
- package/src/demos/ComposableMenu/examples/ComposableSimpleCheckboxSelect.tsx +1 -1
- package/src/demos/ComposableMenu/examples/ComposableSimpleSelect.tsx +1 -1
- package/src/demos/ComposableMenu/examples/ComposableTypeaheadSelect.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.235.
|
|
3
|
+
"version": "4.235.6",
|
|
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",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"generate": "node scripts/copyStyles.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@patternfly/react-icons": "^4.86.
|
|
48
|
-
"@patternfly/react-styles": "^4.85.
|
|
49
|
-
"@patternfly/react-tokens": "^4.87.
|
|
47
|
+
"@patternfly/react-icons": "^4.86.6",
|
|
48
|
+
"@patternfly/react-styles": "^4.85.6",
|
|
49
|
+
"@patternfly/react-tokens": "^4.87.6",
|
|
50
50
|
"focus-trap": "6.9.2",
|
|
51
51
|
"react-dropzone": "9.0.0",
|
|
52
52
|
"tippy.js": "5.1.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8.0 || ^17.0.0",
|
|
71
71
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "e688e3b26385dc09280dca250d72a733ce18b52a"
|
|
74
74
|
}
|
|
@@ -81,7 +81,7 @@ export const DualListSelectorComposableDragDrop: React.FunctionComponent = () =>
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
const onDrop = (source: DraggableItemPosition, dest
|
|
84
|
+
const onDrop = (source: DraggableItemPosition, dest: DraggableItemPosition | undefined) => {
|
|
85
85
|
if (dest) {
|
|
86
86
|
const newList = [...chosenOptions];
|
|
87
87
|
const [removed] = newList.splice(source.index, 1);
|
|
@@ -10,7 +10,7 @@ import { TextInput } from '../TextInput';
|
|
|
10
10
|
|
|
11
11
|
export interface NumberInputProps extends React.HTMLProps<HTMLDivElement> {
|
|
12
12
|
/** Value of the number input */
|
|
13
|
-
value?: number;
|
|
13
|
+
value?: number | null;
|
|
14
14
|
/** Additional classes added to the number input */
|
|
15
15
|
className?: string;
|
|
16
16
|
/** Sets the width of the number input to a number of characters */
|
|
@@ -89,6 +89,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
89
89
|
plusBtnProps,
|
|
90
90
|
...props
|
|
91
91
|
}: NumberInputProps) => {
|
|
92
|
+
value = value || 0;
|
|
92
93
|
const numberInputUnit = <div className={css(styles.numberInputUnit)}>{unit}</div>;
|
|
93
94
|
const keyDownHandler =
|
|
94
95
|
inputProps && inputProps.onKeyDown ? inputProps.onKeyDown : defaultKeyDownHandler({ inputName, onMinus, onPlus });
|
|
@@ -128,6 +129,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
128
129
|
</span>
|
|
129
130
|
</Button>
|
|
130
131
|
<TextInput
|
|
132
|
+
{...inputProps}
|
|
131
133
|
type="number"
|
|
132
134
|
value={value}
|
|
133
135
|
name={inputName}
|
|
@@ -138,7 +140,6 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
138
140
|
{...(!onChange && { isReadOnly: true })}
|
|
139
141
|
onKeyDown={keyDownHandler}
|
|
140
142
|
validated={validated}
|
|
141
|
-
{...inputProps}
|
|
142
143
|
/>
|
|
143
144
|
<Button
|
|
144
145
|
variant="control"
|
|
@@ -10,19 +10,19 @@ describe('numberInput', () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
test('renders success validated', () => {
|
|
13
|
-
const { asFragment } = render(<NumberInput validated=
|
|
13
|
+
const { asFragment } = render(<NumberInput validated="success" />);
|
|
14
14
|
expect(asFragment()).toMatchSnapshot();
|
|
15
|
-
})
|
|
15
|
+
});
|
|
16
16
|
|
|
17
17
|
test('renders error validated', () => {
|
|
18
|
-
const { asFragment } = render(<NumberInput validated=
|
|
18
|
+
const { asFragment } = render(<NumberInput validated="error" />);
|
|
19
19
|
expect(asFragment()).toMatchSnapshot();
|
|
20
|
-
})
|
|
20
|
+
});
|
|
21
21
|
|
|
22
22
|
test('renders warning validated', () => {
|
|
23
|
-
const { asFragment } = render(<NumberInput validated=
|
|
23
|
+
const { asFragment } = render(<NumberInput validated="warning" />);
|
|
24
24
|
expect(asFragment()).toMatchSnapshot();
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
|
|
27
27
|
test('renders value', () => {
|
|
28
28
|
const { asFragment } = render(<NumberInput value={90} />);
|
|
@@ -136,37 +136,74 @@ describe('numberInput', () => {
|
|
|
136
136
|
|
|
137
137
|
test('removes leading zeros from a positive whole number', () => {
|
|
138
138
|
render(<NumberInput value={10} onChange={() => {}} />);
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
const input = screen.getByRole('spinbutton');
|
|
141
141
|
userEvent.type(input, '{arrowleft}{arrowleft}0');
|
|
142
142
|
expect(input).toHaveDisplayValue('010');
|
|
143
|
-
|
|
143
|
+
|
|
144
144
|
userEvent.click(document.body);
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
expect(input).toHaveDisplayValue('10');
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
test('removes leading zeros from a negative whole number', () => {
|
|
150
150
|
render(<NumberInput value={-18} onChange={() => {}} />);
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
const input = screen.getByRole('spinbutton');
|
|
153
153
|
userEvent.type(input, '{arrowleft}{arrowleft}0');
|
|
154
154
|
expect(input).toHaveDisplayValue('-018');
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
userEvent.click(document.body);
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
expect(input).toHaveDisplayValue('-18');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
test('removes leading zeros from a decimal number', () => {
|
|
162
162
|
render(<NumberInput value={47.01} onChange={() => {}} />);
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
const input = screen.getByRole('spinbutton');
|
|
165
165
|
userEvent.type(input, '{arrowleft}{arrowleft}{arrowleft}{arrowleft}{arrowleft}0');
|
|
166
166
|
expect(input).toHaveDisplayValue('047.01');
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
userEvent.click(document.body);
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
expect(input).toHaveDisplayValue('47.01');
|
|
171
171
|
});
|
|
172
|
+
|
|
173
|
+
test('renders 0 if no value passed', () => {
|
|
174
|
+
render(<NumberInput />);
|
|
175
|
+
const input = screen.getByRole('spinbutton');
|
|
176
|
+
expect(input).toHaveDisplayValue('0');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('renders 0 if undefined value passed', () => {
|
|
180
|
+
render(<NumberInput value={undefined} />);
|
|
181
|
+
const input = screen.getByRole('spinbutton');
|
|
182
|
+
expect(input).toHaveDisplayValue('0');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('renders 0 if null value passed', () => {
|
|
186
|
+
render(<NumberInput value={null} />);
|
|
187
|
+
const input = screen.getByRole('spinbutton');
|
|
188
|
+
expect(input).toHaveDisplayValue('0');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('does not throw an error if onChange is passed via inputProps as well as the onChange prop', () => {
|
|
192
|
+
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
193
|
+
|
|
194
|
+
const NumberInputWrapper = () => {
|
|
195
|
+
const [value, setValue] = React.useState(0);
|
|
196
|
+
const onChange = event => setValue(event.currentTarget.value);
|
|
197
|
+
const inputProps = { onChange: onChange };
|
|
198
|
+
|
|
199
|
+
return <NumberInput value={value} onChange={onChange} inputProps={{ ...inputProps }} />;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
render(<NumberInputWrapper />);
|
|
203
|
+
|
|
204
|
+
const input = screen.getByRole('spinbutton');
|
|
205
|
+
userEvent.type(input, '0');
|
|
206
|
+
|
|
207
|
+
expect(consoleSpy).not.toHaveBeenCalled();
|
|
208
|
+
});
|
|
172
209
|
});
|
|
@@ -36,7 +36,7 @@ export const ComposableActionsMenu: React.FunctionComponent = () => {
|
|
|
36
36
|
};
|
|
37
37
|
}, [isOpen, menuRef]);
|
|
38
38
|
|
|
39
|
-
const onSelect = (event
|
|
39
|
+
const onSelect = (event: React.MouseEvent | undefined, itemId: string | number | undefined) => {
|
|
40
40
|
if (typeof itemId === 'string' || typeof itemId === 'undefined') {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MenuToggle, Menu, MenuContent, MenuList, MenuItem, Popper } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const onSelect = (event
|
|
6
|
-
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
const onSelect = (event: React.MouseEvent | undefined, itemId: string | number | undefined) =>
|
|
6
|
+
console.log('selected', itemId);
|
|
7
|
+
/* eslint-enable no-console */
|
|
7
8
|
interface FlyoutMenuProps {
|
|
8
9
|
children?: React.ReactElement;
|
|
9
10
|
depth: number;
|
|
@@ -50,7 +50,7 @@ export const ComposableSimpleCheckboxSelect: React.FunctionComponent = () => {
|
|
|
50
50
|
setIsOpen(!isOpen);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
const onSelect = (event
|
|
53
|
+
const onSelect = (event: React.MouseEvent | undefined, itemId: string | number | undefined) => {
|
|
54
54
|
if (typeof itemId === 'string' || typeof itemId === 'undefined') {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -59,7 +59,7 @@ export const ComposableSimpleSelect: React.FunctionComponent = () => {
|
|
|
59
59
|
</MenuToggle>
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
function onSelect(event
|
|
62
|
+
function onSelect(event: React.MouseEvent | undefined, itemId: string | number | undefined) {
|
|
63
63
|
if (typeof itemId === 'undefined') {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
@@ -55,7 +55,7 @@ export const ComposableTypeaheadSelect: React.FunctionComponent = () => {
|
|
|
55
55
|
|
|
56
56
|
const focusOnInput = () => menuToggleRef.current?.querySelector('input')?.focus();
|
|
57
57
|
|
|
58
|
-
const onMenuSelect = (event
|
|
58
|
+
const onMenuSelect = (event: React.MouseEvent | undefined, itemId: string | number | undefined) => {
|
|
59
59
|
if (itemId) {
|
|
60
60
|
setInputValue(itemId.toString());
|
|
61
61
|
setIsSelected(true);
|
|
@@ -124,7 +124,7 @@ export const ComposableTypeaheadSelect: React.FunctionComponent = () => {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
// Close the menu when a click occurs outside of the menu toggle content
|
|
127
|
-
const onDocumentClick = (event
|
|
127
|
+
const onDocumentClick = (event: MouseEvent | undefined) => {
|
|
128
128
|
if (!menuToggleRef.current?.contains(event?.target as HTMLElement)) {
|
|
129
129
|
setIsMenuOpen(false);
|
|
130
130
|
}
|