@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.
- package/dist/Button/IconButton.d.ts +2 -1
- package/dist/DataGrid/DataGrid.d.ts +1 -0
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
- package/dist/Form/Form.d.ts +3 -3
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -1
- package/dist/Tabs/Tab.d.ts +5 -9
- package/dist/Tabs/TabButton.d.ts +3 -6
- package/dist/Tabs/Tabs.d.ts +1 -2
- package/dist/react-lib-components.cjs.development.js +437 -392
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +438 -393
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
- package/src/Button/BaseButton.tsx +23 -20
- package/src/Button/Button.tsx +40 -40
- package/src/Button/IconButton.tsx +28 -28
- package/src/ContextMenu/ContextMenu.tsx +161 -160
- package/src/ContextMenu/ContextMenuItem.tsx +55 -49
- package/src/DataGrid/DataGrid.tsx +1 -0
- package/src/DataGrid/DataGridActions/DataGridActions.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +4 -2
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +95 -87
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +64 -64
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +42 -44
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +29 -29
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +78 -78
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +48 -48
- package/src/Form/Checkbox/Checkbox.tsx +134 -130
- package/src/Form/Fieldset/Fieldset.tsx +81 -78
- package/src/Form/Form.tsx +9 -4
- package/src/Form/FormControl/FormControl.module.scss +1 -20
- package/src/Form/FormControl/FormControl.tsx +36 -35
- package/src/Form/FormGroup/FormGroup.tsx +62 -62
- package/src/Form/FormHelperText/FormHelperText.tsx +19 -18
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +58 -53
- package/src/Form/Input/Input.tsx +90 -87
- package/src/Form/Label/Label.tsx +17 -16
- package/src/Form/Radio/Radio.tsx +91 -91
- package/src/Form/Select/Option.tsx +66 -60
- package/src/Form/Select/Select.tsx +207 -209
- package/src/Form/Textarea/Textarea.tsx +51 -53
- package/src/Form/Toggle/Toggle.tsx +26 -23
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +51 -43
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +112 -106
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +67 -62
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +42 -37
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +94 -94
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +73 -73
- package/src/Icon/Icon.tsx +19 -16
- package/src/Link/Link.tsx +68 -63
- package/src/Notifications/BaseModal/BaseModal.tsx +68 -68
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +13 -10
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +33 -25
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +20 -17
- package/src/Notifications/Dialog/Dialog.tsx +83 -83
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +17 -14
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +15 -12
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +40 -40
- package/src/Notifications/SlideInModal/SlideInModal.module.scss +5 -5
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +7 -2
- package/src/Notifications/SlideInModal/SlideInModal.tsx +47 -27
- package/src/Pagination/Pagination.tsx +169 -169
- package/src/Popover/Popover.module.scss +1 -0
- package/src/Popover/Popover.tsx +43 -33
- package/src/ProgressBar/ProgressBar.tsx +17 -14
- package/src/Skeleton/Skeleton.tsx +23 -20
- package/src/StatusIndicator/StatusIndicator.tsx +18 -15
- package/src/Tabs/{TabPanel.module.scss → Tab.module.scss} +1 -1
- package/src/Tabs/Tab.test.tsx +1 -39
- package/src/Tabs/Tab.tsx +16 -10
- package/src/Tabs/TabButton.module.scss +0 -4
- package/src/Tabs/TabButton.test.tsx +3 -31
- package/src/Tabs/TabButton.tsx +35 -49
- package/src/Tabs/Tabs.test.tsx +40 -33
- package/src/Tabs/Tabs.tsx +107 -101
- package/src/TextEllipsis/TextEllipsis.tsx +50 -41
- package/src/Tiles/Tile.tsx +58 -56
- package/src/Tiles/Tiles.tsx +44 -41
- package/src/Tooltip/Tooltip.tsx +101 -100
- package/src/Typography/Typography.tsx +47 -44
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +55 -52
- package/src/Wizard/WizardSteps/WizardSteps.tsx +25 -22
- package/src/mixins.module.scss +2 -2
- package/src/util/helper.test.tsx +0 -28
- package/dist/Tabs/TabPanel.d.ts +0 -8
- package/src/Tabs/TabPanel.test.tsx +0 -92
- 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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
+
const handleBackdropClick = () => !disableBackdrop && onClose && onClose();
|
|
95
94
|
|
|
96
|
-
|
|
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
|
-
{...
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
{...
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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, {
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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);
|