@onewelcome/react-lib-components 1.3.0 → 1.4.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 (90) hide show
  1. package/dist/Button/IconButton.d.ts +2 -1
  2. package/dist/DataGrid/DataGrid.d.ts +1 -0
  3. package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
  4. package/dist/Form/Form.d.ts +3 -3
  5. package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -1
  6. package/dist/Tabs/Tab.d.ts +5 -9
  7. package/dist/Tabs/TabButton.d.ts +3 -6
  8. package/dist/Tabs/Tabs.d.ts +1 -2
  9. package/dist/react-lib-components.cjs.development.js +437 -392
  10. package/dist/react-lib-components.cjs.development.js.map +1 -1
  11. package/dist/react-lib-components.cjs.production.min.js +1 -1
  12. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  13. package/dist/react-lib-components.esm.js +438 -393
  14. package/dist/react-lib-components.esm.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
  17. package/src/Button/BaseButton.tsx +23 -20
  18. package/src/Button/Button.tsx +40 -40
  19. package/src/Button/IconButton.tsx +28 -28
  20. package/src/ContextMenu/ContextMenu.tsx +161 -160
  21. package/src/ContextMenu/ContextMenuItem.tsx +55 -49
  22. package/src/DataGrid/DataGrid.tsx +1 -0
  23. package/src/DataGrid/DataGridActions/DataGridActions.module.scss +1 -1
  24. package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +4 -2
  25. package/src/DataGrid/DataGridActions/DataGridActions.tsx +95 -87
  26. package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +64 -64
  27. package/src/DataGrid/DataGridBody/DataGridCell.tsx +42 -44
  28. package/src/DataGrid/DataGridBody/DataGridRow.tsx +29 -29
  29. package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +78 -78
  30. package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +48 -48
  31. package/src/Form/Checkbox/Checkbox.tsx +134 -130
  32. package/src/Form/Fieldset/Fieldset.tsx +81 -78
  33. package/src/Form/Form.tsx +9 -4
  34. package/src/Form/FormControl/FormControl.module.scss +1 -20
  35. package/src/Form/FormControl/FormControl.tsx +36 -35
  36. package/src/Form/FormGroup/FormGroup.tsx +62 -62
  37. package/src/Form/FormHelperText/FormHelperText.tsx +19 -18
  38. package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +58 -53
  39. package/src/Form/Input/Input.tsx +90 -87
  40. package/src/Form/Label/Label.tsx +17 -16
  41. package/src/Form/Radio/Radio.tsx +91 -91
  42. package/src/Form/Select/Option.tsx +66 -60
  43. package/src/Form/Select/Select.tsx +207 -209
  44. package/src/Form/Textarea/Textarea.tsx +51 -53
  45. package/src/Form/Toggle/Toggle.tsx +26 -23
  46. package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +51 -43
  47. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +112 -106
  48. package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +67 -62
  49. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +42 -37
  50. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +94 -94
  51. package/src/Form/Wrapper/Wrapper/Wrapper.tsx +73 -73
  52. package/src/Icon/Icon.tsx +19 -16
  53. package/src/Link/Link.tsx +68 -63
  54. package/src/Notifications/BaseModal/BaseModal.tsx +68 -68
  55. package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +13 -10
  56. package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +33 -25
  57. package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +20 -17
  58. package/src/Notifications/Dialog/Dialog.tsx +83 -83
  59. package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +17 -14
  60. package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +15 -12
  61. package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +40 -40
  62. package/src/Notifications/SlideInModal/SlideInModal.module.scss +5 -5
  63. package/src/Notifications/SlideInModal/SlideInModal.test.tsx +7 -2
  64. package/src/Notifications/SlideInModal/SlideInModal.tsx +47 -27
  65. package/src/Pagination/Pagination.tsx +169 -169
  66. package/src/Popover/Popover.module.scss +1 -0
  67. package/src/Popover/Popover.tsx +43 -33
  68. package/src/ProgressBar/ProgressBar.tsx +17 -14
  69. package/src/Skeleton/Skeleton.tsx +23 -20
  70. package/src/StatusIndicator/StatusIndicator.tsx +18 -15
  71. package/src/Tabs/{TabPanel.module.scss → Tab.module.scss} +1 -1
  72. package/src/Tabs/Tab.test.tsx +1 -39
  73. package/src/Tabs/Tab.tsx +16 -10
  74. package/src/Tabs/TabButton.module.scss +0 -4
  75. package/src/Tabs/TabButton.test.tsx +3 -31
  76. package/src/Tabs/TabButton.tsx +35 -49
  77. package/src/Tabs/Tabs.test.tsx +40 -33
  78. package/src/Tabs/Tabs.tsx +107 -101
  79. package/src/TextEllipsis/TextEllipsis.tsx +50 -41
  80. package/src/Tiles/Tile.tsx +58 -56
  81. package/src/Tiles/Tiles.tsx +44 -41
  82. package/src/Tooltip/Tooltip.tsx +101 -100
  83. package/src/Typography/Typography.tsx +47 -44
  84. package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +55 -52
  85. package/src/Wizard/WizardSteps/WizardSteps.tsx +25 -22
  86. package/src/mixins.module.scss +2 -2
  87. package/src/util/helper.test.tsx +0 -28
  88. package/dist/Tabs/TabPanel.d.ts +0 -8
  89. package/src/Tabs/TabPanel.test.tsx +0 -92
  90. package/src/Tabs/TabPanel.tsx +0 -43
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, useEffect } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef, useEffect } from "react";
18
18
  import { createPortal } from "react-dom";
