@patternfly/react-core 4.221.10 → 4.221.11
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 +8 -0
- package/dist/esm/components/Drawer/Drawer.d.ts +1 -0
- package/dist/esm/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/esm/components/Drawer/Drawer.js +3 -1
- package/dist/esm/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerContent.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerContent.js +3 -3
- package/dist/esm/components/Drawer/DrawerContent.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts +0 -2
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelContent.js +2 -2
- package/dist/esm/components/Drawer/DrawerPanelContent.js.map +1 -1
- package/dist/js/components/Drawer/Drawer.d.ts +1 -0
- package/dist/js/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/js/components/Drawer/Drawer.js +3 -1
- package/dist/js/components/Drawer/Drawer.js.map +1 -1
- package/dist/js/components/Drawer/DrawerContent.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerContent.js +2 -2
- package/dist/js/components/Drawer/DrawerContent.js.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts +0 -2
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelContent.js +2 -2
- package/dist/js/components/Drawer/DrawerPanelContent.js.map +1 -1
- package/dist/umd/react-core.js +7 -5
- package/dist/umd/react-core.min.css +70 -70
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/Drawer/Drawer.tsx +5 -1
- package/src/components/Drawer/DrawerContent.tsx +4 -3
- package/src/components/Drawer/DrawerPanelContent.tsx +3 -4
- package/src/components/Drawer/__tests__/Drawer.test.tsx +38 -1
- package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.221.
|
|
3
|
+
"version": "4.221.11",
|
|
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",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.72.
|
|
38
|
-
"@patternfly/react-styles": "^4.71.
|
|
39
|
-
"@patternfly/react-tokens": "^4.73.
|
|
37
|
+
"@patternfly/react-icons": "^4.72.11",
|
|
38
|
+
"@patternfly/react-styles": "^4.71.11",
|
|
39
|
+
"@patternfly/react-tokens": "^4.73.11",
|
|
40
40
|
"focus-trap": "6.9.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "fd4459f338c4b07d600383d7204a240abd58d710"
|
|
64
64
|
}
|
|
@@ -30,6 +30,7 @@ export interface DrawerContextProps {
|
|
|
30
30
|
onExpand?: () => void;
|
|
31
31
|
position?: string;
|
|
32
32
|
drawerRef?: React.RefObject<HTMLDivElement>;
|
|
33
|
+
drawerContentRef?: React.RefObject<HTMLDivElement>;
|
|
33
34
|
isInline: boolean;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -39,6 +40,7 @@ export const DrawerContext = React.createContext<Partial<DrawerContextProps>>({
|
|
|
39
40
|
onExpand: () => {},
|
|
40
41
|
position: 'right',
|
|
41
42
|
drawerRef: null,
|
|
43
|
+
drawerContentRef: null,
|
|
42
44
|
isInline: false
|
|
43
45
|
});
|
|
44
46
|
|
|
@@ -53,8 +55,10 @@ export const Drawer: React.FunctionComponent<DrawerProps> = ({
|
|
|
53
55
|
...props
|
|
54
56
|
}: DrawerProps) => {
|
|
55
57
|
const drawerRef = React.useRef<HTMLDivElement>();
|
|
58
|
+
const drawerContentRef = React.useRef<HTMLDivElement>();
|
|
59
|
+
|
|
56
60
|
return (
|
|
57
|
-
<DrawerContext.Provider value={{ isExpanded, isStatic, onExpand, position, drawerRef, isInline }}>
|
|
61
|
+
<DrawerContext.Provider value={{ isExpanded, isStatic, onExpand, position, drawerRef, drawerContentRef, isInline }}>
|
|
58
62
|
<div
|
|
59
63
|
className={css(
|
|
60
64
|
styles.drawer,
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { DrawerMain } from './DrawerMain';
|
|
5
|
-
import { DrawerColorVariant } from './Drawer';
|
|
5
|
+
import { DrawerColorVariant, DrawerContext } from './Drawer';
|
|
6
6
|
|
|
7
7
|
export interface DrawerContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
8
8
|
/** Additional classes added to the Drawer. */
|
|
@@ -23,7 +23,8 @@ export const DrawerContent: React.FunctionComponent<DrawerContentProps> = ({
|
|
|
23
23
|
colorVariant = DrawerColorVariant.default,
|
|
24
24
|
...props
|
|
25
25
|
}: DrawerContentProps) => {
|
|
26
|
-
const drawerContentRef = React.
|
|
26
|
+
const { drawerContentRef } = React.useContext(DrawerContext);
|
|
27
|
+
|
|
27
28
|
return (
|
|
28
29
|
<DrawerMain>
|
|
29
30
|
<div
|
|
@@ -37,7 +38,7 @@ export const DrawerContent: React.FunctionComponent<DrawerContentProps> = ({
|
|
|
37
38
|
>
|
|
38
39
|
{children}
|
|
39
40
|
</div>
|
|
40
|
-
{panelContent
|
|
41
|
+
{panelContent}
|
|
41
42
|
</DrawerMain>
|
|
42
43
|
);
|
|
43
44
|
};
|
|
@@ -37,8 +37,6 @@ export interface DrawerPanelContentProps extends React.HTMLProps<HTMLDivElement>
|
|
|
37
37
|
};
|
|
38
38
|
/** Color variant of the background of the drawer panel */
|
|
39
39
|
colorVariant?: DrawerColorVariant | 'light-200' | 'default';
|
|
40
|
-
/** @hide Internal ref to drawer content */
|
|
41
|
-
drawerContentRef?: React.RefObject<HTMLDivElement>;
|
|
42
40
|
}
|
|
43
41
|
let isResizing: boolean = null;
|
|
44
42
|
let newSize: number = 0;
|
|
@@ -57,13 +55,14 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
|
|
|
57
55
|
resizeAriaLabel = 'Resize',
|
|
58
56
|
widths,
|
|
59
57
|
colorVariant = DrawerColorVariant.default,
|
|
60
|
-
drawerContentRef,
|
|
61
58
|
...props
|
|
62
59
|
}: DrawerPanelContentProps) => {
|
|
63
60
|
const panel = React.useRef<HTMLDivElement>();
|
|
64
61
|
const splitterRef = React.useRef<HTMLDivElement>();
|
|
65
62
|
const [separatorValue, setSeparatorValue] = React.useState(0);
|
|
66
|
-
const { position, isExpanded, isStatic, onExpand, drawerRef, isInline } = React.useContext(
|
|
63
|
+
const { position, isExpanded, isStatic, onExpand, drawerRef, drawerContentRef, isInline } = React.useContext(
|
|
64
|
+
DrawerContext
|
|
65
|
+
);
|
|
67
66
|
const hidden = isStatic ? false : !isExpanded;
|
|
68
67
|
const [isExpandedInternal, setIsExpandedInternal] = React.useState(!hidden);
|
|
69
68
|
let currWidth: number = 0;
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
DrawerPanelContent
|
|
11
11
|
} from '../';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { render } from '@testing-library/react';
|
|
13
|
+
import { render, screen } from '@testing-library/react';
|
|
14
|
+
import userEvent from '@testing-library/user-event';
|
|
14
15
|
|
|
15
16
|
Object.values([
|
|
16
17
|
{ isExpanded: true, isInline: false, isStatic: false },
|
|
@@ -124,3 +125,39 @@ test(`Drawer has resizable callback and id`, () => {
|
|
|
124
125
|
);
|
|
125
126
|
expect(asFragment()).toMatchSnapshot();
|
|
126
127
|
});
|
|
128
|
+
|
|
129
|
+
test('Resizeable DrawerPanelContent can be wrapped in a context without causing an error', () => {
|
|
130
|
+
const TestContext = React.createContext({});
|
|
131
|
+
|
|
132
|
+
const consoleError = jest.spyOn(console, 'error').mockImplementation();
|
|
133
|
+
|
|
134
|
+
const panelContent = (
|
|
135
|
+
<TestContext.Provider value={{}}>
|
|
136
|
+
<DrawerPanelContent
|
|
137
|
+
isResizable
|
|
138
|
+
>
|
|
139
|
+
<DrawerHead>
|
|
140
|
+
<span>
|
|
141
|
+
drawer-panel
|
|
142
|
+
</span>
|
|
143
|
+
<DrawerActions>
|
|
144
|
+
<DrawerCloseButton />
|
|
145
|
+
</DrawerActions>
|
|
146
|
+
</DrawerHead>
|
|
147
|
+
</DrawerPanelContent>
|
|
148
|
+
</TestContext.Provider>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
render(
|
|
152
|
+
<Drawer isExpanded={true} position="left">
|
|
153
|
+
<DrawerContent panelContent={panelContent}>
|
|
154
|
+
<DrawerContentBody>Drawer content text</DrawerContentBody>
|
|
155
|
+
</DrawerContent>
|
|
156
|
+
</Drawer>
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
userEvent.tab();
|
|
160
|
+
userEvent.keyboard('{arrowleft}');
|
|
161
|
+
|
|
162
|
+
expect(consoleError).not.toHaveBeenCalled();
|
|
163
|
+
})
|