@patternfly/react-core 4.265.2 → 4.266.1

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 (55) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +2 -0
  3. package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
  4. package/dist/esm/components/ClipboardCopy/ClipboardCopy.js +4 -3
  5. package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
  6. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.d.ts +2 -0
  7. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.d.ts.map +1 -1
  8. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.js +2 -2
  9. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.js.map +1 -1
  10. package/dist/esm/components/Sidebar/SidebarPanel.d.ts +9 -0
  11. package/dist/esm/components/Sidebar/SidebarPanel.d.ts.map +1 -1
  12. package/dist/esm/components/Sidebar/SidebarPanel.js +10 -0
  13. package/dist/esm/components/Sidebar/SidebarPanel.js.map +1 -1
  14. package/dist/esm/components/Truncate/Truncate.d.ts +2 -0
  15. package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -1
  16. package/dist/esm/components/Truncate/Truncate.js +2 -2
  17. package/dist/esm/components/Truncate/Truncate.js.map +1 -1
  18. package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +2 -0
  19. package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
  20. package/dist/js/components/ClipboardCopy/ClipboardCopy.js +4 -3
  21. package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
  22. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.d.ts +2 -0
  23. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.d.ts.map +1 -1
  24. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.js +2 -2
  25. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.js.map +1 -1
  26. package/dist/js/components/Sidebar/SidebarPanel.d.ts +9 -0
  27. package/dist/js/components/Sidebar/SidebarPanel.d.ts.map +1 -1
  28. package/dist/js/components/Sidebar/SidebarPanel.js +11 -1
  29. package/dist/js/components/Sidebar/SidebarPanel.js.map +1 -1
  30. package/dist/js/components/Truncate/Truncate.d.ts +2 -0
  31. package/dist/js/components/Truncate/Truncate.d.ts.map +1 -1
  32. package/dist/js/components/Truncate/Truncate.js +2 -2
  33. package/dist/js/components/Truncate/Truncate.js.map +1 -1
  34. package/dist/umd/react-core.min.js +2 -2
  35. package/package.json +2 -2
  36. package/src/components/ClipboardCopy/ClipboardCopy.tsx +6 -1
  37. package/src/components/ClipboardCopy/ClipboardCopyButton.tsx +4 -0
  38. package/src/components/Panel/__tests__/Panel.test.tsx +96 -58
  39. package/src/components/Panel/__tests__/PanelFooter.test.tsx +42 -0
  40. package/src/components/Panel/__tests__/PanelHeader.test.tsx +42 -0
  41. package/src/components/Panel/__tests__/PanelMain.test.tsx +48 -0
  42. package/src/components/Panel/__tests__/PanelMainBody.test.tsx +42 -0
  43. package/src/components/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +2 -82
  44. package/src/components/Panel/__tests__/__snapshots__/PanelFooter.test.tsx.snap +11 -0
  45. package/src/components/Panel/__tests__/__snapshots__/PanelHeader.test.tsx.snap +11 -0
  46. package/src/components/Panel/__tests__/__snapshots__/PanelMain.test.tsx.snap +11 -0
  47. package/src/components/Panel/__tests__/__snapshots__/PanelMainBody.test.tsx.snap +11 -0
  48. package/src/components/Sidebar/SidebarPanel.tsx +10 -0
  49. package/src/components/Sidebar/__tests__/Sidebar.test.tsx +72 -0
  50. package/src/components/Sidebar/__tests__/SidebarContent.test.tsx +38 -0
  51. package/src/components/Sidebar/__tests__/SidebarPanel.test.tsx +75 -0
  52. package/src/components/Sidebar/__tests__/__snapshots__/Sidebar.test.tsx.snap +15 -0
  53. package/src/components/Sidebar/__tests__/__snapshots__/SidebarContent.test.tsx.snap +11 -0
  54. package/src/components/Sidebar/__tests__/__snapshots__/SidebarPanel.test.tsx.snap +11 -0
  55. package/src/components/Truncate/Truncate.tsx +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.265.2",
3
+ "version": "4.266.1",
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",
@@ -77,5 +77,5 @@
77
77
  "react": "^16.8 || ^17 || ^18",