19
19
  import classes from "./BaseModal.module.scss";
20
20
  import { labelId, descriptionId } from "./BaseModalContext";
@@ -61,82 +61,82 @@ export const useSetBodyScroll = (open: boolean) => {
61
61
  }, [open]);
62
62
  };
63
63
 
64
- export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
65
- (
66
- {
67
- id,
68
- children,
69
- open,
70
- onClose,
71
- className = "",
72
- containerProps,
73
- backdropProps,
74
- labelledby,
75
- describedby,
76
- disableEscapeKeyDown = false,
77
- disableBackdrop = false,
78
- forceContainerOpen = false,
79
- zIndex,
80
- domRoot = document.body,
81
- ...rest
82
- }: Props,
83
- ref
84
- ) => {
85
- useSetBodyScroll(open);
64
+ const BaseModalComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
65
+ {
66
+ id,
67
+ children,
68
+ open,
69
+ onClose,
70
+ className = "",
71
+ containerProps,
72
+ backdropProps,
73
+ labelledby,
74
+ describedby,
75
+ disableEscapeKeyDown = false,
76
+ disableBackdrop = false,
77
+ forceContainerOpen = false,
78
+ zIndex,
79
+ domRoot = document.body,
80
+ ...rest
81
+ }: Props,
82
+ ref
83
+ ) => {
84
+ useSetBodyScroll(open);
86
85
 
87
- const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {
88
- if (!disableEscapeKeyDown && event.key === "Escape") {
89
- event.stopPropagation();
90
- onClose && onClose();
91
- }
92
- };
86
+ const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {
87
+ if (!disableEscapeKeyDown && event.key === "Escape") {
88
+ event.stopPropagation();
89
+ onClose && onClose();
90
+ }
91
+ };
93
92
 
94
- const handleBackdropClick = () => !disableBackdrop && onClose && onClose();
93
+ const handleBackdropClick = () => !disableBackdrop && onClose && onClose();
95
94
 
96
- return createPortal(
95
+ return createPortal(
96
+ <div
97
+ {...rest}
98
+ ref={ref}
99
+ id={id}
100
+ className={`${classes["modal"]} ${open ? classes["visible"] : ""} ${className}`}
101
+ role="dialog"
102
+ aria-modal="true"
103
+ aria-labelledby={labelledby || labelId(id)}
104
+ aria-describedby={describedby || descriptionId(id)}
105
+ aria-hidden={!open}
106
+ tabIndex={-1}
107
+ data-hidden={!open}
108
+ onKeyDown={handleEscKeyPress}
109
+ style={{ zIndex }}
110
+ >
97
111
  <div
98
- {...rest}
99
- ref={ref}
100
- id={id}
101
- className={`${classes["modal"]} ${open ? classes["visible"] : ""} ${className}`}
102
- role="dialog"
103
- aria-modal="true"
104
- aria-labelledby={labelledby || labelId(id)}
105
- aria-describedby={describedby || descriptionId(id)}
106
- aria-hidden={!open}
107
- tabIndex={-1}
108
- data-hidden={!open}
109
- onKeyDown={handleEscKeyPress}
110
- style={{ zIndex }}
111
- >
112
+ {...backdropProps}
113
+ className={`${classes["backdrop"]} ${backdropProps?.className ?? ""}`}
114
+ onClick={handleBackdropClick}
115
+ ></div>
116
+ {forceContainerOpen ? (
112
117
  <div
113
- {...backdropProps}
114
- className={`${classes["backdrop"]} ${backdropProps?.className ?? ""}`}
115
- onClick={handleBackdropClick}
116
- ></div>
117
- {forceContainerOpen ? (
118
+ {...containerProps}
119
+ aria-hidden={!open}
120
+ hidden={!open}
121
+ style={{ zIndex: zIndex && zIndex + 1 }}
122
+ className={`${classes["container"]} ${containerProps?.className ?? ""}`}
123
+ >
124
+ {children}
125
+ </div>
126
+ ) : (
127
+ open && (
118
128
  <div
119
129
  {...containerProps}
120
- aria-hidden={!open}
121
- hidden={!open}
122
130
  style={{ zIndex: zIndex && zIndex + 1 }}
123
131
  className={`${classes["container"]} ${containerProps?.className ?? ""}`}
124
132
  >
125
133
  {children}
126
134
  </div>
127
- ) : (
128
- open && (
129
- <div
130
- {...containerProps}
131
- style={{ zIndex: zIndex && zIndex + 1 }}
132
- className={`${classes["container"]} ${containerProps?.className ?? ""}`}
133
- >
134
- {children}
135
- </div>
136
- )
137
- )}
138
- </div>,
139
- domRoot
140
- );
141
- }
142
- );
135
+ )
136
+ )}
137
+ </div>,
138
+ domRoot
139
+ );
140
+ };
141
+
142
+ export const BaseModal = React.forwardRef(BaseModalComponent);
@@ -14,19 +14,22 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
18
18
  import classes from "./BaseModalActions.module.scss";
