@patternfly/react-core 4.254.1 → 4.255.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 (30) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/esm/components/Alert/AlertIcon.js +1 -1
  3. package/dist/esm/components/Alert/AlertIcon.js.map +1 -1
  4. package/dist/esm/next/components/Dropdown/Dropdown.d.ts +6 -1
  5. package/dist/esm/next/components/Dropdown/Dropdown.d.ts.map +1 -1
  6. package/dist/esm/next/components/Dropdown/Dropdown.js +4 -2
  7. package/dist/esm/next/components/Dropdown/Dropdown.js.map +1 -1
  8. package/dist/esm/next/components/Dropdown/DropdownItem.d.ts +6 -1
  9. package/dist/esm/next/components/Dropdown/DropdownItem.d.ts.map +1 -1
  10. package/dist/esm/next/components/Dropdown/DropdownItem.js +4 -2
  11. package/dist/esm/next/components/Dropdown/DropdownItem.js.map +1 -1
  12. package/dist/js/components/Alert/AlertIcon.js +1 -1
  13. package/dist/js/components/Alert/AlertIcon.js.map +1 -1
  14. package/dist/js/next/components/Dropdown/Dropdown.d.ts +6 -1
  15. package/dist/js/next/components/Dropdown/Dropdown.d.ts.map +1 -1
  16. package/dist/js/next/components/Dropdown/Dropdown.js +4 -2
  17. package/dist/js/next/components/Dropdown/Dropdown.js.map +1 -1
  18. package/dist/js/next/components/Dropdown/DropdownItem.d.ts +6 -1
  19. package/dist/js/next/components/Dropdown/DropdownItem.d.ts.map +1 -1
  20. package/dist/js/next/components/Dropdown/DropdownItem.js +4 -2
  21. package/dist/js/next/components/Dropdown/DropdownItem.js.map +1 -1
  22. package/dist/umd/react-core.min.css +410 -410
  23. package/dist/umd/react-core.min.js +1 -1
  24. package/package.json +2 -2
  25. package/src/components/Alert/AlertIcon.tsx +2 -2
  26. package/src/components/Button/__tests__/Button.test.tsx +16 -7
  27. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +36 -0
  28. package/src/components/Button/examples/ButtonProgress.tsx +15 -2
  29. package/src/next/components/Dropdown/Dropdown.tsx +10 -2
  30. package/src/next/components/Dropdown/DropdownItem.tsx +16 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.254.1",
3
+ "version": "4.255.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",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "b609c0cf576028d64a9ab93f42b34d84c4f5d54f"
73
+ "gitHead": "bb273c8429b6dc5794f70dc8ee4c0ea9a15c20f1"
74
74
  }
