@patternfly/react-core 4.235.8 → 4.236.2

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 (41) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.d.ts.map +1 -1
  3. package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.js +1 -0
  4. package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.js.map +1 -1
  5. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  6. package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
  7. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  8. package/dist/esm/components/Page/PageSection.d.ts +2 -0
  9. package/dist/esm/components/Page/PageSection.d.ts.map +1 -1
  10. package/dist/esm/components/Page/PageSection.js +3 -2
  11. package/dist/esm/components/Page/PageSection.js.map +1 -1
  12. package/dist/esm/components/TimePicker/TimePicker.js +2 -2
  13. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  14. package/dist/js/components/ApplicationLauncher/ApplicationLauncher.d.ts.map +1 -1
  15. package/dist/js/components/ApplicationLauncher/ApplicationLauncher.js +1 -0
  16. package/dist/js/components/ApplicationLauncher/ApplicationLauncher.js.map +1 -1
  17. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  18. package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
  19. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  20. package/dist/js/components/Page/PageSection.d.ts +2 -0
  21. package/dist/js/components/Page/PageSection.d.ts.map +1 -1
  22. package/dist/js/components/Page/PageSection.js +3 -2
  23. package/dist/js/components/Page/PageSection.js.map +1 -1
  24. package/dist/js/components/TimePicker/TimePicker.js +2 -2
  25. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  26. package/dist/umd/react-core.min.css +915 -901
  27. package/dist/umd/react-core.min.js +2 -2
  28. package/package.json +6 -6
  29. package/src/components/ApplicationLauncher/ApplicationLauncher.tsx +1 -0
  30. package/src/components/Avatar/__tests__/Avatar.test.tsx +69 -3
  31. package/src/components/Avatar/__tests__/__snapshots__/Avatar.test.tsx.snap +3 -2
  32. package/src/components/Dropdown/__tests__/Dropdown.test.tsx +1 -1
  33. package/src/components/Dropdown/examples/DropdownPrimaryToggle.tsx +1 -1
  34. package/src/components/LabelGroup/examples/LabelGroupEditableAdd.tsx +1 -1
  35. package/src/components/LabelGroup/examples/LabelGroupEditableAddDropdown.tsx +1 -1
  36. package/src/components/LabelGroup/examples/LabelGroupEditableAddModal.tsx +5 -5
  37. package/src/components/MenuToggle/MenuToggle.tsx +7 -1
  38. package/src/components/Page/PageSection.tsx +7 -2
  39. package/src/components/Page/__tests__/PageSection.test.tsx +12 -0
  40. package/src/components/Page/examples/PageCenteredSection.tsx +1 -1
  41. package/src/components/TimePicker/TimePicker.tsx +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.235.8",
3
+ "version": "4.236.2",
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",
@@ -44,16 +44,16 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.86.8",
48
- "@patternfly/react-styles": "^4.85.8",
49
- "@patternfly/react-tokens": "^4.87.8",
47
+ "@patternfly/react-icons": "^4.87.2",
48
+ "@patternfly/react-styles": "^4.86.2",
49
+ "@patternfly/react-tokens": "^4.88.2",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
53
53
  "tslib": "^2.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@patternfly/patternfly": "4.210.2",
56
+ "@patternfly/patternfly": "4.211.0",
57
57
  "@rollup/plugin-commonjs": "^21.0.0",
58
58
  "@rollup/plugin-node-resolve": "^13.0.0",
59
59
  "@rollup/plugin-replace": "^3.0.0",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "6c9b5c5d59f891999837cd42cf974865548e6b7a"
73
+ "gitHead": "de201ab6c9fa8d24e516025f984b0b86666f484d"
74
74
  }
@@ -70,6 +70,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
70
70
  isDisabled: false,
71
71
  direction: DropdownDirection.down,
72
72
  favorites: [] as string[],
73
+ items: [] as React.ReactNode[],
73
74
  isOpen: false,
