carbon-react 144.0.0 → 144.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/advanced-color-picker/advanced-color-picker.style.js +1 -5
- package/esm/components/dialog/dialog.component.js +29 -103
- package/esm/components/dialog/dialog.config.d.ts +0 -4
- package/esm/components/dialog/dialog.config.js +1 -5
- package/esm/components/dialog/dialog.style.d.ts +6 -14
- package/esm/components/dialog/dialog.style.js +54 -83
- package/esm/components/dialog-full-screen/content.style.js +32 -74
- package/esm/components/dialog-full-screen/dialog-full-screen.style.js +0 -5
- package/esm/components/form/form.component.js +8 -17
- package/esm/components/form/form.style.d.ts +10 -6
- package/esm/components/form/form.style.js +12 -25
- package/esm/components/sidebar/sidebar.component.js +8 -18
- package/esm/components/sidebar/sidebar.config.d.ts +0 -4
- package/esm/components/sidebar/sidebar.config.js +1 -5
- package/esm/components/sidebar/sidebar.style.d.ts +4 -2
- package/esm/components/sidebar/sidebar.style.js +26 -12
- package/lib/components/advanced-color-picker/advanced-color-picker.style.js +0 -4
- package/lib/components/dialog/dialog.component.js +27 -101
- package/lib/components/dialog/dialog.config.d.ts +0 -4
- package/lib/components/dialog/dialog.config.js +2 -6
- package/lib/components/dialog/dialog.style.d.ts +6 -14
- package/lib/components/dialog/dialog.style.js +54 -83
- package/lib/components/dialog-full-screen/content.style.js +31 -73
- package/lib/components/dialog-full-screen/dialog-full-screen.style.js +0 -5
- package/lib/components/form/form.component.js +7 -16
- package/lib/components/form/form.style.d.ts +10 -6
- package/lib/components/form/form.style.js +12 -25
- package/lib/components/sidebar/sidebar.component.js +7 -17
- package/lib/components/sidebar/sidebar.config.d.ts +0 -4
- package/lib/components/sidebar/sidebar.config.js +2 -6
- package/lib/components/sidebar/sidebar.style.d.ts +4 -2
- package/lib/components/sidebar/sidebar.style.js +28 -15
- package/package.json +1 -1
- package/esm/style/utils/form-style-utils.d.ts +0 -21
- package/esm/style/utils/form-style-utils.js +0 -92
- package/lib/style/utils/form-style-utils.d.ts +0 -21
- package/lib/style/utils/form-style-utils.js +0 -100
|
@@ -3,7 +3,7 @@ import { margin } from "styled-system";
|
|
|
3
3
|
import StyledAdvancedColorPickerCell from "./advanced-color-picker-cell.style";
|
|
4
4
|
import { StyledColorOptions } from "../simple-color-picker/simple-color-picker.style";
|
|
5
5
|
import { StyledSimpleColor } from "../simple-color-picker/simple-color/simple-color.style";
|
|
6
|
-
import { StyledDialogContent
|
|
6
|
+
import { StyledDialogContent } from "../dialog/dialog.style";
|
|
7
7
|
import Dialog from "../dialog/dialog.component";
|
|
8
8
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
9
9
|
import checkerBoardSvg from "../simple-color-picker/simple-color/checker-board.svg";
|
|
@@ -52,10 +52,6 @@ const DialogStyle = styled(Dialog)`
|
|
|
52
52
|
padding: var(--spacing200);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
${StyledDialogInnerContent} {
|
|
56
|
-
padding: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
${StyledColorOptions} {
|
|
60
56
|
max-width: 285px;
|
|
61
57
|
${StyledSimpleColor} {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useRef,
|
|
2
|
+
import React, { useRef, useImperativeHandle, forwardRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
5
5
|
import Modal from "../modal";
|
|
6
6
|
import Heading from "../heading";
|
|
7
7
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
8
|
-
import
|
|
9
|
-
import { StyledDialog, StyledDialogTitle, StyledDialogContent, StyledDialogInnerContent } from "./dialog.style";
|
|
10
|
-
import { TOP_MARGIN } from "./dialog.config";
|
|
8
|
+
import { StyledDialog, StyledDialogTitle, StyledDialogContent, DialogPositioner } from "./dialog.style";
|
|
11
9
|
import FocusTrap from "../../__internal__/focus-trap";
|
|
12
10
|
import IconButton from "../icon-button";
|
|
13
11
|
import Icon from "../icon";
|
|
@@ -44,11 +42,7 @@ const Dialog = /*#__PURE__*/forwardRef(({
|
|
|
44
42
|
}, ref) => {
|
|
45
43
|
const locale = useLocale();
|
|
46
44
|
const containerRef = useRef(null);
|
|
47
|
-
const innerContentRef = useRef(null);
|
|
48
45
|
const titleRef = useRef(null);
|
|
49
|
-
const [breakpointOffset, setBreakpointOffset] = useState(undefined);
|
|
50
|
-
const isDialogMaximised = size === "maximise";
|
|
51
|
-
const listenersAdded = useRef(false);
|
|
52
46
|
const {
|
|
53
47
|
current: titleId
|
|
54
48
|
} = useRef(createGuid());
|
|
@@ -61,93 +55,29 @@ const Dialog = /*#__PURE__*/forwardRef(({
|
|
|
61
55
|
containerRef.current?.focus();
|
|
62
56
|
}
|
|
63
57
|
}), []);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
setBreakpointOffset(breakPoint);
|
|
88
|
-
}
|
|
89
|
-
containerRef.current.style.top = `${midPointY}px`;
|
|
90
|
-
containerRef.current.style.left = `${midPointX}px`;
|
|
91
|
-
}, [size]);
|
|
92
|
-
useResizeObserver(innerContentRef, centerDialog, !open);
|
|
93
|
-
const addListeners = useCallback(() => {
|
|
94
|
-
/* istanbul ignore else */
|
|
95
|
-
if (!listenersAdded.current) {
|
|
96
|
-
window.addEventListener("resize", centerDialog);
|
|
97
|
-
listenersAdded.current = true;
|
|
98
|
-
}
|
|
99
|
-
}, [centerDialog]);
|
|
100
|
-
const removeListeners = useCallback(() => {
|
|
101
|
-
if (listenersAdded.current) {
|
|
102
|
-
window.removeEventListener("resize", centerDialog);
|
|
103
|
-
listenersAdded.current = false;
|
|
104
|
-
}
|
|
105
|
-
}, [centerDialog]);
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
if (open) {
|
|
108
|
-
addListeners();
|
|
109
|
-
}
|
|
110
|
-
if (!open) {
|
|
111
|
-
removeListeners();
|
|
112
|
-
}
|
|
113
|
-
return () => {
|
|
114
|
-
removeListeners();
|
|
115
|
-
};
|
|
116
|
-
}, [open, addListeners, removeListeners]);
|
|
117
|
-
useLayoutEffect(() => {
|
|
118
|
-
if (open) {
|
|
119
|
-
centerDialog();
|
|
120
|
-
}
|
|
121
|
-
}, [centerDialog, open, height]);
|
|
122
|
-
const closeIcon = () => {
|
|
123
|
-
if (!showCloseIcon || !onCancel) return null;
|
|
124
|
-
return /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
125
|
-
"aria-label": locale.dialog.ariaLabels.close(),
|
|
126
|
-
onClick: onCancel,
|
|
127
|
-
disabled: disableClose
|
|
128
|
-
}, tagComponent("close", {
|
|
129
|
-
"data-element": "close",
|
|
130
|
-
...closeButtonDataProps
|
|
131
|
-
})), /*#__PURE__*/React.createElement(Icon, {
|
|
132
|
-
type: "close"
|
|
133
|
-
}));
|
|
134
|
-
};
|
|
135
|
-
const dialogTitle = () => {
|
|
136
|
-
if (!title) return null;
|
|
137
|
-
return /*#__PURE__*/React.createElement(StyledDialogTitle, {
|
|
138
|
-
showCloseIcon: showCloseIcon,
|
|
139
|
-
hasSubtitle: !!subtitle,
|
|
140
|
-
ref: titleRef
|
|
141
|
-
}, typeof title === "string" ? /*#__PURE__*/React.createElement(Heading, {
|
|
142
|
-
"data-element": "dialog-title",
|
|
143
|
-
title: title,
|
|
144
|
-
titleId: titleId,
|
|
145
|
-
subheader: subtitle,
|
|
146
|
-
subtitleId: subtitleId,
|
|
147
|
-
divider: false,
|
|
148
|
-
help: help
|
|
149
|
-
}) : title);
|
|
150
|
-
};
|
|
58
|
+
const closeIcon = showCloseIcon && onCancel && /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
59
|
+
"aria-label": locale.dialog.ariaLabels.close(),
|
|
60
|
+
onClick: onCancel,
|
|
61
|
+
disabled: disableClose
|
|
62
|
+
}, tagComponent("close", {
|
|
63
|
+
"data-element": "close",
|
|
64
|
+
...closeButtonDataProps
|
|
65
|
+
})), /*#__PURE__*/React.createElement(Icon, {
|
|
66
|
+
type: "close"
|
|
67
|
+
}));
|
|
68
|
+
const dialogTitle = title && /*#__PURE__*/React.createElement(StyledDialogTitle, {
|
|
69
|
+
showCloseIcon: showCloseIcon,
|
|
70
|
+
hasSubtitle: !!subtitle,
|
|
71
|
+
ref: titleRef
|
|
72
|
+
}, typeof title === "string" ? /*#__PURE__*/React.createElement(Heading, {
|
|
73
|
+
"data-element": "dialog-title",
|
|
74
|
+
title: title,
|
|
75
|
+
titleId: titleId,
|
|
76
|
+
subheader: subtitle,
|
|
77
|
+
subtitleId: subtitleId,
|
|
78
|
+
divider: false,
|
|
79
|
+
help: help
|
|
80
|
+
}) : title);
|
|
151
81
|
let dialogHeight = height;
|
|
152
82
|
if (height && height.match(/px$/)) {
|
|
153
83
|
dialogHeight = height.replace("px", "");
|
|
@@ -174,25 +104,21 @@ const Dialog = /*#__PURE__*/forwardRef(({
|
|
|
174
104
|
wrapperRef: containerRef,
|
|
175
105
|
isOpen: open,
|
|
176
106
|
additionalWrapperRefs: focusableContainers
|
|
177
|
-
}, /*#__PURE__*/React.createElement(StyledDialog, _extends({
|
|
107
|
+
}, /*#__PURE__*/React.createElement(DialogPositioner, null, /*#__PURE__*/React.createElement(StyledDialog, _extends({
|
|
178
108
|
"data-component": dataComponent,
|
|
179
109
|
"data-element": dataElement,
|
|
180
110
|
"data-role": dataRole,
|
|
181
111
|
"aria-modal": isTopModal ? true : undefined,
|
|
182
|
-
ref: containerRef
|
|
183
|
-
topMargin: isDialogMaximised && breakpointOffset ? breakpointOffset * 2 : TOP_MARGIN
|
|
112
|
+
ref: containerRef
|
|
184
113
|
}, dialogProps, {
|
|
185
114
|
role: role,
|
|
186
115
|
tabIndex: -1
|
|
187
116
|
}, contentPadding, {
|
|
188
117
|
backgroundColor: greyBackground ? "var(--colorsUtilityMajor025)" : "var(--colorsUtilityYang100)"
|
|
189
|
-
}), dialogTitle
|
|
118
|
+
}), dialogTitle, closeIcon, /*#__PURE__*/React.createElement(StyledDialogContent, _extends({}, contentPadding, {
|
|
190
119
|
"data-role": "dialog-content",
|
|
191
120
|
tabIndex: -1
|
|
192
|
-
}),
|
|
193
|
-
"data-role": "dialog-inner-content",
|
|
194
|
-
ref: innerContentRef
|
|
195
|
-
}, contentPadding), children)))));
|
|
121
|
+
}), children)))));
|
|
196
122
|
});
|
|
197
123
|
if (process.env.NODE_ENV !== "production") {
|
|
198
124
|
Dialog.propTypes = {
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
export declare const DIALOG_SIZES: readonly ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large", "maximise"];
|
|
2
|
-
export declare const TOP_MARGIN = 20;
|
|
3
|
-
export declare const CONTENT_TOP_PADDING = 24;
|
|
4
|
-
export declare const HORIZONTAL_PADDING = 32;
|
|
5
|
-
export declare const CONTENT_BOTTOM_PADDING = 30;
|
|
6
2
|
export declare type DialogSizes = typeof DIALOG_SIZES[number];
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export const DIALOG_SIZES = ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large", "maximise"];
|
|
2
|
-
export const TOP_MARGIN = 20;
|
|
3
|
-
export const CONTENT_TOP_PADDING = 24;
|
|
4
|
-
export const HORIZONTAL_PADDING = 32;
|
|
5
|
-
export const CONTENT_BOTTOM_PADDING = 30;
|
|
1
|
+
export const DIALOG_SIZES = ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large", "maximise"];
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
size?: DialogSizes;
|
|
6
|
-
dialogHeight?: string;
|
|
1
|
+
import { ContentPaddingInterface, DialogProps } from "./dialog.component";
|
|
2
|
+
declare const DialogPositioner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
declare const StyledDialog: import("styled-components").StyledComponent<"div", any, Required<Pick<DialogProps, "size">> & {
|
|
4
|
+
dialogHeight?: string | undefined;
|
|
7
5
|
backgroundColor: string;
|
|
8
|
-
}
|
|
9
|
-
declare const StyledDialog: import("styled-components").StyledComponent<"div", any, {
|
|
10
|
-
isDialogMaximised: boolean;
|
|
11
|
-
isDialogMaximisedSmallViewport: boolean;
|
|
12
|
-
isDialogMaximisedLargeViewport: boolean;
|
|
13
|
-
} & StyledDialogProps & ContentPaddingInterface, "isDialogMaximised" | "isDialogMaximisedSmallViewport" | "isDialogMaximisedLargeViewport">;
|
|
6
|
+
} & ContentPaddingInterface, never>;
|
|
14
7
|
declare type StyledDialogTitleProps = {
|
|
15
8
|
showCloseIcon?: boolean;
|
|
16
9
|
hasSubtitle?: boolean;
|
|
17
10
|
};
|
|
18
11
|
declare const StyledDialogTitle: import("styled-components").StyledComponent<"div", any, StyledDialogTitleProps, never>;
|
|
19
12
|
declare const StyledDialogContent: import("styled-components").StyledComponent<"div", any, ContentPaddingInterface, never>;
|
|
20
|
-
|
|
21
|
-
export { StyledDialog, StyledDialogTitle, StyledDialogContent, StyledDialogInnerContent, };
|
|
13
|
+
export { DialogPositioner, StyledDialog, StyledDialogTitle, StyledDialogContent, };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { padding as paddingFn } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
-
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
5
|
-
import { StyledForm, StyledFormFooter, StyledFormContent } from "../form/form.style";
|
|
6
4
|
import { StyledHeaderContent, StyledHeading, StyledHeadingTitle } from "../heading/heading.style";
|
|
7
5
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
8
|
-
import {
|
|
6
|
+
import { StyledFormContent, StyledForm, StyledFormFooter } from "../form/form.style";
|
|
9
7
|
const dialogSizes = {
|
|
10
8
|
auto: "fit-content",
|
|
11
9
|
"extra-small": "300px",
|
|
@@ -16,38 +14,38 @@ const dialogSizes = {
|
|
|
16
14
|
large: "960px",
|
|
17
15
|
"extra-large": "1080px"
|
|
18
16
|
};
|
|
19
|
-
const
|
|
20
|
-
py,
|
|
21
|
-
p
|
|
22
|
-
}) => [py, p].some(padding => padding !== undefined) ? 0 : `${CONTENT_TOP_PADDING}px`;
|
|
23
|
-
const StyledDialog = styled.div.attrs(({
|
|
24
|
-
topMargin,
|
|
25
|
-
size
|
|
26
|
-
}) => {
|
|
27
|
-
const isDialogMaximised = size === "maximise";
|
|
28
|
-
const isDialogMaximisedSmallViewport = topMargin === 32;
|
|
29
|
-
const isDialogMaximisedLargeViewport = topMargin === 64;
|
|
30
|
-
return {
|
|
31
|
-
isDialogMaximised,
|
|
32
|
-
isDialogMaximisedSmallViewport,
|
|
33
|
-
isDialogMaximisedLargeViewport
|
|
34
|
-
};
|
|
35
|
-
})`
|
|
36
|
-
box-shadow: var(--boxShadow300);
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
border-radius: var(--borderRadius200);
|
|
17
|
+
const DialogPositioner = styled.div`
|
|
40
18
|
position: fixed;
|
|
41
|
-
|
|
19
|
+
inset: 0;
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
42
23
|
z-index: ${({
|
|
43
24
|
theme
|
|
44
25
|
}) => theme.zIndex.modal};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
`;
|
|
27
|
+
const StyledDialog = styled.div`
|
|
28
|
+
box-shadow: var(--boxShadow300);
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
position: relative;
|
|
32
|
+
border-radius: var(--borderRadius200);
|
|
33
|
+
|
|
48
34
|
${({
|
|
49
|
-
|
|
50
|
-
}) =>
|
|
35
|
+
size
|
|
36
|
+
}) => size === "maximise" ? css`
|
|
37
|
+
height: calc(100% - var(--spacing400));
|
|
38
|
+
width: calc(100% - var(--spacing400));
|
|
39
|
+
|
|
40
|
+
@media screen and (min-width: 960px) {
|
|
41
|
+
height: calc(100% - var(--spacing800));
|
|
42
|
+
width: calc(100% - var(--spacing800));
|
|
43
|
+
}
|
|
44
|
+
` : css`
|
|
45
|
+
max-height: 90vh;
|
|
46
|
+
max-width: ${dialogSizes[size]};
|
|
47
|
+
width: 100%;
|
|
48
|
+
`};
|
|
51
49
|
|
|
52
50
|
&:focus {
|
|
53
51
|
outline: none;
|
|
@@ -59,46 +57,12 @@ const StyledDialog = styled.div.attrs(({
|
|
|
59
57
|
background-color: ${backgroundColor};
|
|
60
58
|
`}
|
|
61
59
|
|
|
62
|
-
${({
|
|
63
|
-
size,
|
|
64
|
-
topMargin
|
|
65
|
-
}) => size && css`
|
|
66
|
-
max-width: ${size === "maximise" ? `calc(100vw - ${topMargin}px)` : dialogSizes[size]};
|
|
67
|
-
width: 100%;
|
|
68
|
-
`}
|
|
69
|
-
|
|
70
60
|
${({
|
|
71
61
|
dialogHeight
|
|
72
62
|
}) => dialogHeight && css`
|
|
73
63
|
height: ${dialogHeight}px;
|
|
74
64
|
`}
|
|
75
|
-
|
|
76
|
-
/* We're overriding the max-height on the form content to account for a larger height when in a smaller viewport.
|
|
77
|
-
TODO: Remove this upon the completion of FE-6643. */
|
|
78
|
-
${StyledForm} {
|
|
79
|
-
${({
|
|
80
|
-
isDialogMaximised,
|
|
81
|
-
isDialogMaximisedSmallViewport
|
|
82
|
-
}) => isDialogMaximised && css`
|
|
83
|
-
${isDialogMaximisedSmallViewport && "max-height: calc(100vh - 184px);"}
|
|
84
|
-
height: 100%;
|
|
85
|
-
`}
|
|
86
|
-
|
|
87
|
-
padding-bottom: 0px;
|
|
88
|
-
box-sizing: border-box;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
${StyledFormContent}.sticky {
|
|
92
|
-
${props => calculateFormSpacingValues(props, true)}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
${StyledFormFooter}.sticky {
|
|
96
|
-
${calculateWidthValue}
|
|
97
|
-
${props => calculateFormSpacingValues(props, false)}
|
|
98
|
-
border-bottom-right-radius: var(--borderRadius200);
|
|
99
|
-
border-bottom-left-radius: var(--borderRadius200);
|
|
100
|
-
}
|
|
101
|
-
|
|
65
|
+
|
|
102
66
|
> ${StyledIconButton} {
|
|
103
67
|
margin: 0;
|
|
104
68
|
position: absolute;
|
|
@@ -113,7 +77,7 @@ const StyledDialog = styled.div.attrs(({
|
|
|
113
77
|
`;
|
|
114
78
|
const StyledDialogTitle = styled.div`
|
|
115
79
|
background-color: var(--colorsUtilityYang100);
|
|
116
|
-
padding: 23px
|
|
80
|
+
padding: 23px 32px 0;
|
|
117
81
|
border-bottom: 1px solid #ccd6db;
|
|
118
82
|
border-top-right-radius: var(--borderRadius200);
|
|
119
83
|
border-top-left-radius: var(--borderRadius200);
|
|
@@ -141,29 +105,36 @@ const StyledDialogTitle = styled.div`
|
|
|
141
105
|
`;
|
|
142
106
|
const StyledDialogContent = styled.div`
|
|
143
107
|
box-sizing: border-box;
|
|
144
|
-
display:
|
|
145
|
-
flex-direction: column;
|
|
108
|
+
display: block;
|
|
146
109
|
overflow-y: auto;
|
|
147
|
-
|
|
148
|
-
/* Delegate handling overflow to child form if it has a sticky footer */
|
|
149
|
-
&:has(${StyledFormContent}.sticky) {
|
|
150
|
-
overflow-y: inherit;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
110
|
width: 100%;
|
|
154
|
-
flex: 1;
|
|
155
|
-
|
|
111
|
+
flex-grow: 1;
|
|
112
|
+
|
|
113
|
+
padding: 24px 32px 30px;
|
|
156
114
|
${paddingFn}
|
|
115
|
+
|
|
116
|
+
&:has(${StyledForm}.sticky) {
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
padding: 0;
|
|
120
|
+
|
|
121
|
+
${StyledForm}.sticky {
|
|
122
|
+
${StyledFormContent} {
|
|
123
|
+
padding: 24px 32px 30px;
|
|
124
|
+
${paddingFn}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
${StyledFormFooter} {
|
|
128
|
+
border-bottom-right-radius: var(--borderRadius200);
|
|
129
|
+
border-bottom-left-radius: var(--borderRadius200);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
157
133
|
`;
|
|
158
|
-
|
|
159
|
-
position: relative;
|
|
160
|
-
flex: 1;
|
|
161
|
-
padding-top: ${calculatePaddingTopInnerContent};
|
|
162
|
-
`;
|
|
163
|
-
StyledDialog.defaultProps = {
|
|
134
|
+
DialogPositioner.defaultProps = {
|
|
164
135
|
theme: baseTheme
|
|
165
136
|
};
|
|
166
137
|
StyledDialogContent.defaultProps = {
|
|
167
138
|
theme: baseTheme
|
|
168
139
|
};
|
|
169
|
-
export { StyledDialog, StyledDialogTitle, StyledDialogContent
|
|
140
|
+
export { DialogPositioner, StyledDialog, StyledDialogTitle, StyledDialogContent };
|
|
@@ -1,87 +1,45 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import {
|
|
2
|
+
import { StyledForm, StyledFormContent } from "../form/form.style";
|
|
3
|
+
function computePadding() {
|
|
4
|
+
return css`
|
|
5
|
+
padding: 0 16px;
|
|
6
|
+
@media screen and (min-width: 600px) {
|
|
7
|
+
padding: 0 24px;
|
|
8
|
+
}
|
|
9
|
+
@media screen and (min-width: 960px) {
|
|
10
|
+
padding: 0 32px;
|
|
11
|
+
}
|
|
12
|
+
@media screen and (min-width: 1260px) {
|
|
13
|
+
padding: 0 40px;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
3
17
|
const StyledContent = styled.div`
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
display: block;
|
|
4
20
|
overflow-y: auto;
|
|
5
|
-
padding: 0 16px;
|
|
6
|
-
flex: 1;
|
|
7
21
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
overflow-y: inherit;
|
|
11
|
-
}
|
|
22
|
+
flex: 1;
|
|
23
|
+
width: 100%;
|
|
12
24
|
|
|
13
25
|
${({
|
|
14
26
|
disableContentPadding
|
|
15
|
-
}) =>
|
|
16
|
-
${!disableContentPadding && css`
|
|
17
|
-
@media screen and (min-width: 600px) {
|
|
18
|
-
padding: 0 24px;
|
|
19
|
-
}
|
|
20
|
-
@media screen and (min-width: 960px) {
|
|
21
|
-
padding: 0 32px;
|
|
22
|
-
}
|
|
23
|
-
@media screen and (min-width: 1260px) {
|
|
24
|
-
padding: 0 40px;
|
|
25
|
-
}
|
|
27
|
+
}) => disableContentPadding ? "padding: 0" : computePadding()}
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@media screen and (min-width: 600px) {
|
|
34
|
-
padding-right: 24px;
|
|
35
|
-
padding-left: 24px;
|
|
36
|
-
margin-right: -24px;
|
|
37
|
-
margin-left: -24px;
|
|
38
|
-
}
|
|
39
|
-
@media screen and (min-width: 960px) {
|
|
40
|
-
padding-right: 32px;
|
|
41
|
-
padding-left: 32px;
|
|
42
|
-
margin-right: -32px;
|
|
43
|
-
margin-left: -32px;
|
|
44
|
-
}
|
|
45
|
-
@media screen and (min-width: 1260px) {
|
|
46
|
-
padding-right: 40px;
|
|
47
|
-
padding-left: 40px;
|
|
48
|
-
margin-right: -40px;
|
|
49
|
-
margin-left: -40px;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
29
|
+
&:has(${StyledForm}.sticky) {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
overflow-y: hidden;
|
|
33
|
+
padding: 0;
|
|
52
34
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
width: calc(100% + 32px);
|
|
59
|
-
|
|
60
|
-
@media screen and (min-width: 600px) {
|
|
61
|
-
padding: 16px 24px;
|
|
62
|
-
margin-right: -24px;
|
|
63
|
-
margin-left: -24px;
|
|
64
|
-
width: calc(100% + 48px);
|
|
65
|
-
}
|
|
66
|
-
@media screen and (min-width: 960px) {
|
|
67
|
-
padding: 16px 32px;
|
|
68
|
-
margin-right: -32px;
|
|
69
|
-
margin-left: -32px;
|
|
70
|
-
width: calc(100% + 64px);
|
|
71
|
-
}
|
|
72
|
-
@media screen and (min-width: 1260px) {
|
|
73
|
-
padding: 16px 40px;
|
|
74
|
-
margin-right: -40px;
|
|
75
|
-
margin-left: -40px;
|
|
76
|
-
width: calc(100% + 80px);
|
|
77
|
-
}
|
|
35
|
+
${StyledForm}.sticky {
|
|
36
|
+
${StyledFormContent} {
|
|
37
|
+
${({
|
|
38
|
+
disableContentPadding
|
|
39
|
+
}) => disableContentPadding ? "padding: 0" : computePadding()}
|
|
78
40
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
${disableContentPadding && css`
|
|
82
|
-
padding: 0;
|
|
83
|
-
`}
|
|
84
|
-
`}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
85
43
|
|
|
86
44
|
${({
|
|
87
45
|
hasHeader
|
|
@@ -4,7 +4,6 @@ import StyledContent from "./content.style";
|
|
|
4
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
5
5
|
import StyledFullScreenHeading from "../../__internal__/full-screen-heading/full-screen-heading.style";
|
|
6
6
|
import { StyledHeader, StyledHeaderContent, StyledHeading } from "../heading/heading.style";
|
|
7
|
-
import { StyledForm } from "../form/form.style";
|
|
8
7
|
const StyledDialogFullScreen = styled.div`
|
|
9
8
|
:focus {
|
|
10
9
|
outline: none;
|
|
@@ -22,10 +21,6 @@ const StyledDialogFullScreen = styled.div`
|
|
|
22
21
|
display: flex;
|
|
23
22
|
flex-direction: column;
|
|
24
23
|
|
|
25
|
-
${StyledForm} {
|
|
26
|
-
min-height: 100%;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
${StyledHeaderContent} {
|
|
30
25
|
align-items: baseline;
|
|
31
26
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useContext, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import SidebarContext from "../sidebar/__internal__/sidebar.context";
|
|
5
|
-
import ModalContext from "../modal/__internal__/modal.context";
|
|
6
4
|
import FormSummary from "./__internal__/form-summary.component";
|
|
7
5
|
import { StyledForm, StyledFormContent, StyledFormFooter, StyledLeftButtons, StyledRightButtons } from "./form.style";
|
|
8
6
|
import { formSpacing } from "./form.config";
|
|
9
7
|
import FormSpacingProvider from "../../__internal__/form-spacing-provider";
|
|
8
|
+
import ModalContext from "../modal/__internal__/modal.context";
|
|
10
9
|
export const Form = ({
|
|
11
10
|
children,
|
|
12
11
|
saveButton,
|
|
@@ -24,45 +23,37 @@ export const Form = ({
|
|
|
24
23
|
footerPadding = {},
|
|
25
24
|
...rest
|
|
26
25
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
} = useContext(SidebarContext);
|
|
26
|
+
const formRef = useRef(null);
|
|
27
|
+
const formFooterRef = useRef(null);
|
|
30
28
|
const {
|
|
31
29
|
isInModal
|
|
32
30
|
} = useContext(ModalContext);
|
|
33
|
-
const formRef = useRef(null);
|
|
34
|
-
const formFooterRef = useRef(null);
|
|
35
|
-
const hasPadding = !!Object.keys(footerPadding).length;
|
|
36
31
|
const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
|
|
37
|
-
const classNames = `${stickyFooter ? "sticky" : ""} ${hasPadding ? "padded" : ""}`.trimEnd();
|
|
38
32
|
return /*#__PURE__*/React.createElement(StyledForm, _extends({
|
|
39
33
|
ref: formRef,
|
|
34
|
+
className: stickyFooter ? "sticky" : "",
|
|
40
35
|
stickyFooter: stickyFooter,
|
|
41
36
|
onSubmit: onSubmit,
|
|
42
37
|
"data-component": "form",
|
|
43
38
|
fieldSpacing: fieldSpacing,
|
|
44
39
|
noValidate: noValidate,
|
|
45
|
-
isInSidebar: isInSidebar,
|
|
46
40
|
height: height,
|
|
47
41
|
isInModal: isInModal
|
|
48
42
|
}, rest), /*#__PURE__*/React.createElement(StyledFormContent, {
|
|
49
43
|
"data-element": "form-content",
|
|
50
44
|
"data-role": "form-content",
|
|
51
|
-
className: stickyFooter ? "sticky" : "",
|
|
52
45
|
stickyFooter: stickyFooter,
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
tabIndex: -1,
|
|
47
|
+
isInModal: isInModal
|
|
55
48
|
}, /*#__PURE__*/React.createElement(FormSpacingProvider, {
|
|
56
49
|
marginBottom: formSpacing[fieldSpacing]
|
|
57
50
|
}, children)), renderFooter && /*#__PURE__*/React.createElement(StyledFormFooter, _extends({
|
|
58
51
|
"data-element": "form-footer",
|
|
59
52
|
"data-role": "form-footer",
|
|
60
|
-
className: classNames,
|
|
61
53
|
ref: formFooterRef,
|
|
62
54
|
stickyFooter: stickyFooter,
|
|
63
55
|
buttonAlignment: buttonAlignment,
|
|
64
|
-
fullWidthButtons: fullWidthButtons
|
|
65
|
-
isInModal: isInModal
|
|
56
|
+
fullWidthButtons: fullWidthButtons
|
|
66
57
|
}, footerPadding), leftSideButtons && /*#__PURE__*/React.createElement(StyledLeftButtons, {
|
|
67
58
|
"data-role": "form-left-buttons",
|
|
68
59
|
buttonAlignment: buttonAlignment
|
|
@@ -4,17 +4,21 @@ interface StyledFormContentProps {
|
|
|
4
4
|
isInModal?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare const StyledFormContent: import("styled-components").StyledComponent<"div", any, StyledFormContentProps, never>;
|
|
7
|
-
interface
|
|
8
|
-
|
|
7
|
+
interface StyledFormFooterProps {
|
|
8
|
+
stickyFooter?: boolean;
|
|
9
9
|
fullWidthButtons?: boolean;
|
|
10
|
+
buttonAlignment?: FormButtonAlignment;
|
|
10
11
|
}
|
|
11
|
-
export declare const StyledFormFooter: import("styled-components").StyledComponent<"div", any,
|
|
12
|
+
export declare const StyledFormFooter: import("styled-components").StyledComponent<"div", any, StyledFormFooterProps, never>;
|
|
12
13
|
interface StyledFormProps extends StyledFormContentProps {
|
|
13
14
|
height?: string;
|
|
14
15
|
fieldSpacing: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
15
|
-
isInSidebar?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare const StyledForm: import("styled-components").StyledComponent<"form", any, StyledFormProps, never>;
|
|
18
|
-
export declare const StyledRightButtons: import("styled-components").StyledComponent<"div", any,
|
|
19
|
-
|
|
18
|
+
export declare const StyledRightButtons: import("styled-components").StyledComponent<"div", any, {
|
|
19
|
+
buttonAlignment?: "left" | "right" | undefined;
|
|
20
|
+
}, never>;
|
|
21
|
+
export declare const StyledLeftButtons: import("styled-components").StyledComponent<"div", any, {
|
|
22
|
+
buttonAlignment?: "left" | "right" | undefined;
|
|
23
|
+
}, never>;
|
|
20
24
|
export {};
|