@patternfly/quickstarts 6.3.0-prerelease.2 → 6.3.0-prerelease.4

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 (133) hide show
  1. package/dist/ConsoleInternal/components/markdown-view.d.ts +2 -2
  2. package/dist/ConsoleInternal/components/utils/camel-case-wrap.d.ts +1 -1
  3. package/dist/ConsoleInternal/components/utils/status-box.d.ts +3 -3
  4. package/dist/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.d.ts +3 -3
  5. package/dist/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.d.ts +2 -2
  6. package/dist/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.d.ts +2 -2
  7. package/dist/ConsoleShared/src/components/modal/Modal.d.ts +3 -3
  8. package/dist/ConsoleShared/src/components/popper/Portal.d.ts +3 -3
  9. package/dist/ConsoleShared/src/components/popper/SimplePopper.d.ts +3 -3
  10. package/dist/ConsoleShared/src/components/spotlight/InteractiveSpotlight.d.ts +3 -2
  11. package/dist/ConsoleShared/src/components/spotlight/Spotlight.d.ts +2 -2
  12. package/dist/ConsoleShared/src/components/spotlight/StaticSpotlight.d.ts +3 -2
  13. package/dist/ConsoleShared/src/components/status/GenericStatus.d.ts +4 -4
  14. package/dist/ConsoleShared/src/components/status/NotStartedIcon.d.ts +1 -2
  15. package/dist/ConsoleShared/src/components/status/PopoverStatus.d.ts +4 -4
  16. package/dist/ConsoleShared/src/components/status/Status.d.ts +3 -3
  17. package/dist/ConsoleShared/src/components/status/StatusIconAndText.d.ts +3 -3
  18. package/dist/ConsoleShared/src/components/status/icons.d.ts +4 -4
  19. package/dist/ConsoleShared/src/components/status/statuses.d.ts +4 -4
  20. package/dist/ConsoleShared/src/components/utils/FallbackImg.d.ts +3 -3
  21. package/dist/ConsoleShared/src/utils/useCombineRefs.d.ts +2 -2
  22. package/dist/HelpTopicDrawer.d.ts +3 -3
  23. package/dist/HelpTopicPanelContent.d.ts +2 -2
  24. package/dist/QuickStartCatalogPage.d.ts +3 -3
  25. package/dist/QuickStartCloseModal.d.ts +2 -2
  26. package/dist/QuickStartContainer.d.ts +2 -2
  27. package/dist/QuickStartController.d.ts +2 -2
  28. package/dist/QuickStartDrawer.d.ts +2 -2
  29. package/dist/QuickStartDrawerContent.d.ts +2 -2
  30. package/dist/QuickStartMarkdownView.d.ts +2 -2
  31. package/dist/QuickStartPanelContent.d.ts +2 -2
  32. package/dist/catalog/Catalog/QuickStartCatalogHeader.d.ts +2 -2
  33. package/dist/catalog/Catalog/QuickStartCatalogSection.d.ts +2 -2
  34. package/dist/catalog/Catalog/QuickStartCatalogToolbar.d.ts +2 -2
  35. package/dist/catalog/QuickStartCatalog.d.ts +2 -2
  36. package/dist/catalog/QuickStartTile.d.ts +2 -2
  37. package/dist/catalog/QuickStartTileDescription.d.ts +2 -2
  38. package/dist/catalog/QuickStartTileFooter.d.ts +2 -2
  39. package/dist/catalog/QuickStartTileFooterExternal.d.ts +2 -2
  40. package/dist/catalog/QuickStartTileHeader.d.ts +2 -2
  41. package/dist/catalog/Toolbar/QuickStartCatalogFilter.d.ts +2 -2
  42. package/dist/catalog/Toolbar/QuickStartCatalogFilterItems.d.ts +7 -7
  43. package/dist/controller/QuickStartConclusion.d.ts +2 -2
  44. package/dist/controller/QuickStartContent.d.ts +2 -2
  45. package/dist/controller/QuickStartFooter.d.ts +2 -2
  46. package/dist/controller/QuickStartIntroduction.d.ts +2 -2
  47. package/dist/controller/QuickStartTaskHeader.d.ts +2 -2
  48. package/dist/controller/QuickStartTaskHeaderList.d.ts +2 -2
  49. package/dist/controller/QuickStartTaskReview.d.ts +2 -2
  50. package/dist/controller/QuickStartTasks.d.ts +2 -2
  51. package/dist/index.es.js +299 -459
  52. package/dist/index.es.js.map +1 -1
  53. package/dist/index.js +310 -472
  54. package/dist/index.js.map +1 -1
  55. package/dist/quickstarts-base.css +61 -0
  56. package/dist/quickstarts-full.es.js +1693 -511
  57. package/dist/quickstarts-full.es.js.map +1 -1
  58. package/dist/quickstarts.css +61 -0
  59. package/dist/quickstarts.min.css +1 -1
  60. package/dist/utils/help-topic-context.d.ts +2 -2
  61. package/dist/utils/quick-start-context.d.ts +3 -3
  62. package/package.json +3 -4
  63. package/src/ConsoleInternal/components/markdown-view.tsx +20 -18
  64. package/src/ConsoleInternal/components/utils/camel-case-wrap.tsx +3 -3
  65. package/src/ConsoleInternal/components/utils/status-box.tsx +4 -4
  66. package/src/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.tsx +8 -15
  67. package/src/ConsoleShared/src/components/markdown-extensions/__tests__/MarkdownCopyClipboard.spec.tsx +0 -1
  68. package/src/ConsoleShared/src/components/markdown-extensions/accordion-extension.tsx +2 -2
  69. package/src/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.tsx +4 -4
  70. package/src/ConsoleShared/src/components/markdown-extensions/admonition-extension.tsx +2 -2
  71. package/src/ConsoleShared/src/components/markdown-extensions/code-extension.tsx +2 -2
  72. package/src/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.tsx +3 -3
  73. package/src/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.tsx +3 -3
  74. package/src/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.tsx +5 -5
  75. package/src/ConsoleShared/src/components/modal/Modal.tsx +3 -3
  76. package/src/ConsoleShared/src/components/popper/Portal.tsx +5 -5
  77. package/src/ConsoleShared/src/components/popper/SimplePopper.tsx +15 -15
  78. package/src/ConsoleShared/src/components/spotlight/InteractiveSpotlight.tsx +6 -5
  79. package/src/ConsoleShared/src/components/spotlight/Spotlight.tsx +3 -3
  80. package/src/ConsoleShared/src/components/spotlight/StaticSpotlight.tsx +4 -3
  81. package/src/ConsoleShared/src/components/spotlight/spotlight.scss +63 -0
  82. package/src/ConsoleShared/src/components/status/GenericStatus.tsx +5 -5
  83. package/src/ConsoleShared/src/components/status/NotStartedIcon.tsx +0 -1
  84. package/src/ConsoleShared/src/components/status/PopoverStatus.tsx +4 -4
  85. package/src/ConsoleShared/src/components/status/Status.tsx +3 -11
  86. package/src/ConsoleShared/src/components/status/StatusIconAndText.tsx +6 -6
  87. package/src/ConsoleShared/src/components/status/icons.tsx +4 -8
  88. package/src/ConsoleShared/src/components/status/statuses.tsx +4 -5
  89. package/src/ConsoleShared/src/components/utils/FallbackImg.tsx +4 -4
  90. package/src/ConsoleShared/src/hooks/scroll.ts +4 -4
  91. package/src/ConsoleShared/src/hooks/useBoundingClientRect.ts +3 -3
  92. package/src/ConsoleShared/src/hooks/useForceRender.ts +2 -2
  93. package/src/ConsoleShared/src/hooks/useResizeObserver.ts +3 -6
  94. package/src/ConsoleShared/src/hooks/useScrollShadows.ts +4 -4
  95. package/src/ConsoleShared/src/utils/useCombineRefs.ts +4 -4
  96. package/src/HelpTopicDrawer.tsx +6 -6
  97. package/src/HelpTopicPanelContent.tsx +4 -4
  98. package/src/QuickStartCatalogPage.tsx +9 -9
  99. package/src/QuickStartCloseModal.tsx +3 -7
  100. package/src/QuickStartContainer.tsx +4 -4
  101. package/src/QuickStartController.tsx +11 -11
  102. package/src/QuickStartDrawer.tsx +6 -6
  103. package/src/QuickStartDrawerContent.tsx +3 -3
  104. package/src/QuickStartMarkdownView.tsx +3 -3
  105. package/src/QuickStartPanelContent.tsx +8 -8
  106. package/src/catalog/Catalog/QuickStartCatalogHeader.tsx +2 -2
  107. package/src/catalog/Catalog/QuickStartCatalogSection.tsx +2 -2
  108. package/src/catalog/Catalog/QuickStartCatalogToolbar.tsx +2 -2
  109. package/src/catalog/QuickStartCatalog.tsx +3 -3
  110. package/src/catalog/QuickStartTile.tsx +4 -4
  111. package/src/catalog/QuickStartTileDescription.tsx +4 -4
  112. package/src/catalog/QuickStartTileFooter.tsx +6 -6
  113. package/src/catalog/QuickStartTileFooterExternal.tsx +2 -5
  114. package/src/catalog/QuickStartTileHeader.tsx +2 -6
  115. package/src/catalog/Toolbar/QuickStartCatalogFilter.tsx +2 -2
  116. package/src/catalog/Toolbar/QuickStartCatalogFilterItems.tsx +16 -16
  117. package/src/catalog/__tests__/QuickStartCatalog.spec.tsx +0 -1
  118. package/src/catalog/__tests__/QuickStartTile.spec.tsx +0 -1
  119. package/src/catalog/__tests__/QuickStartTileDescription.spec.tsx +1 -2
  120. package/src/controller/QuickStartConclusion.tsx +3 -3
  121. package/src/controller/QuickStartContent.tsx +2 -2
  122. package/src/controller/QuickStartFooter.tsx +10 -11
  123. package/src/controller/QuickStartIntroduction.tsx +4 -4
  124. package/src/controller/QuickStartTaskHeader.tsx +5 -5
  125. package/src/controller/QuickStartTaskHeaderList.tsx +2 -2
  126. package/src/controller/QuickStartTaskReview.tsx +4 -4
  127. package/src/controller/QuickStartTasks.tsx +5 -5
  128. package/src/controller/__tests__/QuickStartConclusion.spec.tsx +3 -3
  129. package/src/controller/__tests__/QuickStartContent.spec.tsx +2 -2
  130. package/src/controller/__tests__/QuickStartTaskHeader.spec.tsx +2 -2
  131. package/src/controller/__tests__/QuickStartTaskReview.spec.tsx +2 -2
  132. package/src/utils/help-topic-context.tsx +7 -10
  133. package/src/utils/quick-start-context.tsx +11 -11
