@patternfly/react-core 4.232.7 → 4.232.10

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/Page/Page.d.ts +1 -1
  3. package/dist/esm/components/Page/Page.d.ts.map +1 -1
  4. package/dist/esm/components/Page/PageBreadcrumb.d.ts +3 -1
  5. package/dist/esm/components/Page/PageBreadcrumb.d.ts.map +1 -1
  6. package/dist/esm/components/Page/PageBreadcrumb.js +8 -2
  7. package/dist/esm/components/Page/PageBreadcrumb.js.map +1 -1
  8. package/dist/esm/components/Page/PageGroup.d.ts +3 -1
  9. package/dist/esm/components/Page/PageGroup.d.ts.map +1 -1
  10. package/dist/esm/components/Page/PageGroup.js +8 -2
  11. package/dist/esm/components/Page/PageGroup.js.map +1 -1
  12. package/dist/esm/components/Page/PageNavigation.d.ts +3 -1
  13. package/dist/esm/components/Page/PageNavigation.d.ts.map +1 -1
  14. package/dist/esm/components/Page/PageNavigation.js +8 -2
  15. package/dist/esm/components/Page/PageNavigation.js.map +1 -1
  16. package/dist/esm/components/Page/PageSection.d.ts +4 -0
  17. package/dist/esm/components/Page/PageSection.d.ts.map +1 -1
  18. package/dist/esm/components/Page/PageSection.js +8 -2
  19. package/dist/esm/components/Page/PageSection.js.map +1 -1
  20. package/dist/js/components/Page/Page.d.ts +1 -1
  21. package/dist/js/components/Page/Page.d.ts.map +1 -1
  22. package/dist/js/components/Page/PageBreadcrumb.d.ts +3 -1
  23. package/dist/js/components/Page/PageBreadcrumb.d.ts.map +1 -1
  24. package/dist/js/components/Page/PageBreadcrumb.js +8 -2
  25. package/dist/js/components/Page/PageBreadcrumb.js.map +1 -1
  26. package/dist/js/components/Page/PageGroup.d.ts +3 -1
  27. package/dist/js/components/Page/PageGroup.d.ts.map +1 -1
  28. package/dist/js/components/Page/PageGroup.js +8 -2
  29. package/dist/js/components/Page/PageGroup.js.map +1 -1
  30. package/dist/js/components/Page/PageNavigation.d.ts +3 -1
  31. package/dist/js/components/Page/PageNavigation.d.ts.map +1 -1
  32. package/dist/js/components/Page/PageNavigation.js +8 -2
  33. package/dist/js/components/Page/PageNavigation.js.map +1 -1
  34. package/dist/js/components/Page/PageSection.d.ts +4 -0
  35. package/dist/js/components/Page/PageSection.d.ts.map +1 -1
  36. package/dist/js/components/Page/PageSection.js +8 -2
  37. package/dist/js/components/Page/PageSection.js.map +1 -1
  38. package/dist/styles/base-no-reset.css +1 -1
  39. package/dist/styles/base.css +1 -1
  40. package/dist/umd/react-core.css +669 -669
  41. package/dist/umd/react-core.js +444 -515
  42. package/dist/umd/react-core.min.js +5 -5
  43. package/package.json +12 -12
  44. package/src/components/Nav/examples/Nav.md +10 -626
  45. package/src/components/Nav/examples/NavDefault.tsx +29 -0
  46. package/src/components/Nav/examples/NavDrilldown.tsx +20 -15
  47. package/src/components/Nav/examples/NavExpandable.tsx +119 -0
  48. package/src/components/Nav/examples/NavExpandableThirdLevel.tsx +115 -0
  49. package/src/components/Nav/examples/NavFlyout.tsx +102 -0
  50. package/src/components/Nav/examples/NavGrouped.tsx +67 -0
  51. package/src/components/Nav/examples/NavHorizontalPageHeader.tsx +34 -0
  52. package/src/components/Nav/examples/NavHorizontalSubNav.tsx +32 -0
  53. package/src/components/Nav/examples/NavLegacyTertiary.tsx +32 -0
  54. package/src/components/Nav/examples/NavMixed.tsx +101 -0
  55. package/src/components/Page/Page.tsx +1 -1
  56. package/src/components/Page/PageBreadcrumb.tsx +11 -0
  57. package/src/components/Page/PageGroup.tsx +11 -0
  58. package/src/components/Page/PageNavigation.tsx +11 -0
  59. package/src/components/Page/PageSection.tsx +13 -0
  60. package/src/components/Page/__tests__/PageBreadcrumb.test.tsx +41 -1
  61. package/src/components/Page/__tests__/PageGroup.test.tsx +41 -1
  62. package/src/components/Page/__tests__/PageNavigation.test.tsx +41 -1
  63. package/src/components/Page/__tests__/PageSection.test.tsx +41 -1
  64. package/src/components/Popover/examples/Popover.md +10 -293
  65. package/src/components/Popover/examples/PopoverAdvanced.tsx +79 -0
  66. package/src/components/Popover/examples/PopoverAlert.tsx +47 -0
  67. package/src/components/Popover/examples/PopoverBasic.tsx +15 -0
  68. package/src/components/Popover/examples/PopoverCloseControlled.tsx +29 -0
  69. package/src/components/Popover/examples/PopoverCloseUncontrolled.tsx +25 -0
  70. package/src/components/Popover/examples/PopoverReactRef.tsx +23 -0
  71. package/src/components/Popover/examples/PopoverSelectorRef.tsx +19 -0
  72. package/src/components/Popover/examples/PopoverWidthAuto.tsx +14 -0
  73. package/src/components/Popover/examples/PopoverWithIconInTheTitle.tsx +17 -0
  74. package/src/components/Popover/examples/PopoverWithoutHeaderFooterCloseNoPadding.tsx +21 -0
  75. package/src/components/Progress/examples/Progress.md +18 -117
  76. package/src/components/Progress/examples/ProgressBasic.tsx +4 -0
  77. package/src/components/Progress/examples/ProgressFailure.tsx +6 -0
  78. package/src/components/Progress/examples/ProgressFailureWithoutMeasure.tsx +6 -0
  79. package/src/components/Progress/examples/ProgressFiniteStep.tsx +14 -0
  80. package/src/components/Progress/examples/ProgressInside.tsx +6 -0
  81. package/src/components/Progress/examples/ProgressInsideSuccess.tsx +11 -0
  82. package/src/components/Progress/examples/ProgressLarge.tsx +6 -0
  83. package/src/components/Progress/examples/ProgressOutside.tsx +6 -0
  84. package/src/components/Progress/examples/ProgressOutsideFailure.tsx +11 -0
  85. package/src/components/Progress/examples/ProgressSingleLine.tsx +6 -0
  86. package/src/components/Progress/examples/ProgressSmall.tsx +6 -0
  87. package/src/components/Progress/examples/ProgressStepInstruction.tsx +6 -0
  88. package/src/components/Progress/examples/ProgressSuccess.tsx +6 -0
  89. package/src/components/Progress/examples/ProgressTitleOutsideOfProgressBar.tsx +24 -0
  90. package/src/components/Progress/examples/ProgressTruncateTitle.tsx +10 -0
  91. package/src/components/Progress/examples/ProgressWarning.tsx +6 -0
  92. package/src/components/Progress/examples/ProgressWithoutMeasure.tsx +6 -0
  93. package/src/demos/JumpLinks.md +1 -0
  94. package/src/demos/examples/BackToTop/BackToTopNameDemo.tsx +6 -1
