@patternfly/react-core 4.236.1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.236.1",
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.87.1",
48
- "@patternfly/react-styles": "^4.86.1",
49
- "@patternfly/react-tokens": "^4.88.1",
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": "1e8f4121716891c90191b948a66eccf167f404ce"
73
+ "gitHead": "de201ab6c9fa8d24e516025f984b0b86666f484d"
74
74
  }
@@ -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>
@@ -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)}
@@ -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
  }