@patternfly/react-core 4.248.0 → 4.250.0

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 (228) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/esm/components/Icon/Icon.d.ts +25 -0
  3. package/dist/esm/components/Icon/Icon.d.ts.map +1 -0
  4. package/dist/esm/components/Icon/Icon.js +14 -0
  5. package/dist/esm/components/Icon/Icon.js.map +1 -0
  6. package/dist/esm/components/Icon/index.d.ts +2 -0
  7. package/dist/esm/components/Icon/index.d.ts.map +1 -0
  8. package/dist/esm/components/Icon/index.js +2 -0
  9. package/dist/esm/components/Icon/index.js.map +1 -0
  10. package/dist/esm/components/index.d.ts +1 -0
  11. package/dist/esm/components/index.d.ts.map +1 -1
  12. package/dist/esm/components/index.js +1 -0
  13. package/dist/esm/components/index.js.map +1 -1
  14. package/dist/esm/next/components/Select/Select.d.ts +28 -0
  15. package/dist/esm/next/components/Select/Select.d.ts.map +1 -0
  16. package/dist/esm/next/components/Select/Select.js +62 -0
  17. package/dist/esm/next/components/Select/Select.js.map +1 -0
  18. package/dist/esm/next/components/Select/SelectGroup.d.ts +12 -0
  19. package/dist/esm/next/components/Select/SelectGroup.d.ts.map +1 -0
  20. package/dist/esm/next/components/Select/SelectGroup.js +10 -0
  21. package/dist/esm/next/components/Select/SelectGroup.js.map +1 -0
  22. package/dist/esm/next/components/Select/SelectList.d.ts +10 -0
  23. package/dist/esm/next/components/Select/SelectList.d.ts.map +1 -0
  24. package/dist/esm/next/components/Select/SelectList.js +10 -0
  25. package/dist/esm/next/components/Select/SelectList.js.map +1 -0
  26. package/dist/esm/next/components/Select/SelectOption.d.ts +20 -0
  27. package/dist/esm/next/components/Select/SelectOption.d.ts.map +1 -0
  28. package/dist/esm/next/components/Select/SelectOption.js +10 -0
  29. package/dist/esm/next/components/Select/SelectOption.js.map +1 -0
  30. package/dist/esm/next/components/Select/index.d.ts +5 -0
  31. package/dist/esm/next/components/Select/index.d.ts.map +1 -0
  32. package/dist/esm/next/components/Select/index.js +5 -0
  33. package/dist/esm/next/components/Select/index.js.map +1 -0
  34. package/dist/esm/next/components/Wizard/Wizard.d.ts +9 -7
  35. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
  36. package/dist/esm/next/components/Wizard/Wizard.js +62 -48
  37. package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
  38. package/dist/esm/next/components/Wizard/WizardBody.d.ts +2 -2
  39. package/dist/esm/next/components/Wizard/WizardBody.d.ts.map +1 -1
  40. package/dist/esm/next/components/Wizard/WizardBody.js +1 -1
  41. package/dist/esm/next/components/Wizard/WizardBody.js.map +1 -1
  42. package/dist/esm/next/components/Wizard/WizardContext.d.ts +21 -20
  43. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
  44. package/dist/esm/next/components/Wizard/WizardContext.js +63 -32
  45. package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
  46. package/dist/esm/next/components/Wizard/WizardFooter.d.ts +20 -6
  47. package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  48. package/dist/esm/next/components/Wizard/WizardFooter.js +13 -4
  49. package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -1
  50. package/dist/esm/next/components/Wizard/WizardHeader.d.ts +1 -1
  51. package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  52. package/dist/esm/next/components/Wizard/WizardHeader.js +2 -2
  53. package/dist/esm/next/components/Wizard/WizardHeader.js.map +1 -1
  54. package/dist/esm/next/components/Wizard/WizardNav.d.ts +5 -5
  55. package/dist/esm/next/components/Wizard/WizardNav.d.ts.map +1 -1
  56. package/dist/esm/next/components/Wizard/WizardNav.js +3 -4
  57. package/dist/esm/next/components/Wizard/WizardNav.js.map +1 -1
  58. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts +14 -0
  59. package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts.map +1 -0
  60. package/dist/esm/next/components/Wizard/WizardNavInternal.js +49 -0
  61. package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -0
  62. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +12 -8
  63. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  64. package/dist/esm/next/components/Wizard/WizardNavItem.js +23 -12
  65. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
  66. package/dist/esm/next/components/Wizard/WizardStep.d.ts +22 -6
  67. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
  68. package/dist/esm/next/components/Wizard/WizardStep.js +20 -1
  69. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
  70. package/dist/esm/next/components/Wizard/WizardToggle.d.ts +9 -15
  71. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  72. package/dist/esm/next/components/Wizard/WizardToggle.js +15 -50
  73. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
  74. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -2
  75. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
  76. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js +3 -3
  77. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
  78. package/dist/esm/next/components/Wizard/types.d.ts +37 -46
  79. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
  80. package/dist/esm/next/components/Wizard/types.js +10 -2
  81. package/dist/esm/next/components/Wizard/types.js.map +1 -1
  82. package/dist/esm/next/components/Wizard/utils.d.ts +4 -5
  83. package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
  84. package/dist/esm/next/components/Wizard/utils.js +20 -13
  85. package/dist/esm/next/components/Wizard/utils.js.map +1 -1
  86. package/dist/esm/next/components/index.d.ts +2 -1
  87. package/dist/esm/next/components/index.d.ts.map +1 -1
  88. package/dist/esm/next/components/index.js +2 -1
  89. package/dist/esm/next/components/index.js.map +1 -1
  90. package/dist/js/components/Icon/Icon.d.ts +25 -0
  91. package/dist/js/components/Icon/Icon.d.ts.map +1 -0
  92. package/dist/js/components/Icon/Icon.js +18 -0
  93. package/dist/js/components/Icon/Icon.js.map +1 -0
  94. package/dist/js/components/Icon/index.d.ts +2 -0
  95. package/dist/js/components/Icon/index.d.ts.map +1 -0
  96. package/dist/js/components/Icon/index.js +5 -0
  97. package/dist/js/components/Icon/index.js.map +1 -0
  98. package/dist/js/components/index.d.ts +1 -0
  99. package/dist/js/components/index.d.ts.map +1 -1
  100. package/dist/js/components/index.js +1 -0
  101. package/dist/js/components/index.js.map +1 -1
  102. package/dist/js/next/components/Select/Select.d.ts +28 -0
  103. package/dist/js/next/components/Select/Select.d.ts.map +1 -0
  104. package/dist/js/next/components/Select/Select.js +65 -0
  105. package/dist/js/next/components/Select/Select.js.map +1 -0
  106. package/dist/js/next/components/Select/SelectGroup.d.ts +12 -0
  107. package/dist/js/next/components/Select/SelectGroup.d.ts.map +1 -0
  108. package/dist/js/next/components/Select/SelectGroup.js +14 -0
  109. package/dist/js/next/components/Select/SelectGroup.js.map +1 -0
  110. package/dist/js/next/components/Select/SelectList.d.ts +10 -0
  111. package/dist/js/next/components/Select/SelectList.d.ts.map +1 -0
  112. package/dist/js/next/components/Select/SelectList.js +14 -0
  113. package/dist/js/next/components/Select/SelectList.js.map +1 -0
  114. package/dist/js/next/components/Select/SelectOption.d.ts +20 -0
  115. package/dist/js/next/components/Select/SelectOption.d.ts.map +1 -0
  116. package/dist/js/next/components/Select/SelectOption.js +14 -0
  117. package/dist/js/next/components/Select/SelectOption.js.map +1 -0
  118. package/dist/js/next/components/Select/index.d.ts +5 -0
  119. package/dist/js/next/components/Select/index.d.ts.map +1 -0
  120. package/dist/js/next/components/Select/index.js +8 -0
  121. package/dist/js/next/components/Select/index.js.map +1 -0
  122. package/dist/js/next/components/Wizard/Wizard.d.ts +9 -7
  123. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
  124. package/dist/js/next/components/Wizard/Wizard.js +59 -45
  125. package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
  126. package/dist/js/next/components/Wizard/WizardBody.d.ts +2 -2
  127. package/dist/js/next/components/Wizard/WizardBody.d.ts.map +1 -1
  128. package/dist/js/next/components/Wizard/WizardBody.js +1 -1
  129. package/dist/js/next/components/Wizard/WizardBody.js.map +1 -1
  130. package/dist/js/next/components/Wizard/WizardContext.d.ts +21 -20
  131. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
  132. package/dist/js/next/components/Wizard/WizardContext.js +61 -30
  133. package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
  134. package/dist/js/next/components/Wizard/WizardFooter.d.ts +20 -6
  135. package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  136. package/dist/js/next/components/Wizard/WizardFooter.js +15 -6
  137. package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -1
  138. package/dist/js/next/components/Wizard/WizardHeader.d.ts +1 -1
  139. package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -1
  140. package/dist/js/next/components/Wizard/WizardHeader.js +2 -2
  141. package/dist/js/next/components/Wizard/WizardHeader.js.map +1 -1
  142. package/dist/js/next/components/Wizard/WizardNav.d.ts +5 -5
  143. package/dist/js/next/components/Wizard/WizardNav.d.ts.map +1 -1
  144. package/dist/js/next/components/Wizard/WizardNav.js +3 -4
  145. package/dist/js/next/components/Wizard/WizardNav.js.map +1 -1
  146. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts +14 -0
  147. package/dist/js/next/components/Wizard/WizardNavInternal.d.ts.map +1 -0
  148. package/dist/js/next/components/Wizard/WizardNavInternal.js +54 -0
  149. package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -0
  150. package/dist/js/next/components/Wizard/WizardNavItem.d.ts +12 -8
  151. package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  152. package/dist/js/next/components/Wizard/WizardNavItem.js +23 -12
  153. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
  154. package/dist/js/next/components/Wizard/WizardStep.d.ts +22 -6
  155. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
  156. package/dist/js/next/components/Wizard/WizardStep.js +20 -1
  157. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
  158. package/dist/js/next/components/Wizard/WizardToggle.d.ts +9 -15
  159. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  160. package/dist/js/next/components/Wizard/WizardToggle.js +15 -51
  161. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
  162. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -2
  163. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
  164. package/dist/js/next/components/Wizard/hooks/useWizardFooter.js +3 -3
  165. package/dist/js/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
  166. package/dist/js/next/components/Wizard/types.d.ts +37 -46
  167. package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
  168. package/dist/js/next/components/Wizard/types.js +12 -3
  169. package/dist/js/next/components/Wizard/types.js.map +1 -1
  170. package/dist/js/next/components/Wizard/utils.d.ts +4 -5
  171. package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
  172. package/dist/js/next/components/Wizard/utils.js +24 -15
  173. package/dist/js/next/components/Wizard/utils.js.map +1 -1
  174. package/dist/js/next/components/index.d.ts +2 -1
  175. package/dist/js/next/components/index.d.ts.map +1 -1
  176. package/dist/js/next/components/index.js +2 -1
  177. package/dist/js/next/components/index.js.map +1 -1
  178. package/dist/umd/react-core.min.css +337 -200
  179. package/dist/umd/react-core.min.js +1 -1
  180. package/package.json +2 -2
  181. package/src/components/Icon/Icon.tsx +66 -0
  182. package/src/components/Icon/__tests__/Icon.test.tsx +196 -0
  183. package/src/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +82 -0
  184. package/src/components/Icon/examples/Icon.md +61 -0
  185. package/src/components/Icon/examples/IconBasic.tsx +23 -0
  186. package/src/components/Icon/examples/IconContentSizes.tsx +20 -0
  187. package/src/components/Icon/examples/IconCustomProgress.tsx +24 -0
  188. package/src/components/Icon/examples/IconInline.tsx +62 -0
  189. package/src/components/Icon/examples/IconProgress.tsx +24 -0
  190. package/src/components/Icon/examples/IconSizes.tsx +20 -0
  191. package/src/components/Icon/examples/IconStatus.tsx +27 -0
  192. package/src/components/Icon/index.ts +1 -0
  193. package/src/components/index.ts +1 -0
  194. package/src/next/components/Select/Select.tsx +129 -0
  195. package/src/next/components/Select/SelectGroup.tsx +24 -0
  196. package/src/next/components/Select/SelectList.tsx +21 -0
  197. package/src/next/components/Select/SelectOption.tsx +31 -0
  198. package/src/next/components/Select/examples/Select.md +37 -0
  199. package/src/next/components/Select/examples/SelectBasic.tsx +54 -0
  200. package/src/next/components/Select/examples/SelectCheckbox.tsx +67 -0
  201. package/src/next/components/Select/examples/SelectGrouped.tsx +63 -0
  202. package/src/next/components/Select/examples/SelectMultiTypeahead.tsx +195 -0
  203. package/src/next/components/Select/examples/SelectTypeahead.tsx +191 -0
  204. package/src/next/components/Select/index.ts +4 -0
  205. package/src/next/components/Wizard/Wizard.tsx +107 -64
  206. package/src/next/components/Wizard/WizardBody.tsx +4 -4
  207. package/src/next/components/Wizard/WizardContext.tsx +117 -65
  208. package/src/next/components/Wizard/WizardFooter.tsx +39 -17
  209. package/src/next/components/Wizard/WizardHeader.tsx +6 -3
  210. package/src/next/components/Wizard/WizardNav.tsx +9 -10
  211. package/src/next/components/Wizard/WizardNavInternal.tsx +137 -0
  212. package/src/next/components/Wizard/WizardNavItem.tsx +47 -20
  213. package/src/next/components/Wizard/WizardStep.tsx +52 -7
  214. package/src/next/components/Wizard/WizardToggle.tsx +24 -142
  215. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +10 -13
  216. package/src/next/components/Wizard/__tests__/WizardBody.test.tsx +3 -3
  217. package/src/next/components/Wizard/__tests__/WizardFooter.test.tsx +11 -14
  218. package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +100 -0
  219. package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +4 -4
  220. package/src/next/components/Wizard/examples/Wizard.md +40 -15
  221. package/src/next/components/Wizard/examples/WizardBasic.tsx +2 -2
  222. package/src/next/components/Wizard/examples/WizardCustomNav.tsx +4 -4
  223. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +126 -60
  224. package/src/next/components/Wizard/hooks/__tests__/useWizardFooter.test.tsx +23 -34
  225. package/src/next/components/Wizard/hooks/useWizardFooter.tsx +5 -5
  226. package/src/next/components/Wizard/types.tsx +59 -53
  227. package/src/next/components/Wizard/utils.ts +25 -16
  228. package/src/next/components/index.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.248.0",