78
78
  "react-dom": "^16.8 || ^17 || ^18"
79
79
  },
80
- "gitHead": "16dc61cc8c2e8ee43522c388c638290d34bbb20b"
80
+ "gitHead": "e8e88bf93618d03c99fd94996f0e7db9de6400cd"
81
81
  }
@@ -65,6 +65,8 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
65
65
  | 'left-end'
66
66
  | 'right-start'
67
67
  | 'right-end';
68
+ /** @beta Opt-in for updated popper that does not use findDOMNode. */
69
+ removeFindDomNode?: boolean;
68
70
  /** Maximum width of the tooltip (default 150px). */
69
71
  maxWidth?: string;
70
72
  /** Delay in ms before the tooltip disappears. */
@@ -125,7 +127,8 @@ export class ClipboardCopy extends React.Component<ClipboardCopyProps, Clipboard
125
127
  textAriaLabel: 'Copyable input',
126
128
  toggleAriaLabel: 'Show content',
127
129
  additionalActions: null,
128
- ouiaSafe: true
130
+ ouiaSafe: true,
131
+ removeFindDomNode: false
129
132
  };
130
133
 
131
134
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -177,6 +180,7 @@ export class ClipboardCopy extends React.Component<ClipboardCopyProps, Clipboard
177
180
  additionalActions,
178
181
  ouiaId,
179
182
  ouiaSafe,
183
+ removeFindDomNode,
180
184
  ...divProps
181
185
  } = this.props;
182
186
  const textIdPrefix = 'text-input-';
@@ -269,6 +273,7 @@ export class ClipboardCopy extends React.Component<ClipboardCopyProps, Clipboard
269
273
  this.setState({ copied: true });
270
274
  }}
271
275
  onTooltipHidden={() => this.setState({ copied: false })}
276
+ removeFindDomNode={removeFindDomNode}
272
277
  >
273
278
  {this.state.copied ? clickTip : hoverTip}
274
279
  </ClipboardCopyButton>
@@ -39,6 +39,8 @@ export interface ClipboardCopyButtonProps
39
39
  | 'left-end'
40
40
  | 'right-start'
41
41
  | 'right-end';
42
+ /** @beta Opt-in for updated popper that does not use findDOMNode. */
43
+ removeFindDomNode?: boolean;
42
44
  /** Aria-label for the copy button */
43
45
  'aria-label'?: string;
44
46
  /** Variant of the copy button */
@@ -59,6 +61,7 @@ export const ClipboardCopyButton: React.FunctionComponent<ClipboardCopyButtonPro
59
61
  children,
60
62
  variant = 'control',
61
63
  onTooltipHidden = () => {},
64
+ removeFindDomNode = false,
62
65
  ...props