@@ -26,9 +26,9 @@ export interface AlertIconProps extends React.HTMLProps<HTMLDivElement> {
26
26
 
27
27
  export const AlertIcon = ({ variant, customIcon, className = '', ...props }: AlertIconProps) => {
28
28
  const Icon = variantIcons[variant];
29
- return (
29
+ return Icon ? (
30
30
  <div {...props} className={css(styles.alertIcon, className)}>
31
31
  {customIcon || <Icon />}
32
32
  </div>
33
- );
33
+ ) : null;
34
34
  };
@@ -103,6 +103,22 @@ describe('Button', () => {
103
103
  expect(asFragment()).toMatchSnapshot();
104
104
  });
105
105
 
106
+ test('isLoading inline link', () => {
107
+ const { asFragment } = render(
108
+ <Button variant="link" isInline isLoading aria-label="Loading" spinnerAriaValueText="Loading">
109
+ Loading Button
110
+ </Button>
111
+ );
112
+ expect(asFragment()).toMatchSnapshot();
113
+ });
114
+
115
+ test('isLoading icon only', () => {
116
+ const { asFragment } = render(
117
+ <Button variant="plain" isLoading aria-label="Upload" spinnerAriaValueText="Loading" icon={<div>ICON</div>} />
118
+ );
119
+ expect(asFragment()).toMatchSnapshot();
120
+ });
121
+
106
122
  test('allows passing in a string as the component', () => {
107
123
  const component = 'a';
108
124
  render(<Button component={component}>anchor button</Button>);
@@ -130,11 +146,4 @@ describe('Button', () => {
130
146
  render(<Button tabIndex={0}>TabIndex 0 Button</Button>);
131
147
  expect(screen.getByRole('button')).toHaveAttribute('tabindex', '0');
132
148
  });
133
-
134
- test('isLoading icon only', () => {
135
- const { asFragment } = render(
136
- <Button variant="plain" isLoading aria-label="Upload" spinnerAriaValueText="Loading" icon={<div>ICON</div>} />
137
- );
138
- expect(asFragment()).toMatchSnapshot();
139
- });
140
149
  });
@@ -240,6 +240,42 @@ exports[`Button isLoading icon only 1`] = `
240
240
  </DocumentFragment>
241
241
  `;
242
242
 
243
+ exports[`Button isLoading inline link 1`] = `
244
+ <DocumentFragment>
245
+ <button
246
+ aria-disabled="false"
247
+ aria-label="Loading"
248
+ class="pf-c-button pf-m-link pf-m-inline pf-m-progress pf-m-in-progress"
249
+ data-ouia-component-id="OUIA-Generated-Button-link-5"
250
+ data-ouia-component-type="PF4/Button"
251
+ data-ouia-safe="true"
252
+ type="button"
253
+ >
254
+ <span
255
+ class="pf-c-button__progress"
256
+ >
257
+ <span
258
+ aria-label="Contents"
259
+ aria-valuetext="Loading"
260
+ class="pf-c-spinner pf-m-md"
261
+ role="progressbar"
262
+ >
263
+ <span
264
+ class="pf-c-spinner__clipper"
265
+ />
266
+ <span
267
+ class="pf-c-spinner__lead-ball"
268
+ />
269
+ <span
270
+ class="pf-c-spinner__tail-ball"
271
+ />
272
+ </span>
273
+ </span>
274
+ Loading Button
275
+ </button>
276
+ </DocumentFragment>
277
+ `;
278
+
243
279
  exports[`Button isSmall 1`] = `
244
280
  <DocumentFragment>
245
281
  <button
@@ -12,6 +12,7 @@ interface LoadingPropsType {
12
12
  export const ButtonProgress: React.FunctionComponent = () => {
13
13
  const [isPrimaryLoading, setIsPrimaryLoading] = React.useState<boolean>(true);
14
14
  const [isSecondaryLoading, setIsSecondaryLoading] = React.useState<boolean>(true);
15
+ const [isInlineLoading, setIsInlineLoading] = React.useState<boolean>(true);
15
16
  const [isUploading, setIsUploading] = React.useState<boolean>(false);
16
17
 
17
18
  const primaryLoadingProps = {} as LoadingPropsType;
@@ -24,6 +25,11 @@ export const ButtonProgress: React.FunctionComponent = () => {
24
25
  secondaryLoadingProps.spinnerAriaLabel = 'Content being loaded';
25
26
  secondaryLoadingProps.isLoading = isSecondaryLoading;
26
27
 
28
+ const inlineLoadingProps = {} as LoadingPropsType;
29
+ inlineLoadingProps.spinnerAriaValueText = 'Loading';
30
+ inlineLoadingProps.spinnerAriaLabel = 'Content being loaded';
31
+ inlineLoadingProps.isLoading = isInlineLoading;
32
+
27
33
  const uploadingProps = {} as LoadingPropsType;
28
34
  uploadingProps.spinnerAriaValueText = 'Loading';
29
35
  uploadingProps.spinnerAriaLabel = 'Uploading data';
@@ -37,18 +43,25 @@ export const ButtonProgress: React.FunctionComponent = () => {
37
43
  onClick={() => setIsPrimaryLoading(!isPrimaryLoading)}
38
44
  {...primaryLoadingProps}
39
45
  >
40
- {isPrimaryLoading ? 'Pause loading logs' : 'Resume loading logs'}
46
+ {isPrimaryLoading ? 'Click to stop loading' : 'Click to start loading'}
41
47
  </Button>{' '}
42
48
  <Button variant="secondary" onClick={() => setIsSecondaryLoading(!isSecondaryLoading)} {...secondaryLoadingProps}>
43
49
  {isSecondaryLoading ? 'Click to stop loading' : 'Click to start loading'}
44
50
  </Button>{' '}
51
+ <br />
52
+ <br />
45
53
  <Button
46
54
  variant="plain"
47
55
  {...(!isUploading && { 'aria-label': 'Upload' })}
48
56
  onClick={() => setIsUploading(!isUploading)}
49
57
  icon={<UploadIcon />}
50
58
  {...uploadingProps}
51
- />
59
+ />{' '}
60
+ <br />
61
+ <br />
62
+ <Button variant="link" isInline onClick={() => setIsInlineLoading(!isInlineLoading)} {...inlineLoadingProps}>
63
+ {isInlineLoading ? 'Pause loading logs' : 'Resume loading logs'}
64
+ </Button>{' '}
52
65
  </React.Fragment>
53
66
  );
54
67
  };
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import { Menu, MenuContent, MenuProps } from '../../../components/Menu';
4
4
  import { Popper } from '../../../helpers/Popper/Popper';
5
+ import { useOUIAProps, OUIAProps } from '../../../helpers';
5
6
 
6
- export interface DropdownProps extends MenuProps {
7
+ export interface DropdownProps extends MenuProps, OUIAProps {
7
8
  /** Anything which can be rendered in a dropdown. */
8
9
  children?: React.ReactNode;
9
10
  /** Classes applied to root element of dropdown. */
@@ -25,6 +26,10 @@ export interface DropdownProps extends MenuProps {
25
26
  minWidth?: string;
26
27
  /** @hide Forwarded ref */
27
28
  innerRef?: React.Ref<any>;
29
+ /** Value to overwrite the randomly generated data-ouia-component-id.*/
30
+ ouiaId?: number | string;
31
+ /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
32
+ ouiaSafe?: boolean;
28
33
  }
29
34
 
30
35
  const DropdownBase: React.FunctionComponent<DropdownProps> = ({
@@ -38,11 +43,14 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
38
43
  isScrollable,
39
44
  minWidth,
40
45
  innerRef,
46
+ ouiaId,
47
+ ouiaSafe = true,
41
48
  ...props
42
49
  }: DropdownProps) => {
43
50
  const localMenuRef = React.useRef<HTMLDivElement>();
44
51
  const toggleRef = React.useRef<HTMLButtonElement>();
45
52
  const containerRef = React.useRef<HTMLDivElement>();
53
+ const ouiaProps = useOUIAProps(Dropdown.displayName, ouiaId, ouiaSafe);
46
54
 
47
55
  const menuRef = (innerRef as React.RefObject<HTMLDivElement>) || localMenuRef;
48
56
  React.useEffect(() => {
@@ -104,7 +112,7 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
104
112
  </Menu>
105
113
  );
106
114
  return (
107
- <div ref={containerRef}>
115
+ <div ref={containerRef} {...ouiaProps}>
108
116
  <Popper
109
117
  trigger={toggle(toggleRef)}
110
118
  removeFindDomNode
@@ -1,24 +1,34 @@
1
1
  import React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import { MenuItemProps, MenuItem } from '../../../components/Menu';
4
+ import { useOUIAProps, OUIAProps } from '../../../helpers';
4
5
 
5
- export interface DropdownItemProps extends Omit<MenuItemProps, 'ref'> {
6
+ export interface DropdownItemProps extends Omit<MenuItemProps, 'ref'>, OUIAProps {
6
7
  /** Anything which can be rendered in a dropdown item */
7
8
  children?: React.ReactNode;
8
9
  /** Classes applied to root element of dropdown item */
9
10
  className?: string;
10
11
  /** Description of the dropdown item */
11
12
  description?: React.ReactNode;
13
+ /** Value to overwrite the randomly generated data-ouia-component-id.*/
14
+ ouiaId?: number | string;
15
+ /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
16
+ ouiaSafe?: boolean;
12
17
  }
13
18
 
14
19
  export const DropdownItem: React.FunctionComponent<MenuItemProps> = ({
15
20
  children,
16
21
  className,
17
22
  description,
23
+ ouiaId,
24
+ ouiaSafe,
18
25
  ...props
19
- }: DropdownItemProps) => (
20
- <MenuItem className={css(className)} description={description} {...props}>
21
- {children}
22
- </MenuItem>
23
- );
26
+ }: DropdownItemProps) => {
27
+ const ouiaProps = useOUIAProps(DropdownItem.displayName, ouiaId, ouiaSafe);
28
+ return (
29
+ <MenuItem className={css(className)} description={description} {...ouiaProps} {...props}>
30
+ {children}
31
+ </MenuItem>
32
+ );
33
+ };
24
34
  DropdownItem.displayName = 'DropdownItem';