@patternfly/react-core 4.267.12 → 4.267.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.267.12",
3
+ "version": "4.267.14",
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": "a8d0266963a7cb1b09500077cb5131401e4abca5"
74
+ "gitHead": "2ebc9fdc95102eaf3acb7a25e58571c3cf1d499b"
75
75
  }
@@ -2,13 +2,13 @@ import * as React from 'react';
2
2
  import styles from '@patternfly/react-styles/css/components/Menu/menu';
3
3
  import { css } from '@patternfly/react-styles';
4
4
 
5
- export interface MenuGroupProps extends React.HTMLProps<HTMLElement> {
5
+ export interface MenuGroupProps extends Omit<React.HTMLProps<HTMLElement>, 'label'> {
6
6
  /** Items within group */
7
7
  children?: React.ReactNode;
8
8
  /** Additional classes added to the MenuGroup */
9
9
  className?: string;
10
10
  /** Group label */
11
- label?: string;
11
+ label?: React.ReactNode | React.FC;
12
12
  /** ID for title label */
13
13
  titleId?: string;
14
14
  /** Forwarded ref */
@@ -25,16 +25,23 @@ const MenuGroupBase: React.FunctionComponent<MenuGroupProps> = ({
25
25
  innerRef,
26
26
  labelHeadingLevel: HeadingLevel = 'h1',
27
27
  ...props
28
- }: MenuGroupProps) => (
29
- <section {...props} className={css('pf-c-menu__group', className)} ref={innerRef}>
30
- {label && (
31
- <HeadingLevel className={css(styles.menuGroupTitle)} id={titleId}>
32
- {label}
33
- </HeadingLevel>
34
- )}
35
- {children}
36
- </section>
37
- );
28
+ }: MenuGroupProps) => {
29
+ const Wrapper = typeof label === 'function' ? label : HeadingLevel;
30
+ return (
31
+ <section {...props} className={css('pf-c-menu__group', className)} ref={innerRef}>
32
+ <>
33
+ {['function', 'string'].includes(typeof label) ? (
34
+ <Wrapper className={css(styles.menuGroupTitle)} id={titleId}>
35
+ {label as React.ReactNode}
36
+ </Wrapper>
37
+ ) : (
38
+ label
39
+ )}
40
+ {children}
41
+ </>
42
+ </section>
43
+ );
44
+ };
38
45
 