@@ -1,25 +1,25 @@
1
- import * as React from 'react';
1
+ import { ReactNode, useCallback, useEffect, useRef, useState } from 'react';
2
2
  import Portal from './Portal';
3
3
 
4
4
  interface SimplePopperProps {
5
- children: React.ReactNode;
5
+ children: ReactNode;
6
6
  }
7
7
 
8
8
  const SimplePopper = ({ children }: SimplePopperProps) => {
9
9
  const openProp = true;
10
- const nodeRef = React.useRef<Element>();
11
- const popperRef = React.useRef(null);
12
- const [isOpen, setOpenState] = React.useState(openProp);
10
+ const nodeRef = useRef<Element>(null);
11
+ const popperRef = useRef(null);
12
+ const [isOpen, setOpenState] = useState(openProp);
13
13
 
14
- const setOpen = React.useCallback((newOpen: boolean) => {
14
+ const setOpen = useCallback((newOpen: boolean) => {
15
15
  setOpenState(newOpen);
16
16
  }, []);
17
17
 
18
- React.useEffect(() => {
18
+ useEffect(() => {
19
19
  setOpen(openProp);
20
20
  }, [openProp, setOpen]);
21
21
 
22
- const onKeyDown = React.useCallback(
22
+ const onKeyDown = useCallback(
23
23
  (e: KeyboardEvent) => {
24
24
  if (e.keyCode === 27) {
25
25
  setOpen(false);
@@ -28,7 +28,7 @@ const SimplePopper = ({ children }: SimplePopperProps) => {
28
28
  [setOpen],
29
29
  );
30
30
 
31
- const onClickOutside = React.useCallback(
31
+ const onClickOutside = useCallback(
32
32
  (e: MouseEvent) => {
33
33
  if (!nodeRef.current || (e.target instanceof Node && !nodeRef.current.contains(e.target))) {
34
34
  setOpen(false);
@@ -37,7 +37,7 @@ const SimplePopper = ({ children }: SimplePopperProps) => {
37
37
  [setOpen],
38
38
  );
39
39
 
40
- const destroy = React.useCallback(() => {
40
+ const destroy = useCallback(() => {
41
41
  if (popperRef.current) {
42
42
  popperRef.current.destroy();
43
43
  document.removeEventListener('keydown', onKeyDown, true);
@@ -46,7 +46,7 @@ const SimplePopper = ({ children }: SimplePopperProps) => {
46
46
  }
47
47
  }, [onClickOutside, onKeyDown]);
48
48
 
49
- const initialize = React.useCallback(() => {
49
+ const initialize = useCallback(() => {
50
50
  if (!nodeRef.current || !isOpen) {
51
51
  return;
52
52
  }
@@ -54,7 +54,7 @@ const SimplePopper = ({ children }: SimplePopperProps) => {
54
54
  destroy();
55
55
  }, [isOpen, destroy]);
56
56
 
57
- const nodeRefCallback = React.useCallback(
57
+ const nodeRefCallback = useCallback(
58
58
  (node) => {
59
59
  nodeRef.current = node;
60
60
  initialize();
@@ -62,18 +62,18 @@ const SimplePopper = ({ children }: SimplePopperProps) => {
62
62
  [initialize],
63
63
  );
64
64
 
65
- React.useEffect(() => {
65
+ useEffect(() => {
66
66
  initialize();
67
67
  }, [initialize]);
68
68
 
69
- React.useEffect(
69
+ useEffect(
70
70
  () => () => {
71
71
  destroy();
72
72
  },
73
73
  [destroy],
74
74
  );
75
75
 
76
- React.useEffect(() => {
76
+ useEffect(() => {
77
77
  if (!isOpen) {
78
78
  destroy();
79
79
  }
@@ -1,4 +1,5 @@
1
- import * as React from 'react';
1
+ import './spotlight.scss';
2
+ import { CSSProperties, FC, useEffect, useState } from 'react';
2
3
  import { Portal, SimplePopper } from '../popper';
3
4
 
4
5
  interface InteractiveSpotlightProps {
@@ -15,9 +16,9 @@ const isInViewport = (elementToCheck: Element) => {
15
16
  );
16
17
  };
17
18
 
18
- const InteractiveSpotlight: React.FC<InteractiveSpotlightProps> = ({ element }) => {
19
+ const InteractiveSpotlight: FC<InteractiveSpotlightProps> = ({ element }) => {
19
20
  const { top, bottom, left, right, height, width } = element.getBoundingClientRect();
20
- const style: React.CSSProperties = {
21
+ const style: CSSProperties = {
21
22
  height,
22
23
  width,
23
24
  top,
@@ -25,9 +26,9 @@ const InteractiveSpotlight: React.FC<InteractiveSpotlightProps> = ({ element })
25
26
  bottom,
26
27
  right,
27
28
  };
28
- const [clicked, setClicked] = React.useState(false);
29
+ const [clicked, setClicked] = useState(false);
29
30
 
30
- React.useEffect(() => {
31
+ useEffect(() => {
31
32
  if (!clicked) {
32
33
  if (!isInViewport(element)) {
33
34
  element.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { FC, useMemo } from 'react';
2
2
  import InteractiveSpotlight from './InteractiveSpotlight';
3
3
  import StaticSpotlight from './StaticSpotlight';
4
4
 
@@ -7,9 +7,9 @@ interface SpotlightProps {
7
7
  interactive?: boolean;
8
8
  }
9
9
 
10
- const Spotlight: React.FC<SpotlightProps> = ({ selector, interactive }) => {
10
+ const Spotlight: FC<SpotlightProps> = ({ selector, interactive }) => {
11
11
  // if target element is a hidden one return null
12
- const element = React.useMemo(() => {
12
+ const element = useMemo(() => {
13
13
  const highlightElement = document.querySelector(selector);
14
14
  let hiddenElement = highlightElement;
15
15
  while (hiddenElement) {
@@ -1,4 +1,5 @@
1
- import * as React from 'react';
1
+ import './spotlight.scss';
2
+ import { CSSProperties, FC } from 'react';
2
3
  import { useBoundingClientRect } from '../../hooks';
3
4
  import Portal from '../popper/Portal';
4
5
 
@@ -6,9 +7,9 @@ interface StaticSpotlightProps {
6
7
  element: Element;
7
8
  }
8
9
 
9
- const StaticSpotlight: React.FC<StaticSpotlightProps> = ({ element }) => {
10
+ const StaticSpotlight: FC<StaticSpotlightProps> = ({ element }) => {
10
11
  const clientRect = useBoundingClientRect(element as HTMLElement);
11
- const style: React.CSSProperties = clientRect
12
+ const style: CSSProperties = clientRect
12
13
  ? {
13
14
  top: clientRect.top,
14
15
  left: clientRect.left,
@@ -0,0 +1,63 @@
1
+ @keyframes pfext-spotlight-expand {
2
+ 0% {
3
+ outline-offset: -4px;
4
+ outline-width: 4px;
5
+ opacity: 1;
6
+ }
7
+ 100% {
8
+ outline-offset: 21px;
9
+ outline-width: 12px;
10
+ opacity: 0;
11
+ }
12
+ }
13
+
14
+ @keyframes pfext-spotlight-fade-in {
15
+ 0% {
16
+ opacity: 0;
17
+ }
18
+ 100% {
19
+ opacity: 1;
20
+ }
21
+ }
22
+
23
+ @keyframes pfext-spotlight-fade-out {
24
+ 0% {
25
+ opacity: 1;
26
+ }
27
+ 100% {
28
+ opacity: 0;
29
+ }
30
+ }
31
+
32
+ .pfext-spotlight {
33
+ pointer-events: none;
34
+ position: absolute;
35
+ &__with-backdrop {
36
+ mix-blend-mode: hard-light;
37
+ }
38
+ &__element-highlight-noanimate {
39
+ border: var(--pf-t--global--border--width--strong) solid var(--pf-t--global--border--color--brand--default);
40
+ background-color: var(--pf-t--color--gray--40);
41
+ z-index: 9999;
42
+ }
43
+ &__element-highlight-animate {
44
+ pointer-events: none;
45
+ position: absolute;
46
+ box-shadow: inset 0px 0px 0px 4px var(--pf-t--global--color--brand--default);
47
+ opacity: 0;
48
+ animation: 0.4s pfext-spotlight-fade-in 0s ease-in-out, 5s pfext-spotlight-fade-out 12.8s ease-in-out;
49
+ animation-fill-mode: forwards;
50
+ &::after {
51
+ content: '';
52
+ position: absolute;
53
+ left: 0;
54
+ right: 0;
55
+ top: 0;
56
+ bottom: 0;
57
+ animation: 1.2s pfext-spotlight-expand 1.6s ease-out;
58
+ animation-fill-mode: forwards;
59
+ outline: 4px solid var(--pf-t--global--color--brand--default);
60
+ outline-offset: -4px;
61
+ }
62
+ }
63
+ }
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
1
+ import { Children, ComponentType, FC, ReactNode } from 'react';
2
2
  import PopoverStatus from './PopoverStatus';
3
3
  import StatusIconAndText from './StatusIconAndText';
4
4
  import { StatusComponentProps } from './types';
5
5
 
6
- const GenericStatus: React.FC<GenericStatusProps> = (props) => {
6
+ const GenericStatus: FC<GenericStatusProps> = (props) => {
7
7
  const { Icon, children, popoverTitle, title, noTooltip, iconOnly, ...restProps } = props;
8
8
  const renderIcon = iconOnly && !noTooltip ? <Icon title={title} /> : <Icon />;
9
9
  const statusBody = (
@@ -15,7 +15,7 @@ const GenericStatus: React.FC<GenericStatusProps> = (props) => {
15
15
  icon={renderIcon}
16
16
  />
17
17
  );
18
- return React.Children.toArray(children).length ? (
18
+ return Children.toArray(children).length ? (
19
19
  <PopoverStatus title={popoverTitle || title} {...restProps} statusBody={statusBody}>
20
20
  {children}
21
21
  </PopoverStatus>
@@ -25,8 +25,8 @@ const GenericStatus: React.FC<GenericStatusProps> = (props) => {
25
25
  };
26
26
 
27
27
  type GenericStatusProps = StatusComponentProps & {
28
- Icon: React.ComponentType<{ title?: string }>;
29
- children?: React.ReactNode;
28
+ Icon: ComponentType<{ title?: string }>;
29
+ children?: ReactNode;
30
30
  popoverTitle?: string;
31
31
  noTooltip?: boolean;
32
32
  };
@@ -1,6 +1,5 @@
1
1
  // TODO: Pull from Patternfly when they add it
2
2
  // https://github.com/patternfly/patternfly-design/issues/921#issuecomment-726183814
3
- import * as React from 'react';
4
3
 
5
4
  export default (props) => (
6
5
  <svg
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  import { Button, Popover, PopoverPosition } from '@patternfly/react-core';
3
3
 
4
- const PopoverStatus: React.FC<PopoverStatusProps> = ({
4
+ const PopoverStatus: FC<PopoverStatusProps> = ({
5
5
  hideHeader,
6
6
  children,
7
7
  isVisible = null,
@@ -26,8 +26,8 @@ const PopoverStatus: React.FC<PopoverStatusProps> = ({
26
26
  );
27
27
 
28
28
  interface PopoverStatusProps {
29
- children: React.ReactNode;
30
- statusBody: React.ReactNode;
29
+ children: ReactNode;
30
+ statusBody: ReactNode;
31
31
  onHide?: (event: MouseEvent | KeyboardEvent) => void;
32
32
  onShow?: (event: MouseEvent | KeyboardEvent) => void;
33
33
  title?: string;
@@ -1,17 +1,11 @@
1
- import * as React from 'react';
1
+ import { FC } from 'react';
2
2
  import SyncAltIcon from '@patternfly/react-icons/dist/js/icons/sync-alt-icon';
3
3
  import { DASH } from '../../constants';
4
4
  import { SuccessStatus } from './statuses';
5
5
  import StatusIconAndText from './StatusIconAndText';
6
6
  import { StatusComponentProps } from './types';
7
7
 
8
- export const Status: React.FC<StatusProps> = ({
9
- status,
10
- title,
11
- iconOnly,
12
- noTooltip,
13
- className,
14
- }) => {
8
+ export const Status: FC<StatusProps> = ({ status, title, iconOnly, noTooltip, className }) => {
15
9
  const statusProps = { title: title || status, iconOnly, noTooltip, className };
16
10
  switch (status) {
17
11
  case 'In Progress':
@@ -25,9 +19,7 @@ export const Status: React.FC<StatusProps> = ({
25
19
  }
26
20
  };
27
21
 
28
- export const StatusIcon: React.FC<StatusIconProps> = ({ status }) => (
29
- <Status status={status} iconOnly />
30
- );
22
+ export const StatusIcon: FC<StatusIconProps> = ({ status }) => <Status status={status} iconOnly />;
31
23
 
32
24
  interface StatusIconProps {
33
25
  status: string;
@@ -1,15 +1,15 @@
1
- import * as React from 'react';
1
+ import { cloneElement, FC, ReactElement } from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import { CamelCaseWrap } from '@console/internal/components/utils';
4
4
  import { DASH } from '../../constants';
5
5
  import { StatusComponentProps } from './types';
6
6
 
7
7
  type StatusIconAndTextProps = StatusComponentProps & {
8
- icon?: React.ReactElement;
8
+ icon?: ReactElement<any>;
9
9
  spin?: boolean;
10
10
  };
11
11
 
12
- const StatusIconAndText: React.FC<StatusIconAndTextProps> = ({
12
+ const StatusIconAndText: FC<StatusIconAndTextProps> = ({
13
13
  icon,
14
14
  title,
15
15
  spin,
@@ -27,13 +27,13 @@ const StatusIconAndText: React.FC<StatusIconAndTextProps> = ({
27
27
  title={iconOnly && !noTooltip ? title : undefined}
28
28
  >
29
29
  {icon &&
30
- React.cloneElement(icon, {
30
+ cloneElement(icon, {
31
31
  className: css(
32
32
  spin && 'fa-spin',
33
- icon.props.className,
33
+ (icon.props as any).className,
34
34
  !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child',
35
35
  ),
36
- })}
36
+ } as any)}
37
37
  {!iconOnly && <CamelCaseWrap value={title} dataTest="status-text" />}
38
38
  </span>
39
39
  );
@@ -1,26 +1,22 @@
1
- import * as React from 'react';
1
+ import { FC } from 'react';
2
2
  import CheckCircleIcon from '@patternfly/react-icons/dist/js/icons/check-circle-icon';
3
3
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
4
4
  import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
5
5
  import { Icon } from '@patternfly/react-core';
6
6
 
7
- export const GreenCheckCircleIcon: React.FC<ColoredIconProps> = ({ className, title, size }) => (
7
+ export const GreenCheckCircleIcon: FC<ColoredIconProps> = ({ className, title, size }) => (
8
8
  <Icon size={size} status="success">
9
9
  <CheckCircleIcon data-test="success-icon" className={className} title={title} />
10
10
  </Icon>
11
11
  );
12
12
 
13
- export const RedExclamationCircleIcon: React.FC<ColoredIconProps> = ({
14
- className,
15
- title,
16
- size,
17
- }) => (
13
+ export const RedExclamationCircleIcon: FC<ColoredIconProps> = ({ className, title, size }) => (
18
14
  <Icon size={size} status="danger">
19
15
  <ExclamationCircleIcon className={className} title={title} />
20
16
  </Icon>
21
17
  );
22
18
 
23
- export const BlueInfoCircleIcon: React.FC<ColoredIconProps> = ({ className, title }) => (
19
+ export const BlueInfoCircleIcon: FC<ColoredIconProps> = ({ className, title }) => (
24
20
  <Icon status="info">
25
21
  <InfoCircleIcon className={className} title={title} />
26
22
  </Icon>
@@ -1,20 +1,19 @@
1
- import * as React from 'react';
2
-
1
+ import { FC } from 'react';
3
2
  import GenericStatus from './GenericStatus';
4
3
  import { BlueInfoCircleIcon, GreenCheckCircleIcon, RedExclamationCircleIcon } from './icons';
5
4
  import { StatusComponentProps } from './types';
6
5
 
7
- export const ErrorStatus: React.FC<StatusComponentProps> = (props) => (
6
+ export const ErrorStatus: FC<StatusComponentProps> = (props) => (
8
7
  <GenericStatus {...props} Icon={RedExclamationCircleIcon} title={props.title || 'Error'} />
9
8
  );
10
9
  ErrorStatus.displayName = 'ErrorStatus';
11
10
 
12
- export const InfoStatus: React.FC<StatusComponentProps> = (props) => (
11
+ export const InfoStatus: FC<StatusComponentProps> = (props) => (
13
12
  <GenericStatus {...props} Icon={BlueInfoCircleIcon} title={props.title || 'Information'} />
14
13
  );
15
14
  InfoStatus.displayName = 'InfoStatus';
16
15
 
17
- export const SuccessStatus: React.FC<StatusComponentProps> = (props) => (
16
+ export const SuccessStatus: FC<StatusComponentProps> = (props) => (
18
17
  <GenericStatus {...props} Icon={GreenCheckCircleIcon} title={props.title || 'Healthy'} />
19
18
  );
20
19
  SuccessStatus.displayName = 'SuccessStatus';
@@ -1,14 +1,14 @@
1
- import * as React from 'react';
1
+ import { FC, ReactNode, useState } from 'react';
2
2
 
3
3
  interface FallbackImgProps {
4
4
  src: string;
5
5
  alt?: string;
6
6
  className?: string;
7
- fallback?: React.ReactNode;
7
+ fallback?: ReactNode;
8
8
  }
9
9
 
10
- const FallbackImg: React.FC<FallbackImgProps> = ({ src, alt, className, fallback }) => {
11
- const [isSrcValid, setIsSrcValid] = React.useState<boolean>(true);
10
+ const FallbackImg: FC<FallbackImgProps> = ({ src, alt, className, fallback }) => {
11
+ const [isSrcValid, setIsSrcValid] = useState<boolean>(true);
12
12
 
13
13
  if (src && isSrcValid) {
14
14
  return <img className={className} src={src} alt={alt} onError={() => setIsSrcValid(false)} />;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { useCallback, useRef, useState } from 'react';
2
2
 
3
3
  export enum ScrollDirection {
4
4
  scrollingUp = 'scrolling-up',
@@ -27,9 +27,9 @@ export const getScrollDirection = (
27
27
  };
28
28
 
29
29
  export const useScrollDirection = (): [ScrollDirection, (event) => void] => {
30
- const scrollPosition = React.useRef<number>(null);
31
- const [scrollDirection, setScrollDirection] = React.useState<ScrollDirection>(null);
32
- const handleScroll = React.useCallback(
30
+ const scrollPosition = useRef<number>(null);
31
+ const [scrollDirection, setScrollDirection] = useState<ScrollDirection>(null);
32
+ const handleScroll = useCallback(
33
33
  (event) => {
34
34
  const { scrollHeight, scrollTop, clientHeight } = event.target;
35
35
  if (scrollPosition.current !== null) {
@@ -1,14 +1,14 @@
1
- import * as React from 'react';
1
+ import { useCallback, useState } from 'react';
2
2
  import { useResizeObserver } from './useResizeObserver';
3
3
 
4
4
  type BoundingClientRect = ClientRect | null;
5
5
 
6
6
  export const useBoundingClientRect = (targetElement: HTMLElement | null): BoundingClientRect => {
7
- const [clientRect, setClientRect] = React.useState<BoundingClientRect>(() =>
7
+ const [clientRect, setClientRect] = useState<BoundingClientRect>(() =>
8
8
  targetElement ? targetElement.getBoundingClientRect() : null,
9
9
  );
10
10
 
11
- const observerCallback = React.useCallback(() => {
11
+ const observerCallback = useCallback(() => {
12
12
  setClientRect(targetElement ? targetElement.getBoundingClientRect() : null);
13
13
  }, [targetElement]);
14
14
 
@@ -1,6 +1,6 @@
1
- import * as React from 'react';
1
+ import { useReducer } from 'react';
2
2
 
3
3
  /**
4
4
  * React hook that forces component render.
5
5
  */
6
- export const useForceRender = () => React.useReducer((s: boolean) => !s, false)[1] as VoidFunction;
6
+ export const useForceRender = () => useReducer((s: boolean) => !s, false)[1] as VoidFunction;
@@ -1,15 +1,12 @@
1
- import * as React from 'react';
1
+ import { useEffect, useMemo } from 'react';
2
2
 
3
3
  export const useResizeObserver = (
4
4
  callback: ResizeObserverCallback,
5
5
  targetElement?: HTMLElement | null,
6
6
  observerOptions: ResizeObserverOptions = undefined,
7
7
  ): void => {
8
- const element = React.useMemo(
9
- () => targetElement ?? document.querySelector('body'),
10
- [targetElement],
11
- );
12
- React.useEffect(() => {
8
+ const element = useMemo(() => targetElement ?? document.querySelector('body'), [targetElement]);
9
+ useEffect(() => {
13
10
  const observer = new ResizeObserver(callback);
14
11
  observer.observe(element, observerOptions);
15
12
  return () => {
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { useResizeObserver } from './useResizeObserver';
3
3
 
4
4
  export enum Shadows {
@@ -9,8 +9,8 @@ export enum Shadows {
9
9
  }
10
10
 
11
11
  export const useScrollShadows = (node: HTMLElement): Shadows => {
12
- const [shadows, setShadows] = React.useState(Shadows.none);
13
- const computeShadows = React.useCallback(() => {
12
+ const [shadows, setShadows] = useState(Shadows.none);
13
+ const computeShadows = useCallback(() => {
14
14
  if (node) {
15
15
  const { scrollTop, clientHeight, scrollHeight } = node;
16
16
  const top = scrollTop !== 0;
@@ -28,7 +28,7 @@ export const useScrollShadows = (node: HTMLElement): Shadows => {
28
28
  }, [node]);
29
29
  // recompute when the scroll container changes in size
30
30
  useResizeObserver(computeShadows, node);
31
- React.useEffect(() => {
31
+ useEffect(() => {
32
32
  if (node) {
33
33
  // compute initial shadows
34
34
  computeShadows();
@@ -1,14 +1,14 @@
1
- import * as React from 'react';
1
+ import { MutableRefObject, Ref, useCallback } from 'react';
2
2
 
3
- export const useCombineRefs = <RefType>(...refs: (React.Ref<RefType> | undefined)[]) =>
4
- React.useCallback(
3
+ export const useCombineRefs = <RefType>(...refs: (Ref<RefType> | undefined)[]) =>
4
+ useCallback(
5
5
  (element: RefType | null): void =>
6
6
  refs.forEach((ref) => {
7
7
  if (ref) {
8
8
  if (typeof ref === 'function') {
9
9
  ref(element);
10
10
  } else {
11
- (ref as React.MutableRefObject<any>).current = element;
11
+ (ref as MutableRefObject<any>).current = element;
12
12
  }
13
13
  }
14
14
  }),
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { FC, useContext, useEffect } from 'react';
2
2
  import { Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
3
3
  import HelpTopicPanelContent from './HelpTopicPanelContent';
4
4
  import {
@@ -33,7 +33,7 @@ export interface HelpTopicContainerProps extends React.HTMLProps<HTMLDivElement>
33
33
  children?: React.ReactNode;
34
34
  }
35
35
 
36
- export const HelpTopicContainer: React.FC<HelpTopicContainerProps> = ({
36
+ export const HelpTopicContainer: FC<HelpTopicContainerProps> = ({
37
37
  helpTopics,
38
38
  children,
39
39
  resourceBundle,
@@ -54,13 +54,13 @@ export const HelpTopicContainer: React.FC<HelpTopicContainerProps> = ({
54
54
  ...contextProps,
55
55
  });
56
56
 
57
- React.useEffect(() => {
57
+ useEffect(() => {
58
58
  if (loading !== valuesForHelpTopicContext.loading) {
59
59
  valuesForHelpTopicContext.setLoading(loading);
60
60
  }
61
61
  }, [loading, valuesForHelpTopicContext]);
62
62
 
63
- React.useEffect(() => {
63
+ useEffect(() => {
64
64
  if (
65
65
  helpTopics &&
66
66
  JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)
@@ -81,9 +81,9 @@ export interface HelpTopicDrawerProps extends React.HTMLProps<HTMLDivElement> {
81
81
  children?: React.ReactNode;
82
82
  }
83
83
 
84
- export const HelpTopicDrawer: React.FC<HelpTopicDrawerProps> = ({ children, ...props }) => {
84
+ export const HelpTopicDrawer: FC<HelpTopicDrawerProps> = ({ children, ...props }) => {
85
85
  const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } =
86
- React.useContext<HelpTopicContextValues>(HelpTopicContext);
86
+ useContext<HelpTopicContextValues>(HelpTopicContext);
87
87
 
88
88
  const onClose = () => {
89
89
  setActiveHelpTopicByName('');
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { FC, useContext, useState } from 'react';
2
2
  import {
3
3
  Button,
4
4
  Divider,
@@ -30,16 +30,16 @@ interface HelpTopicPanelContentProps {
30
30
  onClose: () => void;
31
31
  }
32
32
 
33
- const HelpTopicPanelContent: React.FC<HelpTopicPanelContentProps> = ({
33
+ const HelpTopicPanelContent: FC<HelpTopicPanelContentProps> = ({
34
34
  activeHelpTopic = null,
35
35
  filteredHelpTopics = [],
36
36
  isResizable = true,
37
37
  onClose,
38
38
  ...props
39
39
  }) => {
40
- const { setActiveHelpTopicByName } = React.useContext<HelpTopicContextValues>(HelpTopicContext);
40
+ const { setActiveHelpTopicByName } = useContext<HelpTopicContextValues>(HelpTopicContext);
41
41
 
42
- const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React.useState(false);
42
+ const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = useState(false);
43
43
 
44
44
  const toggleHelpTopicMenu = () => {
45
45
  setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);