carbon-react 111.8.4 → 111.8.5
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/dialog/dialog.style.js +2 -43
- package/esm/components/form/form.style.js +0 -17
- package/esm/components/link-preview/__internal__/placeholder.component.d.ts +2 -0
- package/esm/components/link-preview/index.d.ts +2 -2
- package/esm/components/link-preview/link-preview.component.d.ts +28 -0
- package/esm/components/link-preview/link-preview.component.js +17 -30
- package/esm/components/link-preview/link-preview.style.d.ts +11 -0
- package/esm/components/sidebar/sidebar.component.js +2 -2
- package/esm/components/sidebar/sidebar.config.d.ts +4 -0
- package/esm/components/sidebar/sidebar.config.js +5 -1
- package/esm/components/sidebar/sidebar.style.d.ts +2 -1
- package/esm/components/sidebar/sidebar.style.js +11 -0
- package/esm/style/utils/form-style-utils.d.ts +19 -0
- package/esm/style/utils/form-style-utils.js +99 -0
- package/lib/components/dialog/dialog.style.js +5 -45
- package/lib/components/form/form.style.js +0 -17
- package/lib/components/link-preview/__internal__/placeholder.component.d.ts +2 -0
- package/lib/components/link-preview/index.d.ts +2 -2
- package/lib/components/link-preview/link-preview.component.d.ts +28 -0
- package/lib/components/link-preview/link-preview.component.js +18 -31
- package/lib/components/link-preview/link-preview.style.d.ts +11 -0
- package/lib/components/sidebar/sidebar.component.js +2 -2
- package/lib/components/sidebar/sidebar.config.d.ts +4 -0
- package/lib/components/sidebar/sidebar.config.js +10 -2
- package/lib/components/sidebar/sidebar.style.d.ts +2 -1
- package/lib/components/sidebar/sidebar.style.js +13 -0
- package/lib/style/utils/form-style-utils.d.ts +19 -0
- package/lib/style/utils/form-style-utils.js +113 -0
- package/package.json +1 -1
- package/esm/components/link-preview/link-preview.d.ts +0 -24
- package/lib/components/link-preview/link-preview.d.ts +0 -24
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
4
5
|
import { StyledForm, StyledFormFooter, StyledFormContent } from "../form/form.style";
|
|
5
6
|
import { StyledHeaderContent, StyledHeading, StyledHeadingTitle } from "../heading/heading.style";
|
|
6
7
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
@@ -16,48 +17,6 @@ const dialogSizes = {
|
|
|
16
17
|
"extra-large": "1080px"
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const calculateWidthValue = props => {
|
|
20
|
-
const {
|
|
21
|
-
paddingLeft,
|
|
22
|
-
paddingRight,
|
|
23
|
-
padding
|
|
24
|
-
} = paddingFn(props);
|
|
25
|
-
const paddingValue = paddingLeft ?? paddingRight ?? padding;
|
|
26
|
-
return paddingValue === undefined ? HORIZONTAL_PADDING : paddingValue;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const calculateFormSpacingValues = (props, isFormContent) => {
|
|
30
|
-
const {
|
|
31
|
-
paddingTop,
|
|
32
|
-
paddingBottom,
|
|
33
|
-
paddingLeft,
|
|
34
|
-
paddingRight,
|
|
35
|
-
padding
|
|
36
|
-
} = paddingFn(props);
|
|
37
|
-
const spacingTopValue = paddingTop ?? padding ?? CONTENT_TOP_PADDING;
|
|
38
|
-
const spacingRightValue = paddingRight ?? padding ?? HORIZONTAL_PADDING;
|
|
39
|
-
const spacingBottomValue = paddingBottom ?? padding ?? CONTENT_BOTTOM_PADDING;
|
|
40
|
-
const spacingLeftValue = paddingLeft ?? padding ?? HORIZONTAL_PADDING;
|
|
41
|
-
|
|
42
|
-
const setNegativeValue = value => `calc(-1px * ${value})`;
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
"margin-left": setNegativeValue(spacingLeftValue),
|
|
46
|
-
"margin-right": setNegativeValue(spacingRightValue),
|
|
47
|
-
...(isFormContent && {
|
|
48
|
-
"margin-top": setNegativeValue(spacingTopValue),
|
|
49
|
-
"padding-top": spacingTopValue,
|
|
50
|
-
"padding-bottom": spacingBottomValue,
|
|
51
|
-
"padding-left": spacingLeftValue,
|
|
52
|
-
"padding-right": spacingRightValue
|
|
53
|
-
}),
|
|
54
|
-
...(!isFormContent && {
|
|
55
|
-
"margin-bottom": setNegativeValue(spacingBottomValue),
|
|
56
|
-
bottom: setNegativeValue(spacingBottomValue)
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
20
|
const calculatePaddingTopInnerContent = ({
|
|
62
21
|
py,
|
|
63
22
|
p
|
|
@@ -103,7 +62,7 @@ const StyledDialog = styled.div`
|
|
|
103
62
|
}
|
|
104
63
|
|
|
105
64
|
${StyledFormFooter}.sticky {
|
|
106
|
-
|
|
65
|
+
${calculateWidthValue};
|
|
107
66
|
${props => calculateFormSpacingValues(props, false)}
|
|
108
67
|
}
|
|
109
68
|
|
|
@@ -126,23 +126,6 @@ export const StyledForm = styled.form`
|
|
|
126
126
|
|
|
127
127
|
${isInSidebar && css`
|
|
128
128
|
min-height: 100%;
|
|
129
|
-
${StyledFormContent}.sticky {
|
|
130
|
-
padding-right: var(--spacing400);
|
|
131
|
-
padding-left: var(--spacing400);
|
|
132
|
-
padding-top: 27px;
|
|
133
|
-
margin-right: calc(-1 * var(--spacing400));
|
|
134
|
-
margin-left: calc(-1 * var(--spacing400));
|
|
135
|
-
margin-top: -27px;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
${StyledFormFooter}.sticky {
|
|
139
|
-
margin-left: calc(-1 * var(--spacing400));
|
|
140
|
-
margin-bottom: calc(-1 * var(--spacing400));
|
|
141
|
-
width: calc(100% + var(--spacing800));
|
|
142
|
-
padding-left: var(--spacing400);
|
|
143
|
-
padding-right: var(--spacing400);
|
|
144
|
-
bottom: -32px;
|
|
145
|
-
}
|
|
146
129
|
`}
|
|
147
130
|
`}
|
|
148
131
|
`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./link-preview";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./link-preview.component";
|
|
2
|
+
export type { LinkPreviewProps } from "./link-preview.component";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ImageShape {
|
|
3
|
+
/** The url string to be passed to image src */
|
|
4
|
+
url: string;
|
|
5
|
+
/** The string to be passed to image alt */
|
|
6
|
+
alt?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LinkPreviewProps {
|
|
9
|
+
/** Used to set the root element to either an anchor link or div container */
|
|
10
|
+
as?: "a" | "div";
|
|
11
|
+
/** The description to be displayed */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** The config for the image to be displayed */
|
|
14
|
+
image?: ImageShape;
|
|
15
|
+
/** Flag to trigger the loading animation */
|
|
16
|
+
isLoading?: boolean;
|
|
17
|
+
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
18
|
+
onClose?: (url?: string) => void;
|
|
19
|
+
/** The title to be displayed */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** The url string to be displayed and to serve as the link's src */
|
|
22
|
+
url?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const LinkPreview: {
|
|
25
|
+
({ as, description, image, isLoading, onClose, title, url, ...rest }: LinkPreviewProps): JSX.Element;
|
|
26
|
+
displayName: string;
|
|
27
|
+
};
|
|
28
|
+
export default LinkPreview;
|
|
@@ -40,13 +40,15 @@ const LinkPreview = ({
|
|
|
40
40
|
return url;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const linkProps = canRenderAsLink ? {
|
|
44
|
+
href: url,
|
|
45
|
+
target: "_blank",
|
|
46
|
+
rel: "noopener noreferrer"
|
|
47
|
+
} : {};
|
|
43
48
|
return /*#__PURE__*/React.createElement(StyledLinkPreview, _extends({
|
|
44
49
|
as: loadingState ? "div" : as,
|
|
45
|
-
tabIndex: loadingState || as === "div" ? -1 : 0
|
|
46
|
-
|
|
47
|
-
target: canRenderAsLink ? "_blank" : undefined,
|
|
48
|
-
rel: canRenderAsLink ? "noopener noreferrer" : undefined
|
|
49
|
-
}, rest), imageProps().src ? /*#__PURE__*/React.createElement(Image, imageProps()) : /*#__PURE__*/React.createElement(Placeholder, null), /*#__PURE__*/React.createElement(StyledPreviewWrapper, {
|
|
50
|
+
tabIndex: loadingState || as === "div" ? -1 : 0
|
|
51
|
+
}, linkProps, rest), imageProps().src ? /*#__PURE__*/React.createElement(Image, imageProps()) : /*#__PURE__*/React.createElement(Placeholder, null), /*#__PURE__*/React.createElement(StyledPreviewWrapper, {
|
|
50
52
|
isLoading: loadingState
|
|
51
53
|
}, /*#__PURE__*/React.createElement(Preview, {
|
|
52
54
|
loading: loadingState,
|
|
@@ -60,32 +62,17 @@ const LinkPreview = ({
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
LinkPreview.propTypes = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** The config for the image to be displayed */
|
|
70
|
-
image: PropTypes.shape({
|
|
71
|
-
/** The url string to be passed to image src */
|
|
72
|
-
url: PropTypes.string.isRequired,
|
|
73
|
-
|
|
74
|
-
/** The string to be passed to image alt */
|
|
75
|
-
alt: PropTypes.string
|
|
65
|
+
"as": PropTypes.oneOf(["a", "div"]),
|
|
66
|
+
"description": PropTypes.string,
|
|
67
|
+
"image": PropTypes.shape({
|
|
68
|
+
"alt": PropTypes.string,
|
|
69
|
+
"url": PropTypes.string.isRequired
|
|
76
70
|
}),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
82
|
-
onClose: PropTypes.func,
|
|
83
|
-
|
|
84
|
-
/** The title to be displayed */
|
|
85
|
-
title: PropTypes.string,
|
|
86
|
-
|
|
87
|
-
/** The url string to be displayed and to serve as the link's src */
|
|
88
|
-
url: PropTypes.string
|
|
71
|
+
"isLoading": PropTypes.bool,
|
|
72
|
+
"onClose": PropTypes.func,
|
|
73
|
+
"title": PropTypes.string,
|
|
74
|
+
"url": PropTypes.string
|
|
89
75
|
};
|
|
76
|
+
export { LinkPreview };
|
|
90
77
|
LinkPreview.displayName = "LinkPreview";
|
|
91
78
|
export default LinkPreview;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const StyledLinkPreview: import("styled-components").StyledComponent<"a", any, {
|
|
2
|
+
as?: "a" | "div" | undefined;
|
|
3
|
+
}, never>;
|
|
4
|
+
declare const StyledCloseIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare const StyledPreviewWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
}, never>;
|
|
8
|
+
declare const StyledTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
declare const StyledDescription: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
declare const StyledUrl: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export { StyledLinkPreview, StyledCloseIconWrapper, StyledPreviewWrapper, StyledTitle, StyledDescription, StyledUrl, };
|
|
@@ -65,7 +65,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
65
65
|
"data-element": rest["data-element"],
|
|
66
66
|
"data-role": rest["data-role"]
|
|
67
67
|
};
|
|
68
|
-
const sidebar = /*#__PURE__*/React.createElement(StyledSidebar, {
|
|
68
|
+
const sidebar = /*#__PURE__*/React.createElement(StyledSidebar, _extends({
|
|
69
69
|
"aria-modal": !enableBackgroundUI && (topModal === null || topModal === void 0 ? void 0 : topModal.contains(sidebarRef.current)),
|
|
70
70
|
"aria-describedby": ariaDescribedBy,
|
|
71
71
|
"aria-label": ariaLabel,
|
|
@@ -76,7 +76,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
76
76
|
"data-element": "sidebar",
|
|
77
77
|
onCancel: onCancel,
|
|
78
78
|
role: role
|
|
79
|
-
}, header && /*#__PURE__*/React.createElement(SidebarHeader, {
|
|
79
|
+
}, filterStyledSystemPaddingProps(rest)), header && /*#__PURE__*/React.createElement(SidebarHeader, {
|
|
80
80
|
id: headerId
|
|
81
81
|
}, header), closeIcon(), /*#__PURE__*/React.createElement(Box, _extends({
|
|
82
82
|
"data-element": "sidebar-content",
|
|
@@ -9,3 +9,7 @@ export declare const SIDEBAR_SIZES_CSS: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const SIDEBAR_SIZES: string[];
|
|
11
11
|
export declare const SIDEBAR_ALIGNMENTS: string[];
|
|
12
|
+
export declare const SIDEBAR_TOP_SPACING = "27px";
|
|
13
|
+
export declare const SIDEBAR_BOTTOM_SPACING = "var(--spacing400)";
|
|
14
|
+
export declare const SIDEBAR_LEFT_PADDING = "var(--spacing400)";
|
|
15
|
+
export declare const SIDEBAR_RIGHT_PADDING = "var(--spacing400)";
|
|
@@ -8,4 +8,8 @@ export const SIDEBAR_SIZES_CSS = {
|
|
|
8
8
|
"extra-large": "814px"
|
|
9
9
|
};
|
|
10
10
|
export const SIDEBAR_SIZES = ["extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
11
|
-
export const SIDEBAR_ALIGNMENTS = ["left", "right"];
|
|
11
|
+
export const SIDEBAR_ALIGNMENTS = ["left", "right"];
|
|
12
|
+
export const SIDEBAR_TOP_SPACING = "27px";
|
|
13
|
+
export const SIDEBAR_BOTTOM_SPACING = "var(--spacing400)";
|
|
14
|
+
export const SIDEBAR_LEFT_PADDING = "var(--spacing400)";
|
|
15
|
+
export const SIDEBAR_RIGHT_PADDING = "var(--spacing400)";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
1
2
|
import { SidebarProps } from "./sidebar.component";
|
|
2
3
|
declare type StyledSidebarProps = {
|
|
3
4
|
onCancel?: SidebarProps["onCancel"];
|
|
4
5
|
position?: SidebarProps["position"];
|
|
5
6
|
size?: SidebarProps["size"];
|
|
6
7
|
};
|
|
7
|
-
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps
|
|
8
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
8
9
|
export default StyledSidebar;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import baseTheme from "../../style/themes/base";
|
|
3
3
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
4
|
+
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
5
|
+
import { StyledFormContent, StyledFormFooter } from "../form/form.style";
|
|
4
6
|
import { SIDEBAR_SIZES_CSS } from "./sidebar.config";
|
|
5
7
|
const StyledSidebar = styled.div`
|
|
6
8
|
// prevents outline being added in safari
|
|
@@ -8,6 +10,15 @@ const StyledSidebar = styled.div`
|
|
|
8
10
|
outline: none;
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
${StyledFormContent} {
|
|
14
|
+
${props => calculateFormSpacingValues(props, true, "sidebar")}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
${StyledFormFooter}.sticky {
|
|
18
|
+
${calculateWidthValue}
|
|
19
|
+
${props => calculateFormSpacingValues(props, false, "sidebar")}
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
${({
|
|
12
23
|
onCancel,
|
|
13
24
|
position,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
2
|
+
declare type ContainerComponent = "dialog" | "sidebar";
|
|
3
|
+
export declare const calculateWidthValue: (props: PaddingProps) => string;
|
|
4
|
+
export declare const calculateFormSpacingValues: (props: PaddingProps, isFormContent: boolean, containerComponent?: ContainerComponent) => {
|
|
5
|
+
"margin-top": string;
|
|
6
|
+
"padding-top": string;
|
|
7
|
+
"padding-bottom": string | undefined;
|
|
8
|
+
"padding-left": string;
|
|
9
|
+
"padding-right": string;
|
|
10
|
+
"margin-left": string;
|
|
11
|
+
"margin-right": string;
|
|
12
|
+
} | {
|
|
13
|
+
"margin-bottom": string;
|
|
14
|
+
"padding-left": string | undefined;
|
|
15
|
+
"padding-right": string | undefined;
|
|
16
|
+
"margin-left": string;
|
|
17
|
+
"margin-right": string;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { padding as paddingFn } from "styled-system";
|
|
2
|
+
import { HORIZONTAL_PADDING, CONTENT_TOP_PADDING, CONTENT_BOTTOM_PADDING } from "../../components/dialog/dialog.config";
|
|
3
|
+
import { SIDEBAR_TOP_SPACING, SIDEBAR_BOTTOM_SPACING, SIDEBAR_LEFT_PADDING, SIDEBAR_RIGHT_PADDING } from "../../components/sidebar/sidebar.config";
|
|
4
|
+
|
|
5
|
+
const parsePadding = paddingString => {
|
|
6
|
+
const paddingValues = paddingString.split(/\s+/);
|
|
7
|
+
let paddingTop, paddingBottom, paddingLeft, paddingRight;
|
|
8
|
+
|
|
9
|
+
switch (paddingValues.length) {
|
|
10
|
+
case 1:
|
|
11
|
+
{
|
|
12
|
+
const [value] = paddingValues;
|
|
13
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [value, value, value, value];
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
case 2:
|
|
18
|
+
{
|
|
19
|
+
const [vertical, horizontal] = paddingValues;
|
|
20
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [vertical, horizontal, vertical, horizontal];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
case 3:
|
|
25
|
+
{
|
|
26
|
+
const [top, horizontal, bottom] = paddingValues;
|
|
27
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [top, horizontal, bottom, horizontal];
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
case 4:
|
|
32
|
+
{
|
|
33
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = paddingValues;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
paddingTop,
|
|
45
|
+
paddingBottom,
|
|
46
|
+
paddingLeft,
|
|
47
|
+
paddingRight
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const calculatePadding = props => {
|
|
52
|
+
const {
|
|
53
|
+
padding,
|
|
54
|
+
...individualPaddingProperties
|
|
55
|
+
} = paddingFn(props);
|
|
56
|
+
const result = padding ? parsePadding(padding) : {};
|
|
57
|
+
Object.assign(result, individualPaddingProperties);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const calculateWidthValue = props => {
|
|
62
|
+
const {
|
|
63
|
+
paddingLeft,
|
|
64
|
+
paddingRight
|
|
65
|
+
} = calculatePadding(props);
|
|
66
|
+
const paddingValue = `(${paddingLeft ?? `${HORIZONTAL_PADDING}px`} + ${paddingRight ?? `${HORIZONTAL_PADDING}px`})`;
|
|
67
|
+
return `width: calc(100% + ${paddingValue});`;
|
|
68
|
+
};
|
|
69
|
+
export const calculateFormSpacingValues = (props, isFormContent, containerComponent = "dialog") => {
|
|
70
|
+
const {
|
|
71
|
+
paddingTop,
|
|
72
|
+
paddingBottom,
|
|
73
|
+
paddingLeft,
|
|
74
|
+
paddingRight
|
|
75
|
+
} = calculatePadding(props);
|
|
76
|
+
const isSidebar = containerComponent === "sidebar";
|
|
77
|
+
const spacingTopValue = paddingTop ?? (isSidebar ? SIDEBAR_TOP_SPACING : `${CONTENT_TOP_PADDING}px`);
|
|
78
|
+
const spacingRightValue = paddingRight ?? `${HORIZONTAL_PADDING}px`;
|
|
79
|
+
const spacingBottomValue = paddingBottom ?? (isSidebar ? SIDEBAR_BOTTOM_SPACING : `${CONTENT_BOTTOM_PADDING}px`);
|
|
80
|
+
const spacingLeftValue = paddingLeft ?? `${HORIZONTAL_PADDING}px`;
|
|
81
|
+
|
|
82
|
+
const setNegativeValue = value => `calc(-1 * ${value})`;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
"margin-left": setNegativeValue(spacingLeftValue),
|
|
86
|
+
"margin-right": setNegativeValue(spacingRightValue),
|
|
87
|
+
...(isFormContent ? {
|
|
88
|
+
"margin-top": setNegativeValue(spacingTopValue),
|
|
89
|
+
"padding-top": spacingTopValue,
|
|
90
|
+
"padding-bottom": isSidebar ? undefined : spacingBottomValue,
|
|
91
|
+
"padding-left": spacingLeftValue,
|
|
92
|
+
"padding-right": spacingRightValue
|
|
93
|
+
} : {
|
|
94
|
+
"margin-bottom": setNegativeValue(spacingBottomValue),
|
|
95
|
+
"padding-left": isSidebar ? SIDEBAR_LEFT_PADDING : undefined,
|
|
96
|
+
"padding-right": isSidebar ? SIDEBAR_RIGHT_PADDING : undefined
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
};
|
|
@@ -11,6 +11,8 @@ var _styledSystem = require("styled-system");
|
|
|
11
11
|
|
|
12
12
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
13
13
|
|
|
14
|
+
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
15
|
+
|
|
14
16
|
var _form = require("../form/form.style");
|
|
15
17
|
|
|
16
18
|
var _heading = require("../heading/heading.style");
|
|
@@ -36,48 +38,6 @@ const dialogSizes = {
|
|
|
36
38
|
"extra-large": "1080px"
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
const calculateWidthValue = props => {
|
|
40
|
-
const {
|
|
41
|
-
paddingLeft,
|
|
42
|
-
paddingRight,
|
|
43
|
-
padding
|
|
44
|
-
} = (0, _styledSystem.padding)(props);
|
|
45
|
-
const paddingValue = paddingLeft ?? paddingRight ?? padding;
|
|
46
|
-
return paddingValue === undefined ? _dialog.HORIZONTAL_PADDING : paddingValue;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const calculateFormSpacingValues = (props, isFormContent) => {
|
|
50
|
-
const {
|
|
51
|
-
paddingTop,
|
|
52
|
-
paddingBottom,
|
|
53
|
-
paddingLeft,
|
|
54
|
-
paddingRight,
|
|
55
|
-
padding
|
|
56
|
-
} = (0, _styledSystem.padding)(props);
|
|
57
|
-
const spacingTopValue = paddingTop ?? padding ?? _dialog.CONTENT_TOP_PADDING;
|
|
58
|
-
const spacingRightValue = paddingRight ?? padding ?? _dialog.HORIZONTAL_PADDING;
|
|
59
|
-
const spacingBottomValue = paddingBottom ?? padding ?? _dialog.CONTENT_BOTTOM_PADDING;
|
|
60
|
-
const spacingLeftValue = paddingLeft ?? padding ?? _dialog.HORIZONTAL_PADDING;
|
|
61
|
-
|
|
62
|
-
const setNegativeValue = value => `calc(-1px * ${value})`;
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
"margin-left": setNegativeValue(spacingLeftValue),
|
|
66
|
-
"margin-right": setNegativeValue(spacingRightValue),
|
|
67
|
-
...(isFormContent && {
|
|
68
|
-
"margin-top": setNegativeValue(spacingTopValue),
|
|
69
|
-
"padding-top": spacingTopValue,
|
|
70
|
-
"padding-bottom": spacingBottomValue,
|
|
71
|
-
"padding-left": spacingLeftValue,
|
|
72
|
-
"padding-right": spacingRightValue
|
|
73
|
-
}),
|
|
74
|
-
...(!isFormContent && {
|
|
75
|
-
"margin-bottom": setNegativeValue(spacingBottomValue),
|
|
76
|
-
bottom: setNegativeValue(spacingBottomValue)
|
|
77
|
-
})
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
41
|
const calculatePaddingTopInnerContent = ({
|
|
82
42
|
py,
|
|
83
43
|
p
|
|
@@ -119,12 +79,12 @@ const StyledDialog = _styledComponents.default.div`
|
|
|
119
79
|
}
|
|
120
80
|
|
|
121
81
|
${_form.StyledFormContent}.sticky {
|
|
122
|
-
${props => calculateFormSpacingValues(props, true)}
|
|
82
|
+
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, true)}
|
|
123
83
|
}
|
|
124
84
|
|
|
125
85
|
${_form.StyledFormFooter}.sticky {
|
|
126
|
-
|
|
127
|
-
${props => calculateFormSpacingValues(props, false)}
|
|
86
|
+
${_formStyleUtils.calculateWidthValue};
|
|
87
|
+
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, false)}
|
|
128
88
|
}
|
|
129
89
|
|
|
130
90
|
> ${_iconButton.default} {
|
|
@@ -151,23 +151,6 @@ const StyledForm = _styledComponents.default.form`
|
|
|
151
151
|
|
|
152
152
|
${isInSidebar && (0, _styledComponents.css)`
|
|
153
153
|
min-height: 100%;
|
|
154
|
-
${StyledFormContent}.sticky {
|
|
155
|
-
padding-right: var(--spacing400);
|
|
156
|
-
padding-left: var(--spacing400);
|
|
157
|
-
padding-top: 27px;
|
|
158
|
-
margin-right: calc(-1 * var(--spacing400));
|
|
159
|
-
margin-left: calc(-1 * var(--spacing400));
|
|
160
|
-
margin-top: -27px;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
${StyledFormFooter}.sticky {
|
|
164
|
-
margin-left: calc(-1 * var(--spacing400));
|
|
165
|
-
margin-bottom: calc(-1 * var(--spacing400));
|
|
166
|
-
width: calc(100% + var(--spacing800));
|
|
167
|
-
padding-left: var(--spacing400);
|
|
168
|
-
padding-right: var(--spacing400);
|
|
169
|
-
bottom: -32px;
|
|
170
|
-
}
|
|
171
154
|
`}
|
|
172
155
|
`}
|
|
173
156
|
`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./link-preview";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./link-preview.component";
|
|
2
|
+
export type { LinkPreviewProps } from "./link-preview.component";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ImageShape {
|
|
3
|
+
/** The url string to be passed to image src */
|
|
4
|
+
url: string;
|
|
5
|
+
/** The string to be passed to image alt */
|
|
6
|
+
alt?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LinkPreviewProps {
|
|
9
|
+
/** Used to set the root element to either an anchor link or div container */
|
|
10
|
+
as?: "a" | "div";
|
|
11
|
+
/** The description to be displayed */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** The config for the image to be displayed */
|
|
14
|
+
image?: ImageShape;
|
|
15
|
+
/** Flag to trigger the loading animation */
|
|
16
|
+
isLoading?: boolean;
|
|
17
|
+
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
18
|
+
onClose?: (url?: string) => void;
|
|
19
|
+
/** The title to be displayed */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** The url string to be displayed and to serve as the link's src */
|
|
22
|
+
url?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const LinkPreview: {
|
|
25
|
+
({ as, description, image, isLoading, onClose, title, url, ...rest }: LinkPreviewProps): JSX.Element;
|
|
26
|
+
displayName: string;
|
|
27
|
+
};
|
|
28
|
+
export default LinkPreview;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.LinkPreview = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -57,13 +57,15 @@ const LinkPreview = ({
|
|
|
57
57
|
return url;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
const linkProps = canRenderAsLink ? {
|
|
61
|
+
href: url,
|
|
62
|
+
target: "_blank",
|
|
63
|
+
rel: "noopener noreferrer"
|
|
64
|
+
} : {};
|
|
60
65
|
return /*#__PURE__*/_react.default.createElement(_linkPreview.StyledLinkPreview, _extends({
|
|
61
66
|
as: loadingState ? "div" : as,
|
|
62
|
-
tabIndex: loadingState || as === "div" ? -1 : 0
|
|
63
|
-
|
|
64
|
-
target: canRenderAsLink ? "_blank" : undefined,
|
|
65
|
-
rel: canRenderAsLink ? "noopener noreferrer" : undefined
|
|
66
|
-
}, rest), imageProps().src ? /*#__PURE__*/_react.default.createElement(_image.default, imageProps()) : /*#__PURE__*/_react.default.createElement(_placeholder.default, null), /*#__PURE__*/_react.default.createElement(_linkPreview.StyledPreviewWrapper, {
|
|
67
|
+
tabIndex: loadingState || as === "div" ? -1 : 0
|
|
68
|
+
}, linkProps, rest), imageProps().src ? /*#__PURE__*/_react.default.createElement(_image.default, imageProps()) : /*#__PURE__*/_react.default.createElement(_placeholder.default, null), /*#__PURE__*/_react.default.createElement(_linkPreview.StyledPreviewWrapper, {
|
|
67
69
|
isLoading: loadingState
|
|
68
70
|
}, /*#__PURE__*/_react.default.createElement(_preview.default, {
|
|
69
71
|
loading: loadingState,
|
|
@@ -76,33 +78,18 @@ const LinkPreview = ({
|
|
|
76
78
|
}))));
|
|
77
79
|
};
|
|
78
80
|
|
|
81
|
+
exports.LinkPreview = LinkPreview;
|
|
79
82
|
LinkPreview.propTypes = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/** The config for the image to be displayed */
|
|
87
|
-
image: _propTypes.default.shape({
|
|
88
|
-
/** The url string to be passed to image src */
|
|
89
|
-
url: _propTypes.default.string.isRequired,
|
|
90
|
-
|
|
91
|
-
/** The string to be passed to image alt */
|
|
92
|
-
alt: _propTypes.default.string
|
|
83
|
+
"as": _propTypes.default.oneOf(["a", "div"]),
|
|
84
|
+
"description": _propTypes.default.string,
|
|
85
|
+
"image": _propTypes.default.shape({
|
|
86
|
+
"alt": _propTypes.default.string,
|
|
87
|
+
"url": _propTypes.default.string.isRequired
|
|
93
88
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
99
|
-
onClose: _propTypes.default.func,
|
|
100
|
-
|
|
101
|
-
/** The title to be displayed */
|
|
102
|
-
title: _propTypes.default.string,
|
|
103
|
-
|
|
104
|
-
/** The url string to be displayed and to serve as the link's src */
|
|
105
|
-
url: _propTypes.default.string
|
|
89
|
+
"isLoading": _propTypes.default.bool,
|
|
90
|
+
"onClose": _propTypes.default.func,
|
|
91
|
+
"title": _propTypes.default.string,
|
|
92
|
+
"url": _propTypes.default.string
|
|
106
93
|
};
|
|
107
94
|
LinkPreview.displayName = "LinkPreview";
|
|
108
95
|
var _default = LinkPreview;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const StyledLinkPreview: import("styled-components").StyledComponent<"a", any, {
|
|
2
|
+
as?: "a" | "div" | undefined;
|
|
3
|
+
}, never>;
|
|
4
|
+
declare const StyledCloseIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare const StyledPreviewWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
}, never>;
|
|
8
|
+
declare const StyledTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
declare const StyledDescription: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
declare const StyledUrl: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export { StyledLinkPreview, StyledCloseIconWrapper, StyledPreviewWrapper, StyledTitle, StyledDescription, StyledUrl, };
|
|
@@ -95,7 +95,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
95
95
|
"data-role": rest["data-role"]
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.default, {
|
|
98
|
+
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.default, _extends({
|
|
99
99
|
"aria-modal": !enableBackgroundUI && (topModal === null || topModal === void 0 ? void 0 : topModal.contains(sidebarRef.current)),
|
|
100
100
|
"aria-describedby": ariaDescribedBy,
|
|
101
101
|
"aria-label": ariaLabel,
|
|
@@ -106,7 +106,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
106
106
|
"data-element": "sidebar",
|
|
107
107
|
onCancel: onCancel,
|
|
108
108
|
role: role
|
|
109
|
-
}, header && /*#__PURE__*/_react.default.createElement(_sidebarHeader.default, {
|
|
109
|
+
}, (0, _utils.filterStyledSystemPaddingProps)(rest)), header && /*#__PURE__*/_react.default.createElement(_sidebarHeader.default, {
|
|
110
110
|
id: headerId
|
|
111
111
|
}, header), closeIcon(), /*#__PURE__*/_react.default.createElement(_box.default, _extends({
|
|
112
112
|
"data-element": "sidebar-content",
|
|
@@ -9,3 +9,7 @@ export declare const SIDEBAR_SIZES_CSS: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const SIDEBAR_SIZES: string[];
|
|
11
11
|
export declare const SIDEBAR_ALIGNMENTS: string[];
|
|
12
|
+
export declare const SIDEBAR_TOP_SPACING = "27px";
|
|
13
|
+
export declare const SIDEBAR_BOTTOM_SPACING = "var(--spacing400)";
|
|
14
|
+
export declare const SIDEBAR_LEFT_PADDING = "var(--spacing400)";
|
|
15
|
+
export declare const SIDEBAR_RIGHT_PADDING = "var(--spacing400)";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SIDEBAR_ALIGNMENTS = exports.SIDEBAR_SIZES = exports.SIDEBAR_SIZES_CSS = void 0;
|
|
6
|
+
exports.SIDEBAR_RIGHT_PADDING = exports.SIDEBAR_LEFT_PADDING = exports.SIDEBAR_BOTTOM_SPACING = exports.SIDEBAR_TOP_SPACING = exports.SIDEBAR_ALIGNMENTS = exports.SIDEBAR_SIZES = exports.SIDEBAR_SIZES_CSS = void 0;
|
|
7
7
|
const SIDEBAR_SIZES_CSS = {
|
|
8
8
|
"extra-small": "214px",
|
|
9
9
|
small: "314px",
|
|
@@ -17,4 +17,12 @@ exports.SIDEBAR_SIZES_CSS = SIDEBAR_SIZES_CSS;
|
|
|
17
17
|
const SIDEBAR_SIZES = ["extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
18
18
|
exports.SIDEBAR_SIZES = SIDEBAR_SIZES;
|
|
19
19
|
const SIDEBAR_ALIGNMENTS = ["left", "right"];
|
|
20
|
-
exports.SIDEBAR_ALIGNMENTS = SIDEBAR_ALIGNMENTS;
|
|
20
|
+
exports.SIDEBAR_ALIGNMENTS = SIDEBAR_ALIGNMENTS;
|
|
21
|
+
const SIDEBAR_TOP_SPACING = "27px";
|
|
22
|
+
exports.SIDEBAR_TOP_SPACING = SIDEBAR_TOP_SPACING;
|
|
23
|
+
const SIDEBAR_BOTTOM_SPACING = "var(--spacing400)";
|
|
24
|
+
exports.SIDEBAR_BOTTOM_SPACING = SIDEBAR_BOTTOM_SPACING;
|
|
25
|
+
const SIDEBAR_LEFT_PADDING = "var(--spacing400)";
|
|
26
|
+
exports.SIDEBAR_LEFT_PADDING = SIDEBAR_LEFT_PADDING;
|
|
27
|
+
const SIDEBAR_RIGHT_PADDING = "var(--spacing400)";
|
|
28
|
+
exports.SIDEBAR_RIGHT_PADDING = SIDEBAR_RIGHT_PADDING;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
1
2
|
import { SidebarProps } from "./sidebar.component";
|
|
2
3
|
declare type StyledSidebarProps = {
|
|
3
4
|
onCancel?: SidebarProps["onCancel"];
|
|
4
5
|
position?: SidebarProps["position"];
|
|
5
6
|
size?: SidebarProps["size"];
|
|
6
7
|
};
|
|
7
|
-
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps
|
|
8
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
8
9
|
export default StyledSidebar;
|
|
@@ -11,6 +11,10 @@ var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
|
11
11
|
|
|
12
12
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
13
13
|
|
|
14
|
+
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
15
|
+
|
|
16
|
+
var _form = require("../form/form.style");
|
|
17
|
+
|
|
14
18
|
var _sidebar = require("./sidebar.config");
|
|
15
19
|
|
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -25,6 +29,15 @@ const StyledSidebar = _styledComponents.default.div`
|
|
|
25
29
|
outline: none;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
${_form.StyledFormContent} {
|
|
33
|
+
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, true, "sidebar")}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${_form.StyledFormFooter}.sticky {
|
|
37
|
+
${_formStyleUtils.calculateWidthValue}
|
|
38
|
+
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, false, "sidebar")}
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
${({
|
|
29
42
|
onCancel,
|
|
30
43
|
position,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
2
|
+
declare type ContainerComponent = "dialog" | "sidebar";
|
|
3
|
+
export declare const calculateWidthValue: (props: PaddingProps) => string;
|
|
4
|
+
export declare const calculateFormSpacingValues: (props: PaddingProps, isFormContent: boolean, containerComponent?: ContainerComponent) => {
|
|
5
|
+
"margin-top": string;
|
|
6
|
+
"padding-top": string;
|
|
7
|
+
"padding-bottom": string | undefined;
|
|
8
|
+
"padding-left": string;
|
|
9
|
+
"padding-right": string;
|
|
10
|
+
"margin-left": string;
|
|
11
|
+
"margin-right": string;
|
|
12
|
+
} | {
|
|
13
|
+
"margin-bottom": string;
|
|
14
|
+
"padding-left": string | undefined;
|
|
15
|
+
"padding-right": string | undefined;
|
|
16
|
+
"margin-left": string;
|
|
17
|
+
"margin-right": string;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.calculateFormSpacingValues = exports.calculateWidthValue = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
9
|
+
|
|
10
|
+
var _dialog = require("../../components/dialog/dialog.config");
|
|
11
|
+
|
|
12
|
+
var _sidebar = require("../../components/sidebar/sidebar.config");
|
|
13
|
+
|
|
14
|
+
const parsePadding = paddingString => {
|
|
15
|
+
const paddingValues = paddingString.split(/\s+/);
|
|
16
|
+
let paddingTop, paddingBottom, paddingLeft, paddingRight;
|
|
17
|
+
|
|
18
|
+
switch (paddingValues.length) {
|
|
19
|
+
case 1:
|
|
20
|
+
{
|
|
21
|
+
const [value] = paddingValues;
|
|
22
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [value, value, value, value];
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
case 2:
|
|
27
|
+
{
|
|
28
|
+
const [vertical, horizontal] = paddingValues;
|
|
29
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [vertical, horizontal, vertical, horizontal];
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
case 3:
|
|
34
|
+
{
|
|
35
|
+
const [top, horizontal, bottom] = paddingValues;
|
|
36
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [top, horizontal, bottom, horizontal];
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
case 4:
|
|
41
|
+
{
|
|
42
|
+
[paddingTop, paddingRight, paddingBottom, paddingLeft] = paddingValues;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* istanbul ignore next */
|
|
47
|
+
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
paddingTop,
|
|
54
|
+
paddingBottom,
|
|
55
|
+
paddingLeft,
|
|
56
|
+
paddingRight
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const calculatePadding = props => {
|
|
61
|
+
const {
|
|
62
|
+
padding,
|
|
63
|
+
...individualPaddingProperties
|
|
64
|
+
} = (0, _styledSystem.padding)(props);
|
|
65
|
+
const result = padding ? parsePadding(padding) : {};
|
|
66
|
+
Object.assign(result, individualPaddingProperties);
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const calculateWidthValue = props => {
|
|
71
|
+
const {
|
|
72
|
+
paddingLeft,
|
|
73
|
+
paddingRight
|
|
74
|
+
} = calculatePadding(props);
|
|
75
|
+
const paddingValue = `(${paddingLeft ?? `${_dialog.HORIZONTAL_PADDING}px`} + ${paddingRight ?? `${_dialog.HORIZONTAL_PADDING}px`})`;
|
|
76
|
+
return `width: calc(100% + ${paddingValue});`;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.calculateWidthValue = calculateWidthValue;
|
|
80
|
+
|
|
81
|
+
const calculateFormSpacingValues = (props, isFormContent, containerComponent = "dialog") => {
|
|
82
|
+
const {
|
|
83
|
+
paddingTop,
|
|
84
|
+
paddingBottom,
|
|
85
|
+
paddingLeft,
|
|
86
|
+
paddingRight
|
|
87
|
+
} = calculatePadding(props);
|
|
88
|
+
const isSidebar = containerComponent === "sidebar";
|
|
89
|
+
const spacingTopValue = paddingTop ?? (isSidebar ? _sidebar.SIDEBAR_TOP_SPACING : `${_dialog.CONTENT_TOP_PADDING}px`);
|
|
90
|
+
const spacingRightValue = paddingRight ?? `${_dialog.HORIZONTAL_PADDING}px`;
|
|
91
|
+
const spacingBottomValue = paddingBottom ?? (isSidebar ? _sidebar.SIDEBAR_BOTTOM_SPACING : `${_dialog.CONTENT_BOTTOM_PADDING}px`);
|
|
92
|
+
const spacingLeftValue = paddingLeft ?? `${_dialog.HORIZONTAL_PADDING}px`;
|
|
93
|
+
|
|
94
|
+
const setNegativeValue = value => `calc(-1 * ${value})`;
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
"margin-left": setNegativeValue(spacingLeftValue),
|
|
98
|
+
"margin-right": setNegativeValue(spacingRightValue),
|
|
99
|
+
...(isFormContent ? {
|
|
100
|
+
"margin-top": setNegativeValue(spacingTopValue),
|
|
101
|
+
"padding-top": spacingTopValue,
|
|
102
|
+
"padding-bottom": isSidebar ? undefined : spacingBottomValue,
|
|
103
|
+
"padding-left": spacingLeftValue,
|
|
104
|
+
"padding-right": spacingRightValue
|
|
105
|
+
} : {
|
|
106
|
+
"margin-bottom": setNegativeValue(spacingBottomValue),
|
|
107
|
+
"padding-left": isSidebar ? _sidebar.SIDEBAR_LEFT_PADDING : undefined,
|
|
108
|
+
"padding-right": isSidebar ? _sidebar.SIDEBAR_RIGHT_PADDING : undefined
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
exports.calculateFormSpacingValues = calculateFormSpacingValues;
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
interface ImageShape {
|
|
2
|
-
/** The url string to be passed to image src */
|
|
3
|
-
url: string;
|
|
4
|
-
/** The string to be passed to image alt */
|
|
5
|
-
alt?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface LinkPreviewProps {
|
|
9
|
-
description?: string;
|
|
10
|
-
/** The config for the image to be displayed */
|
|
11
|
-
image?: ImageShape;
|
|
12
|
-
/** Flag to trigger the loading animation */
|
|
13
|
-
isLoading?: boolean;
|
|
14
|
-
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
15
|
-
onClose?: (url: string) => void;
|
|
16
|
-
/** The title to be displayed */
|
|
17
|
-
title?: string;
|
|
18
|
-
/** The url string to be displayed and to serve as the link's src */
|
|
19
|
-
url?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function LinkPreview(props: LinkPreviewProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default LinkPreview;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
interface ImageShape {
|
|
2
|
-
/** The url string to be passed to image src */
|
|
3
|
-
url: string;
|
|
4
|
-
/** The string to be passed to image alt */
|
|
5
|
-
alt?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface LinkPreviewProps {
|
|
9
|
-
description?: string;
|
|
10
|
-
/** The config for the image to be displayed */
|
|
11
|
-
image?: ImageShape;
|
|
12
|
-
/** Flag to trigger the loading animation */
|
|
13
|
-
isLoading?: boolean;
|
|
14
|
-
/** The callback to handle the deleting of a Preview, to hide the close button do not set this prop */
|
|
15
|
-
onClose?: (url: string) => void;
|
|
16
|
-
/** The title to be displayed */
|
|
17
|
-
title?: string;
|
|
18
|
-
/** The url string to be displayed and to serve as the link's src */
|
|
19
|
-
url?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function LinkPreview(props: LinkPreviewProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default LinkPreview;
|