3
+ "version": "4.250.0",
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": "3e99a769dc61cb0c1506c3f2e6a868541a62d0cc"
73
+ "gitHead": "50c13d9abd3516bedbf2dbef4390784ef25cf035"
74
74
  }
@@ -0,0 +1,66 @@
1
+ import * as React from 'react';
2
+ import styles from '@patternfly/react-styles/css/components/Icon/icon';
3
+ import { css } from '@patternfly/react-styles';
4
+ import { Spinner } from '../Spinner';
5
+
6
+ export interface IconComponentProps extends Omit<React.HTMLProps<HTMLSpanElement>, 'size'> {
7
+ /** Icon content */
8
+ children?: React.ReactNode;
9
+ /** Icon when isInProgress is set to true. Defaults to a 1em spinner. */
10
+ progressIcon?: React.ReactNode;
11
+ /** Additional classes applied to the icon container */
12
+ className?: string;
13
+ /** Size of the icon component container and icon. */
14
+ size?: 'sm' | 'md' | 'lg' | 'xl';
15
+ /** Size of icon. Overrides the icon size set by the size property. */
16
+ iconSize?: 'sm' | 'md' | 'lg' | 'xl';
17
+ /** Size of progress icon. Overrides the icon size set by the size property. */
18
+ progressIconSize?: 'sm' | 'md' | 'lg' | 'xl';
19
+ /** Status color of the icon */
20
+ status?: 'default' | 'info' | 'success' | 'warning' | 'danger';
21
+ /** Indicates the icon is inline and should inherit the text font size and color. Overriden by size and iconSize properties. */
22
+ isInline?: boolean;
23
+ /** Indicates the icon is in progress. Setting this property to true will swap the icon with the progressIcon. */
24
+ isInProgress?: boolean;
25
+ /** Aria-label for the default progress icon */
26
+ defaultProgressArialabel?: string;
27
+ }
28
+
29
+ export const Icon: React.FunctionComponent<IconComponentProps> = ({
30
+ children,
31
+ className,
32
+ progressIcon,
33
+ size,
34
+ iconSize,
35
+ progressIconSize,
36
+ status,
37
+ isInline = false,
38
+ isInProgress = false,
39
+ defaultProgressArialabel = 'Loading...',
40
+ ...props
41
+ }: IconComponentProps) => {
42
+ const _progressIcon = progressIcon ? (
43
+ progressIcon
44
+ ) : (
45
+ <Spinner diameter="1em" isSVG aria-label={defaultProgressArialabel} />
46
+ );
47
+
48
+ return (
49
+ <span
50
+ className={css(
51
+ styles.icon,
52
+ isInline && styles.modifiers.inline,
53
+ isInProgress && styles.modifiers.inProgress,
54
+ styles.modifiers[size],
55
+ className
56
+ )}
57
+ {...props}
58
+ >
59
+ <span className={css(styles.iconContent, styles.modifiers[iconSize], styles.modifiers[status])}>{children}</span>
60
+ {isInProgress && (
61
+ <span className={css(styles.iconProgress, styles.modifiers[progressIconSize], className)}>{_progressIcon}</span>
62
+ )}
63
+ </span>
64
+ );
65
+ };
66
+ Icon.displayName = 'Icon';
@@ -0,0 +1,196 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { Icon } from '../Icon';
4
+ import { CheckIcon } from '@patternfly/react-icons';
5
+
6
+ test('renders basic icon successfully', () => {
7
+ const { asFragment } = render(
8
+ <Icon>
9
+ <CheckIcon />
10
+ </Icon>
11
+ );
12
+ expect(asFragment()).toMatchSnapshot();
13
+ });
14
+
15
+ test('checks basic icon structure', () => {
16
+ const { asFragment } = render(
17
+ <Icon title="icon">
18
+ <CheckIcon />
19
+ </Icon>
20
+ );
21
+ const iconContainer = screen.getByTitle('icon');
22
+ expect(iconContainer).toHaveClass('pf-c-icon');
23
+ const iconContent = iconContainer.querySelector('.pf-c-icon__content');
24
+ expect(iconContent).toHaveClass('pf-c-icon__content');
25
+ });
26
+
27
+ test('renders without children', () => {
28
+ const { asFragment } = render(<Icon></Icon>);
29
+ expect(asFragment()).toMatchSnapshot();
30
+ });
31
+
32
+ test('sets additional custom class successfully', () => {
33
+ render(
34
+ <Icon className="test" title="custom-icon">
35
+ <CheckIcon />
36
+ </Icon>
37
+ );
38
+ const iconContainer = screen.getByTitle('custom-icon');
39
+
40
+ expect(iconContainer).toHaveClass('test');
41
+ });
42
+
43
+ Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
44
+ test(`sets icon size modifier successfully - ${size}`, () => {
45
+ render(
46
+ <Icon iconSize={size as 'sm' | 'md' | 'lg' | 'xl'} title={`content-${size}-icon`}>
47
+ <CheckIcon />
48
+ </Icon>
49
+ );
50
+ const iconContainer = screen.getByTitle(`content-${size}-icon`).querySelector('.pf-c-icon__content');
51
+
52
+ expect(iconContainer).toHaveClass(`pf-m-${size}`);
53
+ });
54
+ });
55
+
56
+ test('check icon without iconSize', () => {
57
+ render(
58
+ <Icon title="no-icon-size">
59
+ <CheckIcon />
60
+ </Icon>
61
+ );
62
+ const iconContainer = screen.getByTitle('no-icon-size').querySelector('.pf-c-icon__content');
63
+ expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
64
+ });
65
+
66
+ Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
67
+ test(`sets progress icon size modifier successfully - ${size}`, () => {
68
+ render(
69
+ <Icon isInProgress progressIconSize={size as 'sm' | 'md' | 'lg' | 'xl'} title={`progress-content-${size}-icon`}>
70
+ <CheckIcon />
71
+ </Icon>
72
+ );
73
+ const iconContainer = screen.getByTitle(`progress-content-${size}-icon`).querySelector('.pf-c-icon__progress');
74
+
75
+ expect(iconContainer).toHaveClass(`pf-m-${size}`);
76
+ });
77
+ });
78
+
79
+ test('check icon without progress icon size', () => {
80
+ render(
81
+ <Icon title="no-progress-icon-size">
82
+ <CheckIcon />
83
+ </Icon>
84
+ );
85
+ const iconContainer = screen.getByTitle('no-progress-icon-size').querySelector('.pf-c-icon__progress');
86
+ expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
87
+ });
88
+
89
+ Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
90
+ test(`sets size modifier successfully - ${size}`, () => {
91
+ render(
92
+ <Icon size={size as 'sm' | 'md' | 'lg' | 'xl'} title={`${size}-icon`}>
93
+ <CheckIcon />
94
+ </Icon>
95
+ );
96
+ const iconContainer = screen.getByTitle(`${size}-icon`);
97
+
98
+ expect(iconContainer).toHaveClass(`pf-m-${size}`);
99
+ });
100
+ });
101
+
102
+ test('check icon without size', () => {
103
+ render(
104
+ <Icon title="no-size">
105
+ <CheckIcon />
106
+ </Icon>
107
+ );
108
+ const iconContainer = screen.getByTitle('no-size');
109
+ expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
110
+ });
111
+
112
+ Object.values(['default', 'info', 'success', 'warning', 'danger']).forEach(status => {
113
+ test(`sets status modifier successfully - ${status}`, () => {
114
+ render(
115
+ <Icon status={status as 'default' | 'info' | 'success' | 'warning' | 'danger'} title={`${status}-icon`}>
116
+ <CheckIcon />
117
+ </Icon>
118
+ );
119
+ const iconContent = screen.getByTitle(`${status}-icon`).querySelector('.pf-c-icon__content');
120
+
121
+ expect(iconContent).toHaveClass(`pf-m-${status}`);
122
+ });
123
+ });
124
+
125
+ test('check icon without status', () => {
126
+ render(
127
+ <Icon title="no-status">
128
+ <CheckIcon />
129
+ </Icon>
130
+ );
131
+ const iconContent = screen.getByTitle('no-status').querySelector('.pf-c-icon__content');
132
+ expect(Array.from(iconContent?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
133
+ });
134
+
135
+ test('sets isInline successfully', () => {
136
+ render(
137
+ <Icon isInline title="inline-icon">
138
+ <CheckIcon />
139
+ </Icon>
140
+ );
141
+ const iconContainer = screen.getByTitle('inline-icon');
142
+
143
+ expect(iconContainer).toHaveClass('pf-m-inline');
144
+ });
145
+
146
+ test('check icon without isInline', () => {
147
+ render(
148
+ <Icon title="no-inline">
149
+ <CheckIcon />
150
+ </Icon>
151
+ );
152
+ const iconContainer = screen.getByTitle('no-inline');
153
+ expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
154
+ });
155
+
156
+ test('sets isInProgress successfully', () => {
157
+ render(
158
+ <Icon isInProgress title="progress-icon">
159
+ <CheckIcon />
160
+ </Icon>
161
+ );
162
+ const iconContainer = screen.getByTitle('progress-icon');
163
+ expect(iconContainer).toHaveClass('pf-m-in-progress');
164
+
165
+ const iconContent = iconContainer.querySelector('.pf-c-icon__progress');
166
+ expect(iconContent).toHaveClass('pf-c-icon__progress');
167
+ });
168
+
169
+ test('check icon without isInProgress', () => {
170
+ render(
171
+ <Icon title="no-in-progress">
172
+ <CheckIcon />
173
+ </Icon>
174
+ );
175
+ const iconContainer = screen.getByTitle('no-in-progress');
176
+ expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
177
+ });
178
+
179
+ test('sets default progres aria-label successfully', () => {
180
+ render(
181
+ <Icon isInProgress defaultProgressArialabel="test" title="progress-icon">
182
+ <CheckIcon />
183
+ </Icon>
184
+ );
185
+
186
+ expect(screen.getByLabelText('test'));
187
+ });
188
+
189
+ test('renders progress icon successfully', () => {
190
+ const { asFragment } = render(
191
+ <Icon isInProgress progressIcon={<CheckIcon />}>
192
+ <CheckIcon />
193
+ </Icon>
194
+ );
195
+ expect(asFragment()).toMatchSnapshot();
196
+ });
@@ -0,0 +1,82 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders basic icon successfully 1`] = `
4
+ <DocumentFragment>
5
+ <span
6
+ class="pf-c-icon"
7
+ >
8
+ <span
9
+ class="pf-c-icon__content"
10
+ >
11
+ <svg
12
+ aria-hidden="true"
13
+ fill="currentColor"
14
+ height="1em"
15
+ role="img"
16
+ style="vertical-align: -0.125em;"
17
+ viewBox="0 0 512 512"
18
+ width="1em"
19
+ >
20
+ <path
21
+ d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
22
+ />
23
+ </svg>
24
+ </span>
25
+ </span>
26
+ </DocumentFragment>
27
+ `;
28
+
29
+ exports[`renders progress icon successfully 1`] = `
30
+ <DocumentFragment>
31
+ <span
32
+ class="pf-c-icon pf-m-in-progress"
33
+ >
34
+ <span
35
+ class="pf-c-icon__content"
36
+ >
37
+ <svg
38
+ aria-hidden="true"
39
+ fill="currentColor"
40
+ height="1em"
41
+ role="img"
42
+ style="vertical-align: -0.125em;"
43
+ viewBox="0 0 512 512"
44
+ width="1em"
45
+ >
46
+ <path
47
+ d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
48
+ />
49
+ </svg>
50
+ </span>
51
+ <span
52
+ class="pf-c-icon__progress"
53
+ >
54
+ <svg
55
+ aria-hidden="true"
56
+ fill="currentColor"
57
+ height="1em"
58
+ role="img"
59
+ style="vertical-align: -0.125em;"
60
+ viewBox="0 0 512 512"
61
+ width="1em"
62
+ >
63
+ <path
64
+ d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
65
+ />
66
+ </svg>
67
+ </span>
68
+ </span>
69
+ </DocumentFragment>
70
+ `;
71
+
72
+ exports[`renders without children 1`] = `
73
+ <DocumentFragment>
74
+ <span
75
+ class="pf-c-icon"
76
+ >
77
+ <span
78
+ class="pf-c-icon__content"
79
+ />
80
+ </span>
81
+ </DocumentFragment>
82
+ `;
@@ -0,0 +1,61 @@
1
+ ---
2
+ id: Icon
3
+ section: components
4
+ cssPrefix: pf-c-icon
5
+ propComponents: ['Icon']
6
+ beta: true
7
+ ---
8
+
9
+ import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
10
+ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
11
+ import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
12
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
13
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
14
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
15
+ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
16
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
17
+ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
18
+ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
19
+
20
+ ## Examples
21
+
22
+ ### Basic
23
+
24
+ ```ts file="IconBasic.tsx"
25
+ ```
26
+
27
+ ### Sizes
28
+
29
+ ```ts file="IconSizes.tsx"
30
+ ```
31
+
32
+ ### Status colors
33
+
34
+ The following example demonstrates the various status variants of an icon. Keep in mind that these icons are displayed out of a typical context, and that you should not rely on color alone to convey status to users.
35
+
36
+ ```ts file="IconStatus.tsx"
37
+ ```
38
+
39
+ ### Sizing an icon within the icon container
40
+
41
+ Providing both size and iconSize properties allows the icon container to maintain a consistent size, even if the icon changes in size.
42
+
43
+ ```ts file="IconContentSizes.tsx"
44
+ ```
45
+
46
+ ### Inline
47
+
48
+ ```ts file="IconInline.tsx"
49
+ ```
50
+
51
+ ### In progress
52
+
53
+ Passing the `isInProgress` property will swap the icon to a progress icon. By default this progress icon will be a `Spinner` but may be customized or overriden using the `progressIcon` property.
54
+
55
+ ```ts file="IconProgress.tsx"
56
+ ```
57
+
58
+ ### Custom in progress icon
59
+
60
+ ```ts file="IconCustomProgress.tsx"
61
+ ```
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Icon } from '@patternfly/react-core';
3
+ import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
4
+ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
5
+ import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
6
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
7
+
8
+ export const IconBasic: React.FunctionComponent = () => (
9
+ <React.Fragment>
10
+ <Icon>
11
+ <LongArrowAltDownIcon />
12
+ </Icon>
13
+ <Icon>
14
+ <AngleRightIcon />
15
+ </Icon>
16
+ <Icon>
17
+ <AngleDownIcon />
18
+ </Icon>
19
+ <Icon>
20
+ <CogIcon />
21
+ </Icon>
22
+ </React.Fragment>
23
+ );
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Icon } from '@patternfly/react-core';
3
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
4
+
5
+ export const IconContentSizes: React.FunctionComponent = () => (
6
+ <React.Fragment>
7
+ <Icon size="xl" iconSize="sm">
8
+ <PlusCircleIcon />
9
+ </Icon>
10
+ <Icon size="xl" iconSize="md">
11
+ <PlusCircleIcon />
12
+ </Icon>
13
+ <Icon size="xl" iconSize="lg">
14
+ <PlusCircleIcon />
15
+ </Icon>
16
+ <Icon size="xl">
17
+ <PlusCircleIcon />
18
+ </Icon>
19
+ </React.Fragment>
20
+ );
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Icon, Spinner, Checkbox } from '@patternfly/react-core';
3
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
4
+
5
+ export const IconProgress: React.FunctionComponent = () => {
6
+ const [isInProgress, setIsInProgress] = React.useState<boolean>(false);
7
+ return (
8
+ <React.Fragment>
9
+ <div style={{ marginBottom: '12px' }}>
10
+ <Checkbox
11
+ label="Toggle in progress state"
12
+ isChecked={isInProgress}
13
+ onChange={checked => setIsInProgress(checked)}
14
+ aria-label="Set icon progress state"
15
+ id="toggle-icon-progress-custom"
16
+ name="toggle-icon-progress-custom"
17
+ />
18
+ </div>
19
+ <Icon isInProgress={isInProgress} progressIcon={<Spinner diameter="2em" isSVG aria-label="Loading..." />}>
20
+ <CheckCircleIcon />
21
+ </Icon>
22
+ </React.Fragment>
23
+ );
24
+ };
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { Icon, Text, TextContent } from '@patternfly/react-core';
3
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
4
+
5
+ export const IconInline: React.FunctionComponent = () => (
6
+ <React.Fragment>
7
+ <TextContent>
8
+ <Text component="h1">
9
+ Heading
10
+ <Icon isInline>
11
+ <PlusCircleIcon />
12
+ </Icon>
13
+ </Text>
14
+ <Text component="p">
15
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit Sed hendrerit nisi in cursus maximus.
16
+ </Text>
17
+ <Text component="h2">
18
+ Second level
19
+ <Icon isInline>
20
+ <PlusCircleIcon />
21
+ </Icon>
22
+ </Text>
23
+ <Text component="p">
24
+ <Icon isInline>
25
+ <PlusCircleIcon />
26
+ </Icon>
27
+ Curabitur accumsan turpis pharetra
28
+ <strong>
29
+ augue tincidunt
30
+ <Icon isInline>
31
+ <PlusCircleIcon />
32
+ </Icon>
33
+ </strong>
34
+ blandit. Quisque condimentum maximus mi, sit amet commodo arcu rutrum id. Proin pretium urna vel cursus
35
+ venenatis. Suspendisse potenti.
36
+ </Text>
37
+ <small>
38
+ Sometimes you need small text
39
+ <Icon isInline>
40
+ <PlusCircleIcon />
41
+ </Icon>
42
+ </small>
43
+ Inline with size specified:
44
+ <Icon size="sm" isInline>
45
+ <PlusCircleIcon />
46
+ </Icon>
47
+ small,
48
+ <Icon size="md" isInline>
49
+ <PlusCircleIcon />
50
+ </Icon>
51
+ medium,
52
+ <Icon size="lg" isInline>
53
+ <PlusCircleIcon />
54
+ </Icon>
55
+ large,
56
+ <Icon size="xl" isInline>
57
+ <PlusCircleIcon />
58
+ </Icon>
59
+ extra large
60
+ </TextContent>
61
+ </React.Fragment>
62
+ );
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Icon, Checkbox } from '@patternfly/react-core';
3
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
4
+
5
+ export const IconProgress: React.FunctionComponent = () => {
6
+ const [isInProgress, setIsInProgress] = React.useState<boolean>(false);
7
+ return (
8
+ <React.Fragment>
9
+ <div style={{ marginBottom: '12px' }}>
10
+ <Checkbox
11
+ label="Toggle in progress state"
12
+ isChecked={isInProgress}
13
+ onChange={checked => setIsInProgress(checked)}
14
+ aria-label="Set icon progress state"
15
+ id="toggle-icon-progress"
16
+ name="toggle-icon-progress"
17
+ />
18
+ </div>
19
+ <Icon isInProgress={isInProgress}>
20
+ <CheckCircleIcon />
21
+ </Icon>
22
+ </React.Fragment>
23
+ );
24
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Icon } from '@patternfly/react-core';
3
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
4
+
5
+ export const IconSizes: React.FunctionComponent = () => (
6
+ <React.Fragment>
7
+ <Icon size="sm">
8
+ <PlusCircleIcon />
9
+ </Icon>
10
+ <Icon size="md">
11
+ <PlusCircleIcon />
12
+ </Icon>
13
+ <Icon size="lg">
14
+ <PlusCircleIcon />
15
+ </Icon>
16
+ <Icon size="xl">
17
+ <PlusCircleIcon />
18
+ </Icon>
19
+ </React.Fragment>
20
+ );
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { Icon } from '@patternfly/react-core';
3
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
4
+ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
5
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
6
+ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
7
+ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
8
+
9
+ export const IconStatus: React.FunctionComponent = () => (
10
+ <React.Fragment>
11
+ <Icon status="danger">
12
+ <ExclamationCircleIcon />
13
+ </Icon>
14
+ <Icon status="warning">
15
+ <ExclamationTriangleIcon />
16
+ </Icon>
17
+ <Icon status="success">
18
+ <CheckCircleIcon />
19
+ </Icon>
20
+ <Icon status="info">
21
+ <InfoCircleIcon />
22
+ </Icon>
23
+ <Icon status="default">
24
+ <BellIcon />
25
+ </Icon>
26
+ </React.Fragment>
27
+ );
@@ -0,0 +1 @@
1
+ export * from './Icon';
@@ -36,6 +36,7 @@ export * from './Form';
36
36
  export * from './FormSelect';
37
37
  export * from './HelperText';
38
38
  export * from './Hint';
39
+ export * from './Icon';
39
40
  export * from './InputGroup';
40
41
  export * from './JumpLinks';
41
42
  export * from './Label';