63
66
  }: ClipboardCopyButtonProps) => (
64
67
  <Tooltip
@@ -71,6 +74,7 @@ export const ClipboardCopyButton: React.FunctionComponent<ClipboardCopyButtonPro
71
74
  aria="none"
72
75
  content={<div>{children}</div>}
73
76
  onTooltipHidden={onTooltipHidden}
77
+ removeFindDomNode={removeFindDomNode}
74
78
  >
75
79
  <Button
76
80
  type="button"
@@ -1,62 +1,100 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import { Panel } from '../Panel';
4
4
  import { PanelMain } from '../PanelMain';
5
5
  import { PanelMainBody } from '../PanelMainBody';
6
- import { PanelHeader } from '../PanelHeader';
7
- import { PanelFooter } from '../PanelFooter';
8
-
9
- describe('Panel', () => {
10
- test('renders content', () => {
11
- const { asFragment } = render(<Panel>Foo</Panel>);
12
- expect(asFragment()).toMatchSnapshot();
13
- });
14
-
15
- test('renders content with raised styling', () => {
16
- const { asFragment } = render(<Panel variant="raised">Foo</Panel>);
17
- expect(asFragment()).toMatchSnapshot();
18
- });
19
-
20
- test('renders content with bordered styling', () => {
21
- const { asFragment } = render(<Panel variant="bordered">Foo</Panel>);
22
- expect(asFragment()).toMatchSnapshot();
23
- });
24
-
25
- test('renders content with scrollable styling', () => {
26
- const { asFragment } = render(<Panel isScrollable>Foo</Panel>);
27
- expect(asFragment()).toMatchSnapshot();
28
- });
29
- });
30
-
31
- describe('PanelMain', () => {
32
- test('renders content', () => {
33
- const { asFragment } = render(<PanelMain>Foo</PanelMain>);
34
- expect(asFragment()).toMatchSnapshot();
35
- });
36
-
37
- test('renders content with the set maximum height', () => {
38
- const { asFragment } = render(<PanelMain maxHeight={'80px'}>Foo</PanelMain>);
39
- expect(asFragment()).toMatchSnapshot();
40
- });
41
- });
42
-
43
- describe('PanelMainBody', () => {
44
- test('renders content', () => {
45
- const { asFragment } = render(<PanelMainBody>Foo</PanelMainBody>);
46
- expect(asFragment()).toMatchSnapshot();
47
- });
48
- });
49
-
50
- describe('PanelHeader', () => {
51
- test('renders content', () => {
52
- const { asFragment } = render(<PanelHeader>Foo</PanelHeader>);
53
- expect(asFragment()).toMatchSnapshot();
54
- });
55
- });
56
-
57
- describe('PanelFooter', () => {
58
- test('renders content', () => {
59
- const { asFragment } = render(<PanelFooter>Foo</PanelFooter>);
60
- expect(asFragment()).toMatchSnapshot();
61
- });
6
+ import userEvent from '@testing-library/user-event';
7
+ import { useEffect } from 'react';
8
+
9
+ test('Renders without children', () => {
10
+ render(
11
+ <div data-testid="panel">
12
+ <Panel />
13
+ </div>
14
+ );
15
+ expect(screen.getByTestId('panel').firstChild).toBeVisible();
16
+ });
17
+
18
+ test('Renders children', () => {
19
+ render(<Panel>Test</Panel>);
20
+ expect(screen.getByText('Test')).toBeVisible();
21
+ });
22
+
23
+ test('Renders with the class pf-c-panel', () => {
24
+ render(<Panel>Test</Panel>);
25
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel');
26
+ });
27
+
28
+ test('Renders with only the class pf-c-panel by default', () => {
29
+ render(<Panel>Test</Panel>);
30
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel', { exact: true });
31
+ });
32
+
33
+ test('Renders with custom class name when className prop is passed', () => {
34
+ render(<Panel className="test-class">Test</Panel>);
35
+ expect(screen.getByText('Test')).toHaveClass('test-class');
36
+ });
37
+
38
+ test('Renders with class name pf-m-raised when variant is raised', () => {
39
+ render(<Panel variant="raised">Test</Panel>);
40
+ expect(screen.getByText('Test')).toHaveClass('pf-m-raised');
41
+ });
42
+
43
+ test('Renders with class name pf-m-bordered when variant is bordered', () => {
44
+ render(<Panel variant="bordered">Test</Panel>);
45
+ expect(screen.getByText('Test')).toHaveClass('pf-m-bordered');
46
+ });
47
+
48
+ test('Renders with class name pf-m-scrollable when isScrollable is true', () => {
49
+ render(<Panel isScrollable>Test</Panel>);
50
+ expect(screen.getByText('Test')).toHaveClass('pf-m-scrollable');
51
+ });
52
+
53
+ test('Renders with ref', async () => {
54
+ const user = userEvent.setup();
55
+ const panelRef: React.RefObject<HTMLDivElement> = React.createRef();
56
+
57
+ const BasicPanel = () => {
58
+ const [lastClickWasInPanel, setLastClickWasInPanel] = React.useState(false);
59
+
60
+ const handleClick = event => {
61
+ if (panelRef.current && panelRef.current.contains(event.target)) {
62
+ setLastClickWasInPanel(true);
63
+ } else {
64
+ setLastClickWasInPanel(false);
65
+ }
66
+ };
67
+
68
+ useEffect(() => {
69
+ document.addEventListener('click', handleClick);
70
+ }, []);
71
+
72
+ return (
73
+ <div>
74
+ <Panel ref={panelRef}>
75
+ <PanelMain>
76
+ <PanelMainBody>Main content</PanelMainBody>
77
+ </PanelMain>
78
+ </Panel>
79
+ <p>Last click was in panel: {lastClickWasInPanel ? 'true' : 'false'}</p>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ render(<BasicPanel />);
85
+
86
+ await user.click(document.body);
87
+ expect(screen.getByText('Last click was in panel: false')).toBeVisible;
88
+ await user.click(screen.getByText('Main content'));
89
+ expect(screen.getByText('Last click was in panel: true')).toBeVisible;
90
+ });
91
+
92
+ test('Renders with the inherited element props spread to the component', () => {
93
+ render(<Panel aria-label="this is a simple panel">Test</Panel>);
94
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel');
95
+ });
96
+
97
+ test('Matches the snapshot', () => {
98
+ const { asFragment } = render(<Panel>Test</Panel>);
99
+ expect(asFragment()).toMatchSnapshot();
62
100
  });
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { PanelFooter } from '../PanelFooter';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="panelFooter">
8
+ <PanelFooter />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('panelFooter').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<PanelFooter>Test</PanelFooter>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with the class pf-c-panel__footer', () => {
20
+ render(<PanelFooter>Test</PanelFooter>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__footer');
22
+ });
23
+
24
+ test('Renders with only the class pf-c-panel__footer by default', () => {
25
+ render(<PanelFooter>Test</PanelFooter>);
26
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__footer', { exact: true });
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is passed', () => {
30
+ render(<PanelFooter className="test-class">Test</PanelFooter>);
31
+ expect(screen.getByText('Test')).toHaveClass('test-class');
32
+ });
33
+
34
+ test('Renders with the inherited element props spread to the component', () => {
35
+ render(<PanelFooter aria-label="this is a simple panel footer">Test</PanelFooter>);
36
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel footer');
37
+ });
38
+
39
+ test('Matches the snapshot', () => {
40
+ const { asFragment } = render(<PanelFooter>Test</PanelFooter>);
41
+ expect(asFragment()).toMatchSnapshot();
42
+ });
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { PanelHeader } from '../PanelHeader';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="panelHeader">
8
+ <PanelHeader />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('panelHeader').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<PanelHeader>Test</PanelHeader>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with the class pf-c-panel__header', () => {
20
+ render(<PanelHeader>Test</PanelHeader>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__header');
22
+ });
23
+
24
+ test('Renders with only the class pf-c-panel__header by default', () => {
25
+ render(<PanelHeader>Test</PanelHeader>);
26
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__header', { exact: true });
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is passed', () => {
30
+ render(<PanelHeader className="test-class">Test</PanelHeader>);
31
+ expect(screen.getByText('Test')).toHaveClass('test-class');
32
+ });
33
+
34
+ test('Renders with the inherited element props spread to the component', () => {
35
+ render(<PanelHeader aria-label="this is a simple panel header">Test</PanelHeader>);
36
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel header');
37
+ });
38
+
39
+ test('Matches the snapshot', () => {
40
+ const { asFragment } = render(<PanelHeader>Test</PanelHeader>);
41
+ expect(asFragment()).toMatchSnapshot();
42
+ });
@@ -0,0 +1,48 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { PanelMain } from '../PanelMain';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="panelMain">
8
+ <PanelMain />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('panelMain').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<PanelMain>Test</PanelMain>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with the class pf-c-panel__main', () => {
20
+ render(<PanelMain>Test</PanelMain>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main');
22
+ });
23
+
24
+ test('Renders with only the class pf-c-panel__main by default', () => {
25
+ render(<PanelMain>Test</PanelMain>);
26
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main', { exact: true });
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is passed', () => {
30
+ render(<PanelMain className="test-class">Test</PanelMain>);
31
+ expect(screen.getByText('Test')).toHaveClass('test-class');
32
+ });
33
+
34
+ test('Renders with custom max height name when maxHeight prop is passed', () => {
35
+ render(<PanelMain maxHeight="100px">Test</PanelMain>);
36
+ const styles = getComputedStyle(screen.getByText('Test'));
37
+ expect(styles.getPropertyValue('--pf-c-panel__main--MaxHeight')).toBe('100px');
38
+ });
39
+
40
+ test('Renders with the inherited element props spread to the component', () => {
41
+ render(<PanelMain aria-label="this is a simple panel main">Test</PanelMain>);
42
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel main');
43
+ });
44
+
45
+ test('Matches the snapshot', () => {
46
+ const { asFragment } = render(<PanelMain>Test</PanelMain>);
47
+ expect(asFragment()).toMatchSnapshot();
48
+ });
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { PanelMainBody } from '../PanelMainBody';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="panelMainBody">
8
+ <PanelMainBody />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('panelMainBody').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<PanelMainBody>Test</PanelMainBody>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with the class pf-c-panel__main-body', () => {
20
+ render(<PanelMainBody>Test</PanelMainBody>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main-body');
22
+ });
23
+
24
+ test('Renders with only the class pf-c-panel__main-body by default', () => {
25
+ render(<PanelMainBody>Test</PanelMainBody>);
26
+ expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main-body', { exact: true });
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is passed', () => {
30
+ render(<PanelMainBody className="test-class">Test</PanelMainBody>);
31
+ expect(screen.getByText('Test')).toHaveClass('test-class');
32
+ });
33
+
34
+ test('Renders with the inherited element props spread to the component', () => {
35
+ render(<PanelMainBody aria-label="this is a simple panel main body">Test</PanelMainBody>);
36
+ expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel main body');
37
+ });
38
+
39
+ test('Matches the snapshot', () => {
40
+ const { asFragment } = render(<PanelMainBody>Test</PanelMainBody>);
41
+ expect(asFragment()).toMatchSnapshot();
42
+ });
@@ -1,92 +1,12 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Panel renders content 1`] = `
3
+ exports[`Matches the snapshot 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
6
  class="pf-c-panel"
7
7
  >
8
- Foo
8
+ Test
9
9
  </div>
10
10
  </DocumentFragment>
11
11
  `;
12
12
 
13
- exports[`Panel renders content with bordered styling 1`] = `
14
- <DocumentFragment>
15
- <div
16
- class="pf-c-panel pf-m-bordered"
17
- >
18
- Foo
19
- </div>
20
- </DocumentFragment>
21
- `;
22
-
23
- exports[`Panel renders content with raised styling 1`] = `
24
- <DocumentFragment>
25
- <div
26
- class="pf-c-panel pf-m-raised"
27
- >
28
- Foo
29
- </div>
30
- </DocumentFragment>
31
- `;
32
-
33
- exports[`Panel renders content with scrollable styling 1`] = `
34
- <DocumentFragment>
35
- <div
36
- class="pf-c-panel pf-m-scrollable"
37
- >
38
- Foo
39
- </div>
40
- </DocumentFragment>
41
- `;
42
-
43
- exports[`PanelFooter renders content 1`] = `
44
- <DocumentFragment>
45
- <div
46
- class="pf-c-panel__footer"
47
- >
48
- Foo
49
- </div>
50
- </DocumentFragment>
51
- `;
52
-
53
- exports[`PanelHeader renders content 1`] = `
54
- <DocumentFragment>
55
- <div
56
- class="pf-c-panel__header"
57
- >
58
- Foo
59
- </div>
60
- </DocumentFragment>
61
- `;
62
-
63
- exports[`PanelMain renders content 1`] = `
64
- <DocumentFragment>
65
- <div
66
- class="pf-c-panel__main"
67
- >
68
- Foo
69
- </div>
70
- </DocumentFragment>
71
- `;
72
-
73
- exports[`PanelMain renders content with the set maximum height 1`] = `
74
- <DocumentFragment>
75
- <div
76
- class="pf-c-panel__main"
77
- style="--pf-c-panel__main--MaxHeight: 80px;"
78
- >
79
- Foo
80
- </div>
81
- </DocumentFragment>
82
- `;
83
-
84
- exports[`PanelMainBody renders content 1`] = `
85
- <DocumentFragment>
86
- <div
87
- class="pf-c-panel__main-body"
88
- >
89
- Foo
90
- </div>
91
- </DocumentFragment>
92
- `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Matches the snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-panel__footer"
7
+ >
8
+ Test
9
+ </div>
10
+ </DocumentFragment>
11
+ `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Matches the snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-panel__header"
7
+ >
8
+ Test
9
+ </div>
10
+ </DocumentFragment>
11
+ `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Matches the snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-panel__main"
7
+ >
8
+ Test
9
+ </div>
10
+ </DocumentFragment>
11
+ `;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Matches the snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-panel__main-body"
7
+ >
8
+ Test
9
+ </div>
10
+ </DocumentFragment>
11
+ `;
@@ -3,6 +3,16 @@ import { css } from '@patternfly/react-styles';
3
3
  import styles from '@patternfly/react-styles/css/components/Sidebar/sidebar';
4
4
  import { formatBreakpointMods } from '../../helpers/util';
5
5
 
6
+ export enum SidebarPanelWidthType {
7
+ default = 'default',
8
+ width25 = 'width_25',
9
+ width33 = 'width_33',
10
+ width50 = 'width_50',
11
+ width66 = 'width_66',
12
+ width75 = 'width_75',
13
+ width100 = 'width_100'
14
+ }
15
+
6
16
  export interface SidebarPanelProps extends Omit<React.HTMLProps<HTMLDivElement>, 'width'> {
7
17
  children: React.ReactNode;
8
18
  /** Indicates whether the panel is positioned statically or sticky to the top. Default is sticky on small screens when the orientation is stack, and static on medium and above screens when the orientation is split. */
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { Sidebar } from '../Sidebar';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="sidebar">
8
+ <Sidebar />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('sidebar').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<Sidebar>Test</Sidebar>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with only class name pf-c-sidebar by default', () => {
20
+ render(<Sidebar>Test</Sidebar>);
21
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-c-sidebar', { exact: true });
22
+ });
23
+
24
+ test('Renders with class name pf-c-sidebar', () => {
25
+ render(<Sidebar>Test</Sidebar>);
26
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-c-sidebar');
27
+ });
28
+
29
+ test('Renders with custom class name when className prop is provided', () => {
30
+ render(<Sidebar className="custom-class">Test</Sidebar>);
31
+ expect(screen.getByText('Test').parentElement).toHaveClass('custom-class');
32
+ });
33
+
34
+ test('Renders with class name pf-m-no-background when hasNoBackground prop is passed', () => {
35
+ render(<Sidebar hasNoBackground>Test</Sidebar>);
36
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-no-background');
37
+ });
38
+
39
+ test('Renders with class name pf-m-stack when "stack" is passed to orientation prop', () => {
40
+ render(<Sidebar orientation="stack">Test</Sidebar>);
41
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-stack');
42
+ });
43
+
44
+ test('Renders with class name pf-m-split when "split" is passed to orientation prop', () => {
45
+ render(<Sidebar orientation="split">Test</Sidebar>);
46
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-split');
47
+ });
48
+
49
+ test('Renders with class name pf-m-panel-right when isPanelRight prop is passed', () => {
50
+ render(<Sidebar isPanelRight>Test</Sidebar>);
51
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-panel-right');
52
+ });
53
+
54
+ test('Renders with class name pf-m-gutter when hasGutter prop is passed', () => {
55
+ render(<Sidebar hasGutter>Test</Sidebar>);
56
+ expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-gutter');
57
+ });
58
+
59
+ test('Renders with class name pf-m-sidebar__main by default for child component', () => {
60
+ render(<Sidebar>Test</Sidebar>);
61
+ expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__main');
62
+ });
63
+
64
+ test('Renders with inherited element props spread to the component', () => {
65
+ render(<Sidebar aria-label="Test label">Test</Sidebar>);
66
+ expect(screen.getByText('Test').parentElement).toHaveAccessibleName('Test label');
67
+ });
68
+
69
+ test('Matches the snapshot', () => {
70
+ const { asFragment } = render(<Sidebar>Test</Sidebar>);
71
+ expect(asFragment()).toMatchSnapshot();
72
+ });