39
46
  export const MenuGroup = React.forwardRef((props: MenuGroupProps, ref: React.Ref<HTMLElement>) => (
40
47
  <MenuGroupBase {...props} innerRef={ref} />
@@ -23,49 +23,99 @@ import './page.css';
23
23
 
24
24
  ## Examples
25
25
 
26
- ### Vertical nav
26
+ ### Basic page components
27
+
28
+ A page will typically contain the following components:
29
+
30
+ - A `<Page>` with a `header` that often contains a [masthead](/components/masthead)
31
+ - Mastheads contain the `<PageToggleButton>`, a `<MastheadMain>` that contains a `<MastheadBrand>`, and the page's header toolbar within `<MastheadContent>`.
32
+ - A `<PageSidebar>` for vertical navigation
33
+ - 1 or more `<PageSection>` components
34
+
35
+ ### Vertical navigation
36
+
37
+ To add a vertical sidebar to a `<Page>`, pass a `<PageSidebar>` component into the `sidebar` property. To render navigation in the sidebar, use the `nav` property of the `<PageSidebar>`.
38
+
39
+ The `isNavOpen` property helps facilitate the opening and closing of the sidebar and should be 'true' when the navigation sidebar is visible.
27
40
 
28
41
  ```ts file="./PageVerticalNav.tsx"
29
42
  ```
30
43
 
31
- ### Horizontal nav
44
+ ### Legacy page header
45
+
46
+ This example shows the legacy implementation of a page's vertical navigation. Our updated recommendation advises you to use a masthead and toolbar to make headers, rather than `<PageHeader>` and `<PageHeaderTools>` as shown in the following example.
47
+
48
+ ```ts file="./PageVerticalNavUsingPageHeaderComponent.tsx"
49
+ ```
50
+
51
+ ### Horizontal navigation
52
+
53
+ To add horizontal navigation to the top of a `<Page>`, add the navigation inside of a `<ToolbarItem>` in the `<Toolbar>` that is passed to the `<MastheadContent>` of the `<Masthead>`.
32
54
 
33
55
  ```ts file="./PageHorizontalNav.tsx"
34
56
  ```
35
57
 
36
- ### Tertiary nav
58
+ ### Legacy tertiary navigation
59
+
60
+ [Horizontal sub-navigation](/components/navigation#horizontal-subnav) is now recommended instead of tertiary-level navigation.
61
+
62
+ Tertiary navigation allows you to add an additional navigation menu alongside vertical or horizontal navigation. To create tertiary navigation, use the `tertiaryNav` property. The following example passes `tertiaryNav="Navigation"` into a `<Page>` component.
37
63
 
38
64
  ```ts file="./PageTertiaryNav.tsx"
39
65
  ```
40
66
 
41
- ### With or without fill
67
+ ### Uncontrolled navigation
68
+
69
+ When the `isManagedSidebar` property is true, it manages the sidebar open/close state, removing the need to pass both `isNavOpen` into the `<PageSidebar>` and `onNavToggle` into the `<PageHeader>`.
70
+
71
+ ```ts file="./PageUncontrolledNav.tsx"
72
+ ```
73
+
74
+ ### Filled page sections
75
+
76
+ By default, the last page section is "filled", meaning it fills the available vertical space of a page.
77
+
78
+ To change the default behavior, use the `isFilled` property. To make other page sections "filled", set `isFilled` equal to "true". To disable the last page section from being "filled", set `isFilled` equal to "false".
42
79
 
43
80
  ```ts file="./PageWithOrWithoutFill.tsx"
44
81
  ```
45
82
 
46
83
  ### Main section padding
47
84
 
48
- ```ts file="./PageMainSectionPadding.tsx"
49
- ```
85
+ To adjust the padding of a `<PageSection>`, you can pass in different values to the `padding` property. These values should be aligned to a specific breakpoint: 'default', 'sm', 'md', 'lg', 'xl', and '2xl'. Each breakpoint passed into the property should be given a value of either ‘padding’ or ‘noPadding’.
50
86
 
51
- ### Uncontrolled nav
87
+ As the page's viewport width increases, breakpoints inherit the padding behavior of the previous breakpoint. For example, padding that is set on 'lg' also applies to 'xl' and '2xl'.
52
88
 
53
- ```ts file="./PageUncontrolledNav.tsx"
89
+ To remove padding entirely, pass 'noPadding' to the `default` breakpoint. For example, the second section in this example passes in `padding={{ default: 'noPadding' }}`. Since no specific breakpoints are mentioned, every breakpoint will have 'noPadding'.
90
+
91
+ To add padding at specific breakpoints, pass in "padding" at those breakpoints. For example, the third section in this example passes in `padding={{ default: 'noPadding', md: 'padding' }}`. At 'md', 'lg', 'xl', and '2xl' breakpoints, the default value will be overwritten, and padding will be added.
92
+
93
+ To remove padding at specific breakpoints, pass in 'noPadding' at those breakpoints. For example, the fourth section in this example passes in `padding={{ md: 'noPadding' }}`, which means that 'md', 'lg' 'xl', and '2xl' breakpoints will have `noPadding`.
94
+
95
+ ```ts file="./PageMainSectionPadding.tsx"
54
96
  ```
55
97
 
56
98
  ### Group section
57
99
 
58
- ```ts file="./PageGroupSection.tsx"
59
- ```
100
+ To group page content sections, add 1 or more `<PageGroup>` components to a `<Page>`.
60
101
 
61
- ### Vertical nav using PageHeader component
102
+ The following example adds a group containing `<PageNavigation>`, `<PageBreadcrumb>`, and `<PageSection>` components.
62
103
 
63
- This example is provided because PageHeader and PageHeaderTools are still in use; however, going forward Masthead and Toolbar should be used to make headers rather than PageHeader and PageHeaderTools.
104
+ To add additional components and information to a group, you may use the following properties:
64
105
 
65
- ```ts file="./PageVerticalNavUsingPageHeaderComponent.tsx"
106
+ - To indicate that a breadcrumb should be in a group, use `isBreadcrumbGrouped`.
107
+ - To indicate that tertiary navigation should be in a group, use `isTertiaryNavGrouped`.
108
+ - To specify additional group content, use `additionalGroupedContent`.
109
+
110
+
111
+ ```ts file="./PageGroupSection.tsx"
66
112
  ```
67
113
 
68
114
  ### Centered section
69
115
 
116
+ By default, a page section spans the width of the page. To reduce the width of a section, use the `isWidthLimited` property. To center align width-limited page sections, use the `isCenterAligned` property. When the main content area of a page is wider than the value of a centered, width-limited page section's `--pf-c-page--section--m-limit-width--MaxWidth` custom property, the section will automatically be centered.
117
+
118
+ The content in this example is placed in a card to better illustrate how the section behaves when it is centered, but a card is not required to center a page section.
119
+
70
120
  ```ts file="./PageCenteredSection.tsx"
71
121
  ```
@@ -591,4 +591,4 @@ test('prepends create option to list of options if isCreateOptionOnTop flag is s
591
591
 
592
592
  const createOption = screen.getAllByRole('option')[0];
593
593
  expect(createOption).toHaveTextContent('Create "m"');
594
- });
594
+ });