74
75
  position: DropdownPosition.left,
75
76
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -1,8 +1,74 @@
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 { Avatar } from '../Avatar';
4
4
 
5
- test('simple avatar', () => {
6
- const { asFragment } = render(<Avatar alt="avatar" src="test.png" border="light" />);
5
+ test('Renders simple avatar', () => {
6
+ render(
7
+ <div data-testid="avatar">
8
+ <Avatar alt="avatar" />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('avatar').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders without any modifier class when border and size props are not passed', () => {
15
+ render(<Avatar alt="avatar" />);
16
+ expect(screen.getByRole('img')).toHaveClass('pf-c-avatar', { exact: true });
17
+ });
18
+
19
+ test('Renders with class name pf-m-light when "light" is passed as border prop', () => {
20
+ render(<Avatar alt="avatar" border="light" />);
21
+ expect(screen.getByRole('img')).toHaveClass('pf-m-light');
22
+ });
23
+
24
+ test('Renders with class name pf-m-dark when "dark" is passed as border prop', () => {
25
+ render(<Avatar alt="avatar" border="dark" />);
26
+ expect(screen.getByRole('img')).toHaveClass('pf-m-dark');
27
+ });
28
+
29
+ test('Renders with class name pf-m-xl when "xl" is passed as size prop', () => {
30
+ render(<Avatar alt="avatar" size="xl" />);
31
+ expect(screen.getByRole('img')).toHaveClass('pf-m-xl');
32
+ });
33
+
34
+ test('Renders with class name pf-m-lg when "lg" is passed as size prop', () => {
35
+ render(<Avatar alt="avatar" size="lg" />);
36
+ expect(screen.getByRole('img')).toHaveClass('pf-m-lg');
37
+ });
38
+
39
+ test('Renders with class name pf-m-md when "md" is passed as size prop', () => {
40
+ render(<Avatar alt="avatar" size="md" />);
41
+ expect(screen.getByRole('img')).toHaveClass('pf-m-md');
42
+ });
43
+
44
+ test('Renders with class name pf-m-sm when "sm" is passed as size prop', () => {
45
+ render(<Avatar alt="avatar" size="sm" />);
46
+ expect(screen.getByRole('img')).toHaveClass('pf-m-sm');
47
+ });
48
+
49
+ test('Renders with custom class name when className prop is passed', () => {
50
+ render(<Avatar alt="avatar" className="test-class" />);
51
+ expect(screen.getByRole('img')).toHaveClass('test-class');
52
+ });
53
+
54
+ test('Renders with passed src prop', () => {
55
+ render(<Avatar alt="avatar" src="test.png" />);
56
+ const image = screen.getByRole('img') as HTMLImageElement;
57
+ expect(image.src).toMatch('test.png');
58
+ });
59
+
60
+ test('Renders with passed alt prop', () => {
61
+ render(<Avatar alt="avatar" />);
62
+ expect(screen.getByRole('img')).toHaveProperty('alt', 'avatar');
63
+ });
64
+
65
+ test('Renders with passed aria-label prop', () => {
66
+ render(<Avatar alt="avatar" aria-label="Avatar test" />);
67
+ expect(screen.getByRole('img')).toHaveAccessibleName('Avatar test');
68
+ });
69
+
70
+ test('Matches the snapshot', () => {
71
+ const { asFragment } = render(<Avatar alt="avatar" aria-label="Avatar test" src="test.png" className="test-class" />);
72
+
7
73
  expect(asFragment()).toMatchSnapshot();
8
74
  });
@@ -1,10 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`simple avatar 1`] = `
3
+ exports[`Matches the snapshot 1`] = `
4
4
  <DocumentFragment>
5
5
  <img
6
6
  alt="avatar"
7
- class="pf-c-avatar pf-m-light"
7
+ aria-label="Avatar test"
8
+ class="pf-c-avatar test-class"
8
9
  src="test.png"
9
10
  />
10
11
  </DocumentFragment>
@@ -106,7 +106,7 @@ describe('Dropdown', () => {
106
106
  <Dropdown
107
107
  dropdownItems={dropdownItems}
108
108
  toggle={
109
- <DropdownToggle id="Dropdown Toggle" isPrimary>
109
+ <DropdownToggle id="Dropdown Toggle" toggleVariant="primary">
110
110
  Dropdown
111
111
  </DropdownToggle>
112
112
  }
@@ -46,7 +46,7 @@ export const DropdownPrimaryToggle: React.FunctionComponent = () => {
46
46
  <Dropdown
47
47
  onSelect={onSelect}
48
48
  toggle={
49
- <DropdownToggle id="toggle-primary" isPrimary onToggle={onToggle}>
49
+ <DropdownToggle id="toggle-primary" toggleVariant="primary" onToggle={onToggle}>
50
50
  Dropdown
51
51
  </DropdownToggle>
52
52
  }
@@ -59,7 +59,7 @@ export const LabelGroupEditableAdd: React.FunctionComponent = () => {
59
59
  {labels.map((label, index) => (
60
60
  <Label
61
61
  key={label.id}
62
- id={`${label.name}-${index}`}
62
+ id={label.id}
63
63
  color="blue"
64
64
  onClose={() => onClose(label.id)}
65
65
  onEditCancel={prevText => onEdit(prevText, index)}
@@ -122,7 +122,7 @@ export const LabelGroupEditableAddDropdown: React.FunctionComponent = () => {
122
122
  {labels.map((label, index) => (
123
123
  <Label
124
124
  key={label.id}
125
- id={`${label.name}-${index}`}
125
+ id={label.id}
126
126
  color="blue"
127
127
  onClose={() => onClose(label.id)}
128
128
  onEditCancel={prevText => onEdit(prevText, index)}
@@ -20,7 +20,7 @@ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-i
20
20
 
21
21
  export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
22
22
  const [isModalOpen, setModalOpen] = React.useState<boolean>(false);
23
- const [idIndex, setIdIndex] = React.useState<number>(3);
23
+ const [idIndex, setIdIndex] = React.useState<number>(7);
24
24
  const [labelText, setLabelText] = React.useState<string>('');
25
25
  const [color, setColor] = React.useState<string>();
26
26
  const [icon, setIcon] = React.useState<any>();
@@ -40,8 +40,8 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
40
40
  const iconToggleRef = React.useRef<HTMLButtonElement>(null);
41
41
 
42
42
  const [labels, setLabels] = React.useState<any>([
43
- { name: 'Label 1', id: 0 },
44
- { name: 'Label 2', id: 1 },
43
+ { name: 'Label 1', id: 4 },
44
+ { name: 'Label 2', id: 5 },
45
45
  {
46
46
  name: 'Label 3',
47
47
  props: {
@@ -50,7 +50,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
50
50
  'aria-label': 'label editable text'
51
51
  }
52
52
  },
53
- id: 2
53
+ id: 6
54
54
  }
55
55
  ]);
56
56
 
@@ -239,7 +239,7 @@ export const LabelGroupEditableAddModal: React.FunctionComponent = () => {
239
239
  {labels.map((label: { name: string; id: string; props: any }, index: number) => (
240
240
  <Label
241
241
  key={label.id}
242
- id={`${label.name}-${index}`}
242
+ id={label.id}
243
243
  color="blue"
244
244
  onClose={() => onClose(label.id)}
245
245
  onEditCancel={prevText => onEdit(prevText, index)}
@@ -124,7 +124,13 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
124
124
  };
125
125
 
126
126
  if (isTypeahead) {
127
- return <div ref={innerRef as React.Ref<HTMLDivElement>} className={css(commonStyles)} {...componentProps} />;
127
+ return (
128
+ <div
129
+ ref={innerRef as React.Ref<HTMLDivElement>}
130
+ className={css(commonStyles, styles.modifiers.typeahead)}
131
+ {...componentProps}
132
+ />
133
+ );
128
134
  }
129
135
 
130
136
  if (splitButtonOptions) {
@@ -65,6 +65,8 @@ export interface PageSectionProps extends React.HTMLProps<HTMLDivElement> {
65
65
  * This prop should also be passed in if a heading is not being used to describe the content of the page section.
66
66
  */
67
67
  'aria-label'?: string;
68
+ /** Sets the base component to render. Defaults to section */
69
+ component?: keyof JSX.IntrinsicElements;
68
70
  }
69
71
 
70
72
  const variantType = {
@@ -98,6 +100,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
98
100
  hasShadowBottom = false,
99
101
  hasOverflowScroll = false,
100
102
  'aria-label': ariaLabel,
103
+ component = 'section',
101
104
  ...props
102
105
  }: PageSectionProps) => {
103
106
  const { height, getVerticalBreakpoint } = React.useContext(PageContext);
@@ -109,8 +112,10 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
109
112
  }
110
113
  }, [hasOverflowScroll, ariaLabel]);
111
114
 
115
+ const Component = component as any;
116
+
112
117
  return (
113
- <section
118
+ <Component
114
119
  {...props}
115
120
  className={css(
116
121
  variantType[type],
@@ -133,7 +138,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
133
138
  >
134
139
  {isWidthLimited && <div className={css(styles.pageMainBody)}>{children}</div>}
135
140
  {!isWidthLimited && children}
136
- </section>
141
+ </Component>
137
142
  );
138
143
  };
139
144
  PageSection.displayName = 'PageSection';
@@ -128,3 +128,15 @@ test('Logs a warning in the console when an aria-label is not included with hasO
128
128
 
129
129
  expect(consoleWarning).toHaveBeenCalled();
130
130
  });
131
+
132
+ test('Renders as a section by default', () => {
133
+ render(<PageSection>test</PageSection>);
134
+
135
+ expect(screen.getByText('test')).toHaveProperty('nodeName', 'SECTION');
136
+ });
137
+
138
+ test('Renders as other elements when a different element type is passed using the component prop', () => {
139
+ render(<PageSection component="main">test</PageSection>);
140
+
141
+ expect(screen.getByRole('main')).toHaveTextContent('test');
142
+ });
@@ -54,7 +54,7 @@ export const PageCenteredSection: React.FunctionComponent = () => {
54
54
  </Masthead>
55
55
  );
56
56
 
57
- const sidebar = <PageSidebar nav="Navigation" isNavOpen={isNavOpen} id="main-padding-sidebar" />;
57
+ const sidebar = <PageSidebar nav="Navigation" isNavOpen={isNavOpen} id="centered-section-sidebar" />;
58
58
 
59
59
  return (
60
60
  <Page header={header} sidebar={sidebar}>
@@ -282,7 +282,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
282
282
  ) {
283
283
  time = `${time}${new Date().getHours() > 11 ? pmSuffix : amSuffix}`;
284
284
  }
285
- let scrollIndex = this.getOptions().findIndex(option => option.innerText === time);
285
+ let scrollIndex = this.getOptions().findIndex(option => option.textContent === time);
286
286
 
287
287
  // if we found an exact match, scroll to match and return index of match for focus
288
288
  if (scrollIndex !== -1) {
@@ -299,7 +299,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
299
299
  }
300
300
  }
301
301
  time = `${splitTime[0]}${delimiter}00${amPm}`;
302
- scrollIndex = this.getOptions().findIndex(option => option.innerText === time);
302
+ scrollIndex = this.getOptions().findIndex(option => option.textContent === time);
303
303
  if (scrollIndex !== -1) {
304
304
  this.scrollToIndex(scrollIndex);
305
305
  }