19
19
 
20
20
  export interface Props extends ComponentPropsWithRef<"div"> {
21
21
  children?: React.ReactNode;
22
22
  }
23
23
 
24
- export const BaseModalActions = React.forwardRef<HTMLDivElement, Props>(
25
- ({ children, className = "", ...rest }: Props, ref) => {
26
- return (
27
- <div {...rest} ref={ref} className={`${classes["actions"]} ${className}`}>
28
- {children}
29
- </div>
30
- );
31
- }
32
- );
24
+ const BaseModalActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
25
+ { children, className = "", ...rest }: Props,
26
+ ref
27
+ ) => {
28
+ return (
29
+ <div {...rest} ref={ref} className={`${classes["actions"]} ${className}`}>
30
+ {children}
31
+ </div>
32
+ );
33
+ };
34
+
35
+ export const BaseModalActions = React.forwardRef(BaseModalActionsComponent);
@@ -14,7 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, createRef, useEffect } from "react";
17
+ import React, {
18
+ ForwardRefRenderFunction,
19
+ ComponentPropsWithRef,
20
+ createRef,
21
+ useEffect
22
+ } from "react";
18
23
  import classes from "./BaseModalContent.module.scss";
19
24
 
20
25
  export interface Props extends ComponentPropsWithRef<"div"> {
@@ -24,29 +29,32 @@ export interface Props extends ComponentPropsWithRef<"div"> {
24
29
  disableAutoFocus?: boolean;
25
30
  }
26
31
 
27
- export const BaseModalContent = React.forwardRef<HTMLDivElement, Props>(
28
- ({ id, children, className = "", disableAutoFocus = false, ...rest }: Props, ref) => {
29
- const contentRef = createRef<HTMLDivElement>();
32
+ const BaseModalContentComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
33
+ { id, children, className = "", disableAutoFocus = false, ...rest }: Props,
34
+ ref
35
+ ) => {
36
+ const contentRef = createRef<HTMLDivElement>();
30
37
 
31
- useEffect(() => {
32
- if (!disableAutoFocus && ref) {
33
- (ref as React.RefObject<HTMLDivElement>).current?.focus();
34
- } else if (!disableAutoFocus) {
35
- contentRef.current?.focus();
36
- }
37
- }, []);
38
+ useEffect(() => {
39
+ if (!disableAutoFocus && ref) {
40
+ (ref as React.RefObject<HTMLDivElement>).current?.focus();
41
+ } else if (!disableAutoFocus) {
42
+ contentRef.current?.focus();
43
+ }
44
+ }, []);
38
45
 
39
- /**tabIndex is set to be able to do focus on that element which we need for catching keyDown events */
40
- return (
41
- <div
42
- {...rest}
43
- ref={ref || contentRef}
44
- id={id}
45
- className={`${classes["content"]} ${className}`}
46
- tabIndex={-1}
47
- >
48
- {children}
49
- </div>
50
- );
51
- }
52
- );
46
+ /**tabIndex is set to be able to do focus on that element which we need for catching keyDown events */
47
+ return (
48
+ <div
49
+ {...rest}
50
+ ref={ref || contentRef}
51
+ id={id}
52
+ className={`${classes["content"]} ${className}`}
53
+ tabIndex={-1}
54
+ >
55
+ {children}
56
+ </div>
57
+ );
58
+ };
59
+
60
+ export const BaseModalContent = React.forwardRef(BaseModalContentComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
18
18
  import classes from "./BaseModalHeader.module.scss";
19
19
  import { IconButton } from "../../../Button/IconButton";
20
20
  import { Icon, Icons } from "../../../Icon/Icon";
@@ -27,20 +27,23 @@ export interface Props extends ComponentPropsWithRef<"div"> {
27
27
  onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
28
28
  }
29
29
 
30
- export const BaseModalHeader = React.forwardRef<HTMLDivElement, Props>(
31
- ({ id, title, children, onClose, ...rest }: Props, ref) => {
32
- return (
33
- <div {...rest} ref={ref} className={classes["header"]}>
34
- <div className={classes["headline"]}>
35
- <Typography id={id} className={classes["title"]} tag="h1" variant="h4">
36
- {title}
37
- </Typography>
38
- <IconButton onClick={onClose} className={classes["closeBtn"]} title="close modal">
39
- <Icon icon={Icons.Times} />
40
- </IconButton>
41
- </div>
42
- {children}
30
+ const BaseModalHeaderComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
31
+ { id, title, children, onClose, ...rest }: Props,
32
+ ref
33
+ ) => {
34
+ return (
35
+ <div {...rest} ref={ref} className={classes["header"]}>
36
+ <div className={classes["headline"]}>
37
+ <Typography id={id} className={classes["title"]} tag="h1" variant="h4">
38
+ {title}
39
+ </Typography>
40
+ <IconButton onClick={onClose} className={classes["closeBtn"]} title="close modal">
41
+ <Icon icon={Icons.Times} />
42
+ </IconButton>
43
43
  </div>
44
- );
45
- }
46
- );
44
+ {children}
45
+ </div>
46
+ );
47
+ };
48
+
49
+ export const BaseModalHeader = React.forwardRef(BaseModalHeaderComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, useState } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef, useState } from "react";
18
18
  import { BaseModal } from "../BaseModal/BaseModal";