@@ -78,7 +78,7 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
78
78
  * Can add callback to be notified when resize occurs, for example to set the sidebar isNav prop to false for a width < 768px
79
79
  * Returns object { mobileView: boolean, windowSize: number }
80
80
  */
81
- onPageResize?: (object: any) => void;
81
+ onPageResize?: ((object: any) => void) | null;
82
82
  /**
83
83
  * The page resize observer uses the breakpoints returned from this function when adding the pf-m-breakpoint-[default|sm|md|lg|xl|2xl] class
84
84
  * You can override the default getBreakpoint function to return breakpoints at different sizes than the default
@@ -28,6 +28,8 @@ export interface PageBreadcrumbProps extends React.HTMLProps<HTMLElement> {
28
28
  hasShadowBottom?: boolean;
29
29
  /** Flag indicating if the PageBreadcrumb has a scrolling overflow */
30
30
  hasOverflowScroll?: boolean;
31
+ /** Adds an accessible name to the breadcrumb section. Required when the hasOverflowScroll prop is set to true. */
32
+ 'aria-label'?: string;
31
33
  }
32
34
 
33
35
  export const PageBreadcrumb = ({
@@ -39,10 +41,18 @@ export const PageBreadcrumb = ({
39
41
  hasShadowTop = false,
40
42
  hasShadowBottom = false,
41
43
  hasOverflowScroll = false,
44
+ 'aria-label': ariaLabel,
42
45
  ...props
43
46
  }: PageBreadcrumbProps) => {
44
47
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
45
48
 
49
+ React.useEffect(() => {
50
+ if (hasOverflowScroll && !ariaLabel) {
51
+ /* eslint-disable no-console */
52
+ console.warn('PageBreadcrumb: An accessible aria-label is required when hasOverflowScroll is set to true.');
53
+ }
54
+ }, [hasOverflowScroll, ariaLabel]);
55
+
46
56
  return (
47
57
  <section
48
58
  className={css(
@@ -57,6 +67,7 @@ export const PageBreadcrumb = ({
57
67
  className
58
68
  )}
59
69
  {...(hasOverflowScroll && { tabIndex: 0 })}
70
+ aria-label={ariaLabel}
60
71
  {...props}
61
72
  >
62
73
  {isWidthLimited && <div className={css(styles.pageMainBody)}>{children}</div>}
@@ -25,6 +25,8 @@ export interface PageGroupProps extends React.HTMLProps<HTMLDivElement> {
25
25
  hasShadowBottom?: boolean;
26
26
  /** Flag indicating if the PageGroup has a scrolling overflow */
27
27
  hasOverflowScroll?: boolean;
28
+ /** Adds an accessible name to the page group. Required when the hasOverflowScroll prop is set to true. */
29
+ 'aria-label'?: string;
28
30
  }
29
31
 
30
32
  export const PageGroup = ({
@@ -35,10 +37,18 @@ export const PageGroup = ({
35
37
  hasShadowTop = false,
36
38
  hasShadowBottom = false,
37
39
  hasOverflowScroll = false,
40
+ 'aria-label': ariaLabel,
38
41
  ...props
39
42
  }: PageGroupProps) => {
40
43
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
41
44
 
45
+ React.useEffect(() => {
46
+ if (hasOverflowScroll && !ariaLabel) {
47
+ /* eslint-disable no-console */
48
+ console.warn('PageGroup: An accessible aria-label is required when hasOverflowScroll is set to true.');
49
+ }
50
+ }, [hasOverflowScroll, ariaLabel]);
51
+
42
52
  return (
43
53
  <div
44
54
  {...props}
@@ -53,6 +63,7 @@ export const PageGroup = ({
53
63
  className
54
64
  )}
55
65
  {...(hasOverflowScroll && { tabIndex: 0 })}
66
+ aria-label={ariaLabel}
56
67
  >
57
68
  {children}
58
69
  </div>
@@ -28,6 +28,8 @@ export interface PageNavigationProps extends React.HTMLProps<HTMLDivElement> {
28
28
  hasShadowBottom?: boolean;
29
29
  /** Flag indicating if the PageNavigation has a scrolling overflow */
30
30
  hasOverflowScroll?: boolean;
31
+ /** Adds an accessible name to the page navigation. Required when the hasOverflowScroll prop is set to true. */
32
+ 'aria-label'?: string;
31
33
  }
32
34
 
33
35
  export const PageNavigation = ({
@@ -39,10 +41,18 @@ export const PageNavigation = ({
39
41
  hasShadowTop = false,
40
42
  hasShadowBottom = false,
41
43
  hasOverflowScroll = false,
44
+ 'aria-label': ariaLabel,
42
45
  ...props
43
46
  }: PageNavigationProps) => {
44
47
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
45
48
 
49
+ React.useEffect(() => {
50
+ if (hasOverflowScroll && !ariaLabel) {
51
+ /* eslint-disable no-console */
52
+ console.warn('PageNavigation: An accessible aria-label is required when hasOverflowScroll is set to true.');
53
+ }
54
+ }, [hasOverflowScroll, ariaLabel]);
55
+
46
56
  return (
47
57
  <div
48
58
  className={css(
@@ -57,6 +67,7 @@ export const PageNavigation = ({
57
67
  className
58
68
  )}
59
69
  {...(hasOverflowScroll && { tabIndex: 0 })}
70
+ aria-label={ariaLabel}
60
71
  {...props}
61
72
  >
62
73
  {isWidthLimited && <div className={css(styles.pageMainBody)}>{children}</div>}
@@ -61,6 +61,10 @@ export interface PageSectionProps extends React.HTMLProps<HTMLDivElement> {
61
61
  hasShadowBottom?: boolean;
62
62
  /** Flag indicating if the PageSection has a scrolling overflow */
63
63
  hasOverflowScroll?: boolean;
64
+ /** Adds an accessible name to the page section. Required when the hasOverflowScroll prop is set to true.
65
+ * This prop should also be passed in if a heading is not being used to describe the content of the page section.
66
+ */
67
+ 'aria-label'?: string;
64
68
  }
65
69
 
66
70
  const variantType = {
@@ -93,10 +97,18 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
93
97
  hasShadowTop = false,
94
98
  hasShadowBottom = false,
95
99
  hasOverflowScroll = false,
100
+ 'aria-label': ariaLabel,
96
101
  ...props
97
102
  }: PageSectionProps) => {
98
103
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
99
104
 
105
+ React.useEffect(() => {
106
+ if (hasOverflowScroll && !ariaLabel) {
107
+ /* eslint-disable no-console */
108
+ console.warn('PageSection: An accessible aria-label is required when hasOverflowScroll is set to true.');
109
+ }
110
+ }, [hasOverflowScroll, ariaLabel]);
111
+
100
112
  return (
101
113
  <section
102
114
  {...props}
@@ -117,6 +129,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
117
129
  className
118
130
  )}
119
131
  {...(hasOverflowScroll && { tabIndex: 0 })}
132
+ aria-label={ariaLabel}
120
133
  >
121
134
  {isWidthLimited && <div className={css(styles.pageMainBody)}>{children}</div>}
122
135
  {!isWidthLimited && children}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { PageBreadcrumb } from '../PageBreadcrumb';
4
4
 
5
5
  describe('page breadcrumb', () => {
@@ -31,4 +31,44 @@ describe('page breadcrumb', () => {
31
31
  const { asFragment } = render(<PageBreadcrumb hasOverflowScroll>test</PageBreadcrumb>);
32
32
  expect(asFragment()).toMatchSnapshot();
33
33
  });
34
+
35
+ test('Renders without an aria-label by default', () => {
36
+ render(<PageBreadcrumb>test</PageBreadcrumb>);
37
+
38
+ expect(screen.getByText('test')).not.toHaveAccessibleName('Test label');
39
+ });
40
+
41
+ test('Renders with the passed aria-label applied', () => {
42
+ render(<PageBreadcrumb aria-label="Test label">test</PageBreadcrumb>);
43
+
44
+ expect(screen.getByText('test')).toHaveAccessibleName('Test label');
45
+ });
46
+
47
+ test('Does not log a warning in the console by default', () => {
48
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
49
+
50
+ render(<PageBreadcrumb>test</PageBreadcrumb>);
51
+
52
+ expect(consoleWarning).not.toHaveBeenCalled();
53
+ });
54
+
55
+ test('Does not log a warning in the console when an aria-label is included with hasOverflowScroll', () => {
56
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
57
+
58
+ render(
59
+ <PageBreadcrumb hasOverflowScroll aria-label="Test label">
60
+ test
61
+ </PageBreadcrumb>
62
+ );
63
+
64
+ expect(consoleWarning).not.toHaveBeenCalled();
65
+ });
66
+
67
+ test('Logs a warning in the console when an aria-label is not included with hasOverflowScroll', () => {
68
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
69
+
70
+ render(<PageBreadcrumb hasOverflowScroll>test</PageBreadcrumb>);
71
+
72
+ expect(consoleWarning).toHaveBeenCalled();
73
+ });
34
74
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { PageGroup } from '../PageGroup';
4
4
 
5
5
  describe('page group', () => {
@@ -27,4 +27,44 @@ describe('page group', () => {
27
27
  const { asFragment } = render(<PageGroup hasOverflowScroll>test</PageGroup>);
28
28
  expect(asFragment()).toMatchSnapshot();
29
29
  });
30
+
31
+ test('Renders without an aria-label by default', () => {
32
+ render(<PageGroup>test</PageGroup>);
33
+
34
+ expect(screen.getByText('test')).not.toHaveAccessibleName('Test label');
35
+ });
36
+
37
+ test('Renders with the passed aria-label applied', () => {
38
+ render(<PageGroup aria-label="Test label">test</PageGroup>);
39
+
40
+ expect(screen.getByText('test')).toHaveAccessibleName('Test label');
41
+ });
42
+
43
+ test('Does not log a warning in the console by default', () => {
44
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
45
+
46
+ render(<PageGroup>test</PageGroup>);
47
+
48
+ expect(consoleWarning).not.toHaveBeenCalled();
49
+ });
50
+
51
+ test('Does not log a warning in the console when an aria-label is included with hasOverflowScroll', () => {
52
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
53
+
54
+ render(
55
+ <PageGroup hasOverflowScroll aria-label="Test label">
56
+ test
57
+ </PageGroup>
58
+ );
59
+
60
+ expect(consoleWarning).not.toHaveBeenCalled();
61
+ });
62
+
63
+ test('Logs a warning in the console when an aria-label is not included with hasOverflowScroll', () => {
64
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
65
+
66
+ render(<PageGroup hasOverflowScroll>test</PageGroup>);
67
+
68
+ expect(consoleWarning).toHaveBeenCalled();
69
+ });
30
70
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { PageNavigation } from '../PageNavigation';
4
4
 
5
5
  describe('page navigation', () => {
@@ -31,4 +31,44 @@ describe('page navigation', () => {
31
31
  const { asFragment } = render(<PageNavigation hasOverflowScroll>test</PageNavigation>);
32
32
  expect(asFragment()).toMatchSnapshot();
33
33
  });
34
+
35
+ test('Renders without an aria-label by default', () => {
36
+ render(<PageNavigation>test</PageNavigation>);
37
+
38
+ expect(screen.getByText('test')).not.toHaveAccessibleName('Test label');
39
+ });
40
+
41
+ test('Renders with the passed aria-label applied', () => {
42
+ render(<PageNavigation aria-label="Test label">test</PageNavigation>);
43
+
44
+ expect(screen.getByText('test')).toHaveAccessibleName('Test label');
45
+ });
46
+
47
+ test('Does not log a warning in the console by default', () => {
48
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
49
+
50
+ render(<PageNavigation>test</PageNavigation>);
51
+
52
+ expect(consoleWarning).not.toHaveBeenCalled();
53
+ });
54
+
55
+ test('Does not log a warning in the console when an aria-label is included with hasOverflowScroll', () => {
56
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
57
+
58
+ render(
59
+ <PageNavigation hasOverflowScroll aria-label="Test label">
60
+ test
61
+ </PageNavigation>
62
+ );
63
+
64
+ expect(consoleWarning).not.toHaveBeenCalled();
65
+ });
66
+
67
+ test('Logs a warning in the console when an aria-label is not included with hasOverflowScroll', () => {
68
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
69
+
70
+ render(<PageNavigation hasOverflowScroll>test</PageNavigation>);
71
+
72
+ expect(consoleWarning).toHaveBeenCalled();
73
+ });
34
74
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { PageSection, PageSectionTypes } from '../PageSection';
4
4
 
5
5
  jest.mock('../Page');
@@ -88,3 +88,43 @@ test('Verify page section overflow scroll', () => {
88
88
  const { asFragment } = render(<PageSection hasOverflowScroll>test</PageSection>);
89
89
  expect(asFragment()).toMatchSnapshot();
90
90
  });
91
+
92
+ test('Renders without an aria-label by default', () => {
93
+ render(<PageSection>test</PageSection>);
94
+
95
+ expect(screen.getByText('test')).not.toHaveAccessibleName('Test label');
96
+ });
97
+
98
+ test('Renders with the passed aria-label applied', () => {
99
+ render(<PageSection aria-label="Test label">test</PageSection>);
100
+
101
+ expect(screen.getByText('test')).toHaveAccessibleName('Test label');
102
+ });
103
+
104
+ test('Does not log a warning in the console by default', () => {
105
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
106
+
107
+ render(<PageSection>test</PageSection>);
108
+
109
+ expect(consoleWarning).not.toHaveBeenCalled();
110
+ });
111
+
112
+ test('Does not log a warning in the console when an aria-label is included with hasOverflowScroll', () => {
113
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
114
+
115
+ render(
116
+ <PageSection hasOverflowScroll aria-label="Test label">
117
+ test
118
+ </PageSection>
119
+ );
120
+
121
+ expect(consoleWarning).not.toHaveBeenCalled();
122
+ });
123
+
124
+ test('Logs a warning in the console when an aria-label is not included with hasOverflowScroll', () => {
125
+ const consoleWarning = jest.spyOn(console, 'warn').mockImplementation();
126
+
127
+ render(<PageSection hasOverflowScroll>test</PageSection>);
128
+
129
+ expect(consoleWarning).toHaveBeenCalled();
130
+ });