@patternfly/react-core 4.192.6 → 4.192.7
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/Masthead/Masthead.d.ts.map +1 -1
- package/dist/esm/components/Masthead/Masthead.js +6 -2
- package/dist/esm/components/Masthead/Masthead.js.map +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +4 -2
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/Nav.js +2 -1
- package/dist/esm/components/Nav/Nav.js.map +1 -1
- package/dist/esm/components/Nav/NavList.d.ts +2 -8
- package/dist/esm/components/Nav/NavList.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavList.js +4 -7
- package/dist/esm/components/Nav/NavList.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts +14 -0
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +31 -16
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js +7 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/esm/components/Page/PageSidebar.d.ts +1 -0
- package/dist/esm/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/esm/components/Page/PageSidebar.js +3 -2
- package/dist/esm/components/Page/PageSidebar.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +3 -2
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +8 -5
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/esm/helpers/util.d.ts +16 -8
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +53 -7
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Masthead/Masthead.d.ts.map +1 -1
- package/dist/js/components/Masthead/Masthead.js +6 -2
- package/dist/js/components/Masthead/Masthead.js.map +1 -1
- package/dist/js/components/Nav/Nav.d.ts +4 -2
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/Nav.js +3 -2
- package/dist/js/components/Nav/Nav.js.map +1 -1
- package/dist/js/components/Nav/NavList.d.ts +2 -8
- package/dist/js/components/Nav/NavList.d.ts.map +1 -1
- package/dist/js/components/Nav/NavList.js +4 -7
- package/dist/js/components/Nav/NavList.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts +14 -0
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +34 -19
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js +6 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/js/components/Page/PageSidebar.d.ts +1 -0
- package/dist/js/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/js/components/Page/PageSidebar.js +4 -3
- package/dist/js/components/Page/PageSidebar.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +3 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js +7 -4
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/js/helpers/util.d.ts +16 -8
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +55 -8
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +913 -913
- package/dist/umd/react-core.js +420 -347
- package/dist/umd/react-core.min.css +72 -72
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/Masthead/Masthead.tsx +23 -16
- package/src/components/Masthead/__tests__/__snapshots__/Masthead.test.tsx.snap +11 -11
- package/src/components/Nav/Nav.tsx +4 -2
- package/src/components/Nav/NavList.tsx +4 -7
- package/src/components/Page/Page.tsx +49 -16
- package/src/components/Page/PageHeaderToolsGroup.tsx +16 -5
- package/src/components/Page/PageHeaderToolsItem.tsx +20 -14
- package/src/components/Page/PageSidebar.tsx +3 -3
- package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +2 -0
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +18 -9
- package/src/components/Toolbar/Toolbar.tsx +44 -39
- package/src/components/Toolbar/ToolbarContent.tsx +45 -40
- package/src/components/Toolbar/ToolbarGroup.tsx +19 -14
- package/src/components/Toolbar/ToolbarItem.tsx +30 -19
- package/src/components/Toolbar/ToolbarToggleGroup.tsx +60 -53
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/Toolbar.test.tsx.snap +3 -43
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap +3 -7
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarItem.test.tsx.snap +3 -8
- package/src/demos/Page/Page.md +92 -43
- package/src/helpers/util.ts +61 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.192.
|
|
3
|
+
"version": "4.192.7",
|
|
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.43.
|
|
38
|
-
"@patternfly/react-styles": "^4.42.
|
|
39
|
-
"@patternfly/react-tokens": "^4.44.
|
|
37
|
+
"@patternfly/react-icons": "^4.43.7",
|
|
38
|
+
"@patternfly/react-styles": "^4.42.7",
|
|
39
|
+
"@patternfly/react-tokens": "^4.44.7",
|
|
40
40
|
"focus-trap": "6.2.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": "cf4d17a0d89c743e5e12c6d455b8a668cc985bbd"
|
|
64
64
|
}
|
|
@@ -2,6 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Masthead/masthead';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
+
import { PageContext } from '../Page/Page';
|
|
6
|
+
|
|
5
7
|
export interface MastheadProps extends React.DetailedHTMLProps<React.HTMLProps<HTMLDivElement>, HTMLDivElement> {
|
|
6
8
|
/** Content rendered inside of the masthead */
|
|
7
9
|
children?: React.ReactNode;
|
|
@@ -33,22 +35,27 @@ export const Masthead: React.FunctionComponent<MastheadProps> = ({
|
|
|
33
35
|
children,
|
|
34
36
|
className,
|
|
35
37
|
backgroundColor = 'dark',
|
|
36
|
-
display
|
|
38
|
+
display = {
|
|
39
|
+
md: 'inline'
|
|
40
|
+
},
|
|
37
41
|
inset,
|
|
38
42
|
...props
|
|
39
|
-
}: MastheadProps) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
}: MastheadProps) => {
|
|
44
|
+
const { width, getBreakpoint } = React.useContext(PageContext);
|
|
45
|
+
return (
|
|
46
|
+
<header
|
|
47
|
+
className={css(
|
|
48
|
+
styles.masthead,
|
|
49
|
+
formatBreakpointMods(display, styles, 'display-', getBreakpoint(width)),
|
|
50
|
+
formatBreakpointMods(inset, styles, '', getBreakpoint(width)),
|
|
51
|
+
backgroundColor === 'light' && styles.modifiers.light,
|
|
52
|
+
backgroundColor === 'light200' && styles.modifiers.light_200,
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</header>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
54
61
|
Masthead.displayName = 'Masthead';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Masthead verify basic 1`] = `
|
|
4
4
|
<header
|
|
5
|
-
className="pf-c-masthead"
|
|
5
|
+
className="pf-c-masthead pf-m-display-inline-on-md"
|
|
6
6
|
>
|
|
7
7
|
test
|
|
8
8
|
</header>
|
|
@@ -13,7 +13,7 @@ exports[`Masthead verify custom class 1`] = `
|
|
|
13
13
|
className="custom-css"
|
|
14
14
|
>
|
|
15
15
|
<header
|
|
16
|
-
className="pf-c-masthead custom-css"
|
|
16
|
+
className="pf-c-masthead pf-m-display-inline-on-md custom-css"
|
|
17
17
|
>
|
|
18
18
|
test
|
|
19
19
|
</header>
|
|
@@ -23,7 +23,7 @@ exports[`Masthead verify custom class 1`] = `
|
|
|
23
23
|
exports[`Masthead verify full structure 1`] = `
|
|
24
24
|
<Masthead>
|
|
25
25
|
<header
|
|
26
|
-
className="pf-c-masthead"
|
|
26
|
+
className="pf-c-masthead pf-m-display-inline-on-md"
|
|
27
27
|
>
|
|
28
28
|
<MastheadToggle>
|
|
29
29
|
<div
|
|
@@ -94,7 +94,7 @@ exports[`Masthead verify inset2xl inset breakpoints 1`] = `
|
|
|
94
94
|
}
|
|
95
95
|
>
|
|
96
96
|
<header
|
|
97
|
-
className="pf-c-masthead pf-m-inset-2xl pf-m-inset-2xl-on-sm pf-m-inset-2xl-on-md pf-m-inset-2xl-on-lg pf-m-inset-2xl-on-xl pf-m-inset-2xl-on-2xl"
|
|
97
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-2xl pf-m-inset-2xl-on-sm pf-m-inset-2xl-on-md pf-m-inset-2xl-on-lg pf-m-inset-2xl-on-xl pf-m-inset-2xl-on-2xl"
|
|
98
98
|
>
|
|
99
99
|
test
|
|
100
100
|
</header>
|
|
@@ -115,7 +115,7 @@ exports[`Masthead verify inset3xl inset breakpoints 1`] = `
|
|
|
115
115
|
}
|
|
116
116
|
>
|
|
117
117
|
<header
|
|
118
|
-
className="pf-c-masthead"
|
|
118
|
+
className="pf-c-masthead pf-m-display-inline-on-md"
|
|
119
119
|
>
|
|
120
120
|
test
|
|
121
121
|
</header>
|
|
@@ -136,7 +136,7 @@ exports[`Masthead verify insetLg inset breakpoints 1`] = `
|
|
|
136
136
|
}
|
|
137
137
|
>
|
|
138
138
|
<header
|
|
139
|
-
className="pf-c-masthead pf-m-inset-lg pf-m-inset-lg-on-sm pf-m-inset-lg-on-md pf-m-inset-lg-on-lg pf-m-inset-lg-on-xl pf-m-inset-lg-on-2xl"
|
|
139
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-lg pf-m-inset-lg-on-sm pf-m-inset-lg-on-md pf-m-inset-lg-on-lg pf-m-inset-lg-on-xl pf-m-inset-lg-on-2xl"
|
|
140
140
|
>
|
|
141
141
|
test
|
|
142
142
|
</header>
|
|
@@ -157,7 +157,7 @@ exports[`Masthead verify insetMd inset breakpoints 1`] = `
|
|
|
157
157
|
}
|
|
158
158
|
>
|
|
159
159
|
<header
|
|
160
|
-
className="pf-c-masthead pf-m-inset-md pf-m-inset-md-on-sm pf-m-inset-md-on-md pf-m-inset-md-on-lg pf-m-inset-md-on-xl pf-m-inset-md-on-2xl"
|
|
160
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-md pf-m-inset-md-on-sm pf-m-inset-md-on-md pf-m-inset-md-on-lg pf-m-inset-md-on-xl pf-m-inset-md-on-2xl"
|
|
161
161
|
>
|
|
162
162
|
test
|
|
163
163
|
</header>
|
|
@@ -178,7 +178,7 @@ exports[`Masthead verify insetNone inset breakpoints 1`] = `
|
|
|
178
178
|
}
|
|
179
179
|
>
|
|
180
180
|
<header
|
|
181
|
-
className="pf-c-masthead pf-m-inset-none pf-m-inset-none-on-sm pf-m-inset-none-on-md pf-m-inset-none-on-lg pf-m-inset-none-on-xl pf-m-inset-none-on-2xl"
|
|
181
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-none pf-m-inset-none-on-sm pf-m-inset-none-on-md pf-m-inset-none-on-lg pf-m-inset-none-on-xl pf-m-inset-none-on-2xl"
|
|
182
182
|
>
|
|
183
183
|
test
|
|
184
184
|
</header>
|
|
@@ -199,7 +199,7 @@ exports[`Masthead verify insetSm inset breakpoints 1`] = `
|
|
|
199
199
|
}
|
|
200
200
|
>
|
|
201
201
|
<header
|
|
202
|
-
className="pf-c-masthead pf-m-inset-sm pf-m-inset-sm-on-sm pf-m-inset-sm-on-md pf-m-inset-sm-on-lg pf-m-inset-sm-on-xl pf-m-inset-sm-on-2xl"
|
|
202
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-sm pf-m-inset-sm-on-sm pf-m-inset-sm-on-md pf-m-inset-sm-on-lg pf-m-inset-sm-on-xl pf-m-inset-sm-on-2xl"
|
|
203
203
|
>
|
|
204
204
|
test
|
|
205
205
|
</header>
|
|
@@ -220,7 +220,7 @@ exports[`Masthead verify insetXl inset breakpoints 1`] = `
|
|
|
220
220
|
}
|
|
221
221
|
>
|
|
222
222
|
<header
|
|
223
|
-
className="pf-c-masthead pf-m-inset-xl pf-m-inset-xl-on-sm pf-m-inset-xl-on-md pf-m-inset-xl-on-lg pf-m-inset-xl-on-xl pf-m-inset-xl-on-2xl"
|
|
223
|
+
className="pf-c-masthead pf-m-display-inline-on-md pf-m-inset-xl pf-m-inset-xl-on-sm pf-m-inset-xl-on-md pf-m-inset-xl-on-lg pf-m-inset-xl-on-xl pf-m-inset-xl-on-2xl"
|
|
224
224
|
>
|
|
225
225
|
test
|
|
226
226
|
</header>
|
|
@@ -241,7 +241,7 @@ exports[`Masthead verify insetXs inset breakpoints 1`] = `
|
|
|
241
241
|
}
|
|
242
242
|
>
|
|
243
243
|
<header
|
|
244
|
-
className="pf-c-masthead"
|
|
244
|
+
className="pf-c-masthead pf-m-display-inline-on-md"
|
|
245
245
|
>
|
|
246
246
|
test
|
|
247
247
|
</header>
|
|
@@ -38,7 +38,7 @@ export interface NavProps
|
|
|
38
38
|
variant?: 'default' | 'horizontal' | 'tertiary' | 'horizontal-subnav';
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export
|
|
41
|
+
export interface NavContextProps {
|
|
42
42
|
onSelect?: (
|
|
43
43
|
event: React.FormEvent<HTMLInputElement>,
|
|
44
44
|
groupId: number | string,
|
|
@@ -57,7 +57,9 @@ export const NavContext = React.createContext<{
|
|
|
57
57
|
isHorizontal?: boolean;
|
|
58
58
|
flyoutRef?: React.Ref<HTMLLIElement>;
|
|
59
59
|
setFlyoutRef?: (ref: React.Ref<HTMLLIElement>) => void;
|
|
60
|
-
}
|
|
60
|
+
}
|
|
61
|
+
export const navContextDefaults = {};
|
|
62
|
+
export const NavContext = React.createContext<NavContextProps>(navContextDefaults);
|
|
61
63
|
|
|
62
64
|
export class Nav extends React.Component<
|
|
63
65
|
NavProps,
|
|
@@ -6,7 +6,7 @@ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-i
|
|
|
6
6
|
import { isElementInView } from '../../helpers/util';
|
|
7
7
|
import { NavContext } from './Nav';
|
|
8
8
|
import { PageSidebarContext } from '../Page/PageSidebar';
|
|
9
|
-
import {
|
|
9
|
+
import { getResizeObserver } from '../../helpers/resizeObserver';
|
|
10
10
|
|
|
11
11
|
export interface NavListProps
|
|
12
12
|
extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement> {
|
|
@@ -35,6 +35,7 @@ export class NavList extends React.Component<NavListProps> {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
navList = React.createRef<HTMLUListElement>();
|
|
38
|
+
observer: any = () => {};
|
|
38
39
|
|
|
39
40
|
handleScrollButtons = () => {
|
|
40
41
|
const container = this.navList.current;
|
|
@@ -91,16 +92,12 @@ export class NavList extends React.Component<NavListProps> {
|
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
componentDidMount() {
|
|
94
|
-
|
|
95
|
-
window.addEventListener('resize', this.handleScrollButtons, false);
|
|
96
|
-
}
|
|
95
|
+
this.observer = getResizeObserver(this.navList.current, this.handleScrollButtons);
|
|
97
96
|
this.handleScrollButtons();
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
componentWillUnmount() {
|
|
101
|
-
|
|
102
|
-
window.removeEventListener('resize', this.handleScrollButtons, false);
|
|
103
|
-
}
|
|
100
|
+
this.observer();
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
render() {
|
|
@@ -5,6 +5,8 @@ import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/global_breakpo
|
|
|
5
5
|
import { debounce, canUseDOM } from '../../helpers/util';
|
|
6
6
|
import { Drawer, DrawerContent, DrawerContentBody, DrawerPanelContent } from '../Drawer';
|
|
7
7
|
import { PageGroup, PageGroupProps } from './PageGroup';
|
|
8
|
+
import { getResizeObserver } from '../../helpers/resizeObserver';
|
|
9
|
+
import { getBreakpoint } from '../../helpers/util';
|
|
8
10
|
|
|
9
11
|
export enum PageLayouts {
|
|
10
12
|
vertical = 'vertical',
|
|
@@ -15,13 +17,17 @@ export interface PageContextProps {
|
|
|
15
17
|
isManagedSidebar: boolean;
|
|
16
18
|
onNavToggle: () => void;
|
|
17
19
|
isNavOpen: boolean;
|
|
20
|
+
width: number;
|
|
21
|
+
getBreakpoint: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
const PageContext = React.createContext<PageContextProps>({
|
|
23
|
+
export const pageContextDefaults: PageContextProps = {
|
|
21
24
|
isManagedSidebar: false,
|
|
22
25
|
isNavOpen: false,
|
|
23
|
-
onNavToggle: () => null
|
|
24
|
-
|
|
26
|
+
onNavToggle: () => null,
|
|
27
|
+
width: null,
|
|
28
|
+
getBreakpoint
|
|
29
|
+
};
|
|
30
|
+
export const PageContext = React.createContext<PageContextProps>(pageContextDefaults);
|
|
25
31
|
|
|
26
32
|
export const PageContextProvider = PageContext.Provider;
|
|
27
33
|
export const PageContextConsumer = PageContext.Consumer;
|
|
@@ -67,6 +73,13 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
67
73
|
* Returns object { mobileView: boolean, windowSize: number }
|
|
68
74
|
*/
|
|
69
75
|
onPageResize?: (object: any) => void;
|
|
76
|
+
/**
|
|
77
|
+
* The page resize observer uses the breakpoints returned from this function when adding the pf-m-breakpoint-[default|sm|md|lg|xl|2xl] class
|
|
78
|
+
* You can override the default getBreakpoint function to return breakpoints at different sizes than the default
|
|
79
|
+
* You can view the default getBreakpoint function here:
|
|
80
|
+
* https://github.com/patternfly/patternfly-react/blob/main/packages/react-core/src/helpers/util.ts
|
|
81
|
+
*/
|
|
82
|
+
getBreakpoint?: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
70
83
|
/** Breadcrumb component for the page */
|
|
71
84
|
breadcrumb?: React.ReactNode;
|
|
72
85
|
/** Tertiary nav component for the page */
|
|
@@ -87,6 +100,7 @@ export interface PageState {
|
|
|
87
100
|
desktopIsNavOpen: boolean;
|
|
88
101
|
mobileIsNavOpen: boolean;
|
|
89
102
|
mobileView: boolean;
|
|
103
|
+
width: number;
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
export class Page extends React.Component<PageProps, PageState> {
|
|
@@ -98,9 +112,12 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
98
112
|
onPageResize: (): void => null,
|
|
99
113
|
mainTabIndex: -1,
|
|
100
114
|
isNotificationDrawerExpanded: false,
|
|
101
|
-
onNotificationDrawerExpand: () => null
|
|
115
|
+
onNotificationDrawerExpand: () => null,
|
|
116
|
+
getBreakpoint
|
|
102
117
|
};
|
|
103
118
|
mainRef = React.createRef<HTMLDivElement>();
|
|
119
|
+
pageRef = React.createRef<HTMLDivElement>();
|
|
120
|
+
observer: any = () => {};
|
|
104
121
|
|
|
105
122
|
constructor(props: PageProps) {
|
|
106
123
|
super(props);
|
|
@@ -110,16 +127,15 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
110
127
|
this.state = {
|
|
111
128
|
desktopIsNavOpen: managedSidebarOpen,
|
|
112
129
|
mobileIsNavOpen: false,
|
|
113
|
-
mobileView: false
|
|
130
|
+
mobileView: false,
|
|
131
|
+
width: null
|
|
114
132
|
};
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
componentDidMount() {
|
|
118
136
|
const { isManagedSidebar, onPageResize } = this.props;
|
|
119
137
|
if (isManagedSidebar || onPageResize) {
|
|
120
|
-
|
|
121
|
-
window.addEventListener('resize', this.handleResize);
|
|
122
|
-
}
|
|
138
|
+
this.observer = getResizeObserver(this.pageRef.current, this.handleResize);
|
|
123
139
|
const currentRef = this.mainRef.current;
|
|
124
140
|
if (currentRef) {
|
|
125
141
|
currentRef.addEventListener('mousedown', this.handleMainClick);
|
|
@@ -133,9 +149,7 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
133
149
|
componentWillUnmount() {
|
|
134
150
|
const { isManagedSidebar, onPageResize } = this.props;
|
|
135
151
|
if (isManagedSidebar || onPageResize) {
|
|
136
|
-
|
|
137
|
-
window.removeEventListener('resize', this.handleResize);
|
|
138
|
-
}
|
|
152
|
+
this.observer();
|
|
139
153
|
const currentRef = this.mainRef.current;
|
|
140
154
|
if (currentRef) {
|
|
141
155
|
currentRef.removeEventListener('mousedown', this.handleMainClick);
|
|
@@ -144,7 +158,13 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
|
|
147
|
-
getWindowWidth = () =>
|
|
161
|
+
getWindowWidth = () => {
|
|
162
|
+
if (canUseDOM) {
|
|
163
|
+
return this.pageRef.current ? this.pageRef.current.clientWidth : window.innerWidth;
|
|
164
|
+
} else {
|
|
165
|
+
return 1200;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
148
168
|
|
|
149
169
|
isMobile = () =>
|
|
150
170
|
// eslint-disable-next-line radix
|
|
@@ -159,6 +179,7 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
159
179
|
if (mobileView !== this.state.mobileView) {
|
|
160
180
|
this.setState({ mobileView });
|
|
161
181
|
}
|
|
182
|
+
this.pageRef.current && this.setState({ width: this.pageRef.current.clientWidth });
|
|
162
183
|
};
|
|
163
184
|
|
|
164
185
|
handleResize = debounce(this.resize, 250);
|
|
@@ -201,6 +222,7 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
201
222
|
defaultManagedSidebarIsOpen,
|
|
202
223
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
203
224
|
onPageResize,
|
|
225
|
+
getBreakpoint,
|
|
204
226
|
mainAriaLabel,
|
|
205
227
|
mainTabIndex,
|
|
206
228
|
tertiaryNav,
|
|
@@ -210,12 +232,14 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
210
232
|
groupProps,
|
|
211
233
|
...rest
|
|
212
234
|
} = this.props;
|
|
213
|
-
const { mobileView, mobileIsNavOpen, desktopIsNavOpen } = this.state;
|
|
235
|
+
const { mobileView, mobileIsNavOpen, desktopIsNavOpen, width } = this.state;
|
|
214
236
|
|
|
215
237
|
const context = {
|
|
216
238
|
isManagedSidebar,
|
|
217
239
|
onNavToggle: mobileView ? this.onNavToggleMobile : this.onNavToggleDesktop,
|
|
218
|
-
isNavOpen: mobileView ? mobileIsNavOpen : desktopIsNavOpen
|
|
240
|
+
isNavOpen: mobileView ? mobileIsNavOpen : desktopIsNavOpen,
|
|
241
|
+
width,
|
|
242
|
+
getBreakpoint
|
|
219
243
|
};
|
|
220
244
|
|
|
221
245
|
let nav = null;
|
|
@@ -270,7 +294,16 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
270
294
|
|
|
271
295
|
return (
|
|
272
296
|
<PageContextProvider value={context}>
|
|
273
|
-
<div
|
|
297
|
+
<div
|
|
298
|
+
ref={this.pageRef}
|
|
299
|
+
{...rest}
|
|
300
|
+
className={css(
|
|
301
|
+
styles.page,
|
|
302
|
+
width !== null && 'pf-m-resize-observer',
|
|
303
|
+
width !== null && `pf-m-breakpoint-${getBreakpoint(width)}`,
|
|
304
|
+
className
|
|
305
|
+
)}
|
|
306
|
+
>
|
|
274
307
|
{skipToContent}
|
|
275
308
|
{header}
|
|
276
309
|
{sidebar}
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
+
import { PageContext } from '../Page/Page';
|
|
5
6
|
|
|
6
7
|
export interface PageHeaderToolsGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
7
8
|
/** Content rendered in the page header tools group */
|
|
@@ -24,9 +25,19 @@ export const PageHeaderToolsGroup: React.FunctionComponent<PageHeaderToolsGroupP
|
|
|
24
25
|
className,
|
|
25
26
|
visibility,
|
|
26
27
|
...props
|
|
27
|
-
}: PageHeaderToolsGroupProps) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
}: PageHeaderToolsGroupProps) => {
|
|
29
|
+
const { width, getBreakpoint } = React.useContext(PageContext);
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className={css(
|
|
33
|
+
styles.pageHeaderToolsGroup,
|
|
34
|
+
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
32
43
|
PageHeaderToolsGroup.displayName = 'PageHeaderToolsGroup';
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
+
import { PageContext } from '../Page/Page';
|
|
5
6
|
|
|
6
7
|
export interface PageHeaderToolsItemProps extends React.HTMLProps<HTMLDivElement> {
|
|
7
8
|
/** Content rendered in page header tools item. */
|
|
@@ -28,18 +29,23 @@ export const PageHeaderToolsItem: React.FunctionComponent<PageHeaderToolsItemPro
|
|
|
28
29
|
id,
|
|
29
30
|
className,
|
|
30
31
|
visibility,
|
|
31
|
-
isSelected
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
isSelected,
|
|
33
|
+
...props
|
|
34
|
+
}: PageHeaderToolsItemProps) => {
|
|
35
|
+
const { width, getBreakpoint } = React.useContext(PageContext);
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={css(
|
|
39
|
+
styles.pageHeaderToolsItem,
|
|
40
|
+
isSelected && styles.modifiers.selected,
|
|
41
|
+
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
id={id}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
45
51
|
PageHeaderToolsItem.displayName = 'PageHeaderToolsItem';
|
|
@@ -22,10 +22,10 @@ export interface PageSidebarProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
22
22
|
export interface PageSidebarContextProps {
|
|
23
23
|
isNavOpen: boolean;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
export const PageSidebarContext = React.createContext<Partial<PageSidebarContextProps>>({
|
|
25
|
+
export const pageSidebarContextDefaults: PageSidebarContextProps = {
|
|
27
26
|
isNavOpen: true
|
|
28
|
-
}
|
|
27
|
+
};
|
|
28
|
+
export const PageSidebarContext = React.createContext<Partial<PageSidebarContextProps>>(pageSidebarContextDefaults);
|
|
29
29
|
|
|
30
30
|
export const PageSidebar: React.FunctionComponent<PageSidebarProps> = ({
|
|
31
31
|
className = '',
|
|
@@ -5,6 +5,7 @@ exports[`Check dark page against snapshot 1`] = `
|
|
|
5
5
|
aria-label="Page layout"
|
|
6
6
|
className="my-page-class"
|
|
7
7
|
defaultManagedSidebarIsOpen={true}
|
|
8
|
+
getBreakpoint={[Function]}
|
|
8
9
|
header={
|
|
9
10
|
<PageHeader
|
|
10
11
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -29,7 +30,7 @@ exports[`Check dark page against snapshot 1`] = `
|
|
|
29
30
|
>
|
|
30
31
|
<div
|
|
31
32
|
aria-label="Page layout"
|
|
32
|
-
className="pf-c-page my-page-class"
|
|
33
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
33
34
|
id="PageId"
|
|
34
35
|
>
|
|
35
36
|
<PageHeader
|
|
@@ -119,6 +120,7 @@ exports[`Check page horizontal layout example against snapshot 1`] = `
|
|
|
119
120
|
aria-label="Page layout"
|
|
120
121
|
className="my-page-class"
|
|
121
122
|
defaultManagedSidebarIsOpen={true}
|
|
123
|
+
getBreakpoint={[Function]}
|
|
122
124
|
header={
|
|
123
125
|
<PageHeader
|
|
124
126
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -141,7 +143,7 @@ exports[`Check page horizontal layout example against snapshot 1`] = `
|
|
|
141
143
|
>
|
|
142
144
|
<div
|
|
143
145
|
aria-label="Page layout"
|
|
144
|
-
className="pf-c-page my-page-class"
|
|
146
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
145
147
|
id="PageId"
|
|
146
148
|
>
|
|
147
149
|
<PageHeader
|
|
@@ -232,6 +234,7 @@ exports[`Check page to verify breadcrumb is created - PageBreadcrumb syntax 1`]
|
|
|
232
234
|
aria-label="Page layout"
|
|
233
235
|
className="my-page-class"
|
|
234
236
|
defaultManagedSidebarIsOpen={true}
|
|
237
|
+
getBreakpoint={[Function]}
|
|
235
238
|
header={
|
|
236
239
|
<PageHeader
|
|
237
240
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -254,7 +257,7 @@ exports[`Check page to verify breadcrumb is created - PageBreadcrumb syntax 1`]
|
|
|
254
257
|
>
|
|
255
258
|
<div
|
|
256
259
|
aria-label="Page layout"
|
|
257
|
-
className="pf-c-page my-page-class"
|
|
260
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
258
261
|
id="PageId"
|
|
259
262
|
>
|
|
260
263
|
<PageHeader
|
|
@@ -510,6 +513,7 @@ exports[`Check page to verify breadcrumb is created 1`] = `
|
|
|
510
513
|
breadcrumb={<PageBreadcrumb />}
|
|
511
514
|
className="my-page-class"
|
|
512
515
|
defaultManagedSidebarIsOpen={true}
|
|
516
|
+
getBreakpoint={[Function]}
|
|
513
517
|
header={
|
|
514
518
|
<PageHeader
|
|
515
519
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -532,7 +536,7 @@ exports[`Check page to verify breadcrumb is created 1`] = `
|
|
|
532
536
|
>
|
|
533
537
|
<div
|
|
534
538
|
aria-label="Page layout"
|
|
535
|
-
className="pf-c-page my-page-class"
|
|
539
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
536
540
|
id="PageId"
|
|
537
541
|
>
|
|
538
542
|
<PageHeader
|
|
@@ -787,6 +791,7 @@ exports[`Check page to verify grouped nav and breadcrumb - new components syntax
|
|
|
787
791
|
aria-label="Page layout"
|
|
788
792
|
className="my-page-class"
|
|
789
793
|
defaultManagedSidebarIsOpen={true}
|
|
794
|
+
getBreakpoint={[Function]}
|
|
790
795
|
header={
|
|
791
796
|
<PageHeader
|
|
792
797
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -809,7 +814,7 @@ exports[`Check page to verify grouped nav and breadcrumb - new components syntax
|
|
|
809
814
|
>
|
|
810
815
|
<div
|
|
811
816
|
aria-label="Page layout"
|
|
812
|
-
className="pf-c-page my-page-class"
|
|
817
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
813
818
|
id="PageId"
|
|
814
819
|
>
|
|
815
820
|
<PageHeader
|
|
@@ -1295,6 +1300,7 @@ exports[`Check page to verify grouped nav and breadcrumb - old / props syntax 1`
|
|
|
1295
1300
|
}
|
|
1296
1301
|
className="my-page-class"
|
|
1297
1302
|
defaultManagedSidebarIsOpen={true}
|
|
1303
|
+
getBreakpoint={[Function]}
|
|
1298
1304
|
groupProps={
|
|
1299
1305
|
Object {
|
|
1300
1306
|
"hasShadowTop": true,
|
|
@@ -1367,7 +1373,7 @@ exports[`Check page to verify grouped nav and breadcrumb - old / props syntax 1`
|
|
|
1367
1373
|
>
|
|
1368
1374
|
<div
|
|
1369
1375
|
aria-label="Page layout"
|
|
1370
|
-
className="pf-c-page my-page-class"
|
|
1376
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
1371
1377
|
id="PageId"
|
|
1372
1378
|
>
|
|
1373
1379
|
<PageHeader
|
|
@@ -1831,6 +1837,7 @@ exports[`Check page to verify nav is created - PageNavigation syntax 1`] = `
|
|
|
1831
1837
|
aria-label="Page layout"
|
|
1832
1838
|
className="my-page-class"
|
|
1833
1839
|
defaultManagedSidebarIsOpen={true}
|
|
1840
|
+
getBreakpoint={[Function]}
|
|
1834
1841
|
header={
|
|
1835
1842
|
<PageHeader
|
|
1836
1843
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -1853,7 +1860,7 @@ exports[`Check page to verify nav is created - PageNavigation syntax 1`] = `
|
|
|
1853
1860
|
>
|
|
1854
1861
|
<div
|
|
1855
1862
|
aria-label="Page layout"
|
|
1856
|
-
className="pf-c-page my-page-class"
|
|
1863
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
1857
1864
|
id="PageId"
|
|
1858
1865
|
>
|
|
1859
1866
|
<PageHeader
|
|
@@ -2165,6 +2172,7 @@ exports[`Check page to verify skip to content points to main content region 1`]
|
|
|
2165
2172
|
}
|
|
2166
2173
|
className="my-page-class"
|
|
2167
2174
|
defaultManagedSidebarIsOpen={true}
|
|
2175
|
+
getBreakpoint={[Function]}
|
|
2168
2176
|
header={
|
|
2169
2177
|
<PageHeader
|
|
2170
2178
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -2196,7 +2204,7 @@ exports[`Check page to verify skip to content points to main content region 1`]
|
|
|
2196
2204
|
>
|
|
2197
2205
|
<div
|
|
2198
2206
|
aria-label="Page layout"
|
|
2199
|
-
className="pf-c-page my-page-class"
|
|
2207
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
2200
2208
|
id="PageId"
|
|
2201
2209
|
>
|
|
2202
2210
|
<SkipToContent
|
|
@@ -2461,6 +2469,7 @@ exports[`Check page vertical layout example against snapshot 1`] = `
|
|
|
2461
2469
|
aria-label="Page layout"
|
|
2462
2470
|
className="my-page-class"
|
|
2463
2471
|
defaultManagedSidebarIsOpen={true}
|
|
2472
|
+
getBreakpoint={[Function]}
|
|
2464
2473
|
header={
|
|
2465
2474
|
<PageHeader
|
|
2466
2475
|
headerTools="PageHeaderTools | Avatar"
|
|
@@ -2484,7 +2493,7 @@ exports[`Check page vertical layout example against snapshot 1`] = `
|
|
|
2484
2493
|
>
|
|
2485
2494
|
<div
|
|
2486
2495
|
aria-label="Page layout"
|
|
2487
|
-
className="pf-c-page my-page-class"
|
|
2496
|
+
className="pf-c-page pf-m-resize-observer pf-m-breakpoint-default my-page-class"
|
|
2488
2497
|
id="PageId"
|
|
2489
2498
|
>
|
|
2490
2499
|
<PageHeader
|