19
19
  import { BaseModalContent } from "../BaseModal/BaseModalContent/BaseModalContent";
20
20
  import { DialogActions } from "./DialogActions/DialogActions";
@@ -42,88 +42,88 @@ export interface Action extends Omit<ButtonProps, "variant" | "ref"> {
42
42
  onClick: (event?: React.MouseEvent<HTMLButtonElement>) => unknown;
43
43
  }
44
44
 
45
- export const Dialog = React.forwardRef<HTMLDivElement, Props>(
46
- (
47
- {
48
- id,
49
- open,
50
- children,
51
- alignActions,
52
- onClose,
53
- title,
54
- primaryAction,
55
- secondaryAction,
56
- zIndex,
57
- disableEscapeKeyDown = true,
58
- ...rest
59
- }: Props,
60
- ref
61
- ) => {
62
- const [dialogId] = useState(id ?? generateID(20));
63
- const { label: primaryLabel, ...restOfPrimaryAction } = primaryAction;
64
- const PrimaryButton = (
65
- <Button key="primary" {...restOfPrimaryAction}>
66
- {primaryLabel}
67
- </Button>
68
- );
69
- const TertiaryButton =
70
- secondaryAction &&
71
- (function () {
72
- const { label: secondaryLabel, ...restOfSecondaryAction } = secondaryAction;
73
- return (
74
- <Button key="tertiary" variant="text" {...restOfSecondaryAction}>
75
- {secondaryLabel}
76
- </Button>
77
- );
78
- })();
45
+ const DialogComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
46
+ {
47
+ id,
48
+ open,
49
+ children,
50
+ alignActions,
51
+ onClose,
52
+ title,
53
+ primaryAction,
54
+ secondaryAction,
55
+ zIndex,
56
+ disableEscapeKeyDown = true,
57
+ ...rest
58
+ }: Props,
59
+ ref
60
+ ) => {
61
+ const [dialogId] = useState(id ?? generateID(20));
62
+ const { label: primaryLabel, ...restOfPrimaryAction } = primaryAction;
63
+ const PrimaryButton = (
64
+ <Button key="primary" {...restOfPrimaryAction}>
65
+ {primaryLabel}
66
+ </Button>
67
+ );
68
+ const TertiaryButton =
69
+ secondaryAction &&
70
+ (function () {
71
+ const { label: secondaryLabel, ...restOfSecondaryAction } = secondaryAction;
72
+ return (
73
+ <Button key="tertiary" variant="text" {...restOfSecondaryAction}>
74
+ {secondaryLabel}
75
+ </Button>
76
+ );
77
+ })();
79
78
 
80
- const onHiddenInputKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
81
- /** It has to be here because then we will need to check if user doesn't click tab to select action button and want to do another action then primary one? */
82
- if (event.key === "Enter") {
83
- primaryAction.onClick();
84
- }
85
- };
79
+ const onHiddenInputKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
80
+ /** It has to be here because then we will need to check if user doesn't click tab to select action button and want to do another action then primary one? */
81
+ if (event.key === "Enter") {
82
+ primaryAction.onClick();
83
+ }
84
+ };
86
85
 
87
- return (
88
- <BaseModal
89
- {...rest}
90
- ref={ref}
91
- id={dialogId}
92
- className={classes["dialog"]}
93
- containerProps={{ className: classes["container"] }}
94
- open={open}
95
- disableBackdrop
96
- onClose={onClose}
97
- zIndex={zIndex}
98
- disableEscapeKeyDown={disableEscapeKeyDown}
86
+ return (
87
+ <BaseModal
88
+ {...rest}
89
+ ref={ref}
90
+ id={dialogId}
91
+ className={classes["dialog"]}
92
+ containerProps={{ className: classes["container"] }}
93
+ open={open}
94
+ disableBackdrop
95
+ onClose={onClose}
96
+ zIndex={zIndex}
97
+ disableEscapeKeyDown={disableEscapeKeyDown}
98
+ >
99
+ <DialogTitle id={labelId(dialogId)} title={title} />
100
+ <BaseModalContent
101
+ id={descriptionId(dialogId)}
102
+ className={classes["content"]}
103
+ disableAutoFocus
99
104
  >
100
- <DialogTitle id={labelId(dialogId)} title={title} />
101
- <BaseModalContent
102
- id={descriptionId(dialogId)}
103
- className={classes["content"]}
104
- disableAutoFocus
105
- >
106
- {children}
107
- </BaseModalContent>
108
- <DialogActions align={alignActions}>
109
- {alignActions === "left"
110
- ? [PrimaryButton, TertiaryButton]
111
- : [TertiaryButton, PrimaryButton]}
112
- </DialogActions>
113
- <input
114
- autoFocus
115
- aria-hidden={true}
116
- style={{
117
- position: "absolute",
118
- width: 0,
119
- height: 0,
120
- opacity: 0
121
- }}
122
- maxLength={0}
123
- tabIndex={-1}
124
- onKeyPress={onHiddenInputKeyPress}
125
- />
126
- </BaseModal>
127
- );
128
- }
129
- );
105
+ {children}
106
+ </BaseModalContent>
107
+ <DialogActions align={alignActions}>
108
+ {alignActions === "left"
109
+ ? [PrimaryButton, TertiaryButton]
110
+ : [TertiaryButton, PrimaryButton]}
111
+ </DialogActions>
112
+ <input
113
+ autoFocus
114
+ aria-hidden={true}
115
+ style={{
116
+ position: "absolute",
117
+ width: 0,
118
+ height: 0,
119
+ opacity: 0
120
+ }}
121
+ maxLength={0}
122
+ tabIndex={-1}
123
+ onKeyPress={onHiddenInputKeyPress}
124
+ />
125
+ </BaseModal>
126
+ );
127
+ };
128
+
129
+ export const Dialog = React.forwardRef(DialogComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
18
18
  import {
19
19
  BaseModalActions,
20
20
  Props as BaseModalActionsProps
@@ -25,16 +25,19 @@ export interface Props extends ComponentPropsWithRef<any>, BaseModalActionsProps
25
25
  align: "left" | "right";
26
26
  }
27
27
 
28
- export const DialogActions = React.forwardRef<HTMLDivElement, Props>(
29
- ({ children, align, ...rest }: Props, ref) => {
30
- return (
31
- <BaseModalActions
32
- {...rest}
33
- ref={ref}
34
- className={`${classes["actions"]}${align === "left" ? " " + classes["left"] : ""}`}
35
- >
36
- {children}
37
- </BaseModalActions>
38
- );
39
- }
40
- );
28
+ const DialogActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
29
+ { children, align, ...rest }: Props,
30
+ ref
31
+ ) => {
32
+ return (
33
+ <BaseModalActions
34
+ {...rest}
35
+ ref={ref}
36
+ className={`${classes["actions"]}${align === "left" ? " " + classes["left"] : ""}`}
37
+ >
38
+ {children}
39
+ </BaseModalActions>
40
+ );
41
+ };
42
+
43
+ export const DialogActions = React.forwardRef(DialogActionsComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
18
18
  import { Typography } from "../../../Typography/Typography";
19
19
  import classes from "./DialogTitle.module.scss";
20
20
 
@@ -23,14 +23,17 @@ export interface Props extends ComponentPropsWithRef<"div"> {
23
23
  title: string;
24
24
  }
25
25
 
26
- export const DialogTitle = React.forwardRef<HTMLDivElement, Props>(
27
- ({ id, title, ...rest }: Props, ref) => {
28
- return (
29
- <div {...rest} ref={ref} className={classes["header"]}>
30
- <Typography id={id} className={classes["title"]} tag="h1" variant="h4">
31
- {title}
32
- </Typography>
33
- </div>
34
- );
35
- }
36
- );
26
+ const DialogTitleComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
27
+ { id, title, ...rest }: Props,
28
+ ref
29
+ ) => {
30
+ return (
31
+ <div {...rest} ref={ref} className={classes["header"]}>
32
+ <Typography id={id} className={classes["title"]} tag="h1" variant="h4">
33
+ {title}
34
+ </Typography>
35
+ </div>
36
+ );
37
+ };
38
+
39
+ export const DialogTitle = React.forwardRef(DialogTitleComponent);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef } from "react";
17
+ import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
18
18
  import { Dialog } from "../../Dialog/Dialog";
19
19
  import { Typography } from "../../../Typography/Typography";
20
20
  import { DataAttributeKey } from "../../../interfaces";
@@ -30,42 +30,42 @@ export interface Props extends ComponentPropsWithRef<"div"> {
30
30
  onDiscardChanges: () => void;
31
31
  }
32
32
 
33
- export const DiscardChangesDialog = React.forwardRef<HTMLDivElement, Props>(
34
- (
35
- {
36
- open,
37
- onKeepEditing,
38
- onDiscardChanges,
39
- discardChangesButtonLabel,
40
- keepEditingButtonLabel,
41
- contentLabel,
42
- titleLabel,
43
- ...rest
44
- }: Props,
45
- ref
46
- ) => {
47
- return (
48
- <Dialog
49
- {...rest}
50
- ref={ref}
51
- open={open}
52
- alignActions="left"
53
- title={titleLabel}
54
- onClose={onKeepEditing}
55
- primaryAction={{
56
- label: discardChangesButtonLabel,
57
- onClick: onDiscardChanges
58
- }}
59
- secondaryAction={{
60
- label: keepEditingButtonLabel,
61
- onClick: onKeepEditing
62
- }}
63
- disableEscapeKeyDown={false}
64
- >
65
- <Typography variant="body" spacing={{ margin: 0 }}>
66
- {contentLabel}
67
- </Typography>
68
- </Dialog>
69
- );
70
- }
71
- );
33
+ const DiscardChangesDialogComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
34
+ {
35
+ open,
36
+ onKeepEditing,
37
+ onDiscardChanges,
38
+ discardChangesButtonLabel,
39
+ keepEditingButtonLabel,
40
+ contentLabel,
41
+ titleLabel,
42
+ ...rest
43
+ }: Props,
44
+ ref
45
+ ) => {
46
+ return (
47
+ <Dialog
48
+ {...rest}
49
+ ref={ref}
50
+ open={open}
51
+ alignActions="left"
52
+ title={titleLabel}
53
+ onClose={onKeepEditing}
54
+ primaryAction={{
55
+ label: discardChangesButtonLabel,
56
+ onClick: onDiscardChanges
57
+ }}
58
+ secondaryAction={{
59
+ label: keepEditingButtonLabel,
60
+ onClick: onKeepEditing
61
+ }}
62
+ disableEscapeKeyDown={false}
63
+ >
64
+ <Typography variant="body" spacing={{ margin: 0 }}>
65
+ {contentLabel}
66
+ </Typography>
67
+ </Dialog>
68
+ );
69
+ };
70
+
71
+ export const DiscardChangesDialog = React.forwardRef(DiscardChangesDialogComponent);