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
|
@@ -8,88 +8,46 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
8
8
|
var _form = require("../form/form.style");
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function computePadding() {
|
|
12
|
+
return (0, _styledComponents.css)`
|
|
13
|
+
padding: 0 16px;
|
|
14
|
+
@media screen and (min-width: 600px) {
|
|
15
|
+
padding: 0 24px;
|
|
16
|
+
}
|
|
17
|
+
@media screen and (min-width: 960px) {
|
|
18
|
+
padding: 0 32px;
|
|
19
|
+
}
|
|
20
|
+
@media screen and (min-width: 1260px) {
|
|
21
|
+
padding: 0 40px;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
11
25
|
const StyledContent = _styledComponents.default.div`
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
display: block;
|
|
12
28
|
overflow-y: auto;
|
|
13
|
-
padding: 0 16px;
|
|
14
|
-
flex: 1;
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
overflow-y: inherit;
|
|
19
|
-
}
|
|
30
|
+
flex: 1;
|
|
31
|
+
width: 100%;
|
|
20
32
|
|
|
21
33
|
${({
|
|
22
34
|
disableContentPadding
|
|
23
|
-
}) =>
|
|
24
|
-
${!disableContentPadding && (0, _styledComponents.css)`
|
|
25
|
-
@media screen and (min-width: 600px) {
|
|
26
|
-
padding: 0 24px;
|
|
27
|
-
}
|
|
28
|
-
@media screen and (min-width: 960px) {
|
|
29
|
-
padding: 0 32px;
|
|
30
|
-
}
|
|
31
|
-
@media screen and (min-width: 1260px) {
|
|
32
|
-
padding: 0 40px;
|
|
33
|
-
}
|
|
35
|
+
}) => disableContentPadding ? "padding: 0" : computePadding()}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@media screen and (min-width: 600px) {
|
|
42
|
-
padding-right: 24px;
|
|
43
|
-
padding-left: 24px;
|
|
44
|
-
margin-right: -24px;
|
|
45
|
-
margin-left: -24px;
|
|
46
|
-
}
|
|
47
|
-
@media screen and (min-width: 960px) {
|
|
48
|
-
padding-right: 32px;
|
|
49
|
-
padding-left: 32px;
|
|
50
|
-
margin-right: -32px;
|
|
51
|
-
margin-left: -32px;
|
|
52
|
-
}
|
|
53
|
-
@media screen and (min-width: 1260px) {
|
|
54
|
-
padding-right: 40px;
|
|
55
|
-
padding-left: 40px;
|
|
56
|
-
margin-right: -40px;
|
|
57
|
-
margin-left: -40px;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
37
|
+
&:has(${_form.StyledForm}.sticky) {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
overflow-y: hidden;
|
|
41
|
+
padding: 0;
|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
width: calc(100% + 32px);
|
|
67
|
-
|
|
68
|
-
@media screen and (min-width: 600px) {
|
|
69
|
-
padding: 16px 24px;
|
|
70
|
-
margin-right: -24px;
|
|
71
|
-
margin-left: -24px;
|
|
72
|
-
width: calc(100% + 48px);
|
|
73
|
-
}
|
|
74
|
-
@media screen and (min-width: 960px) {
|
|
75
|
-
padding: 16px 32px;
|
|
76
|
-
margin-right: -32px;
|
|
77
|
-
margin-left: -32px;
|
|
78
|
-
width: calc(100% + 64px);
|
|
79
|
-
}
|
|
80
|
-
@media screen and (min-width: 1260px) {
|
|
81
|
-
padding: 16px 40px;
|
|
82
|
-
margin-right: -40px;
|
|
83
|
-
margin-left: -40px;
|
|
84
|
-
width: calc(100% + 80px);
|
|
85
|
-
}
|
|
43
|
+
${_form.StyledForm}.sticky {
|
|
44
|
+
${_form.StyledFormContent} {
|
|
45
|
+
${({
|
|
46
|
+
disableContentPadding
|
|
47
|
+
}) => disableContentPadding ? "padding: 0" : computePadding()}
|
|
86
48
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
${disableContentPadding && (0, _styledComponents.css)`
|
|
90
|
-
padding: 0;
|
|
91
|
-
`}
|
|
92
|
-
`}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
93
51
|
|
|
94
52
|
${({
|
|
95
53
|
hasHeader
|
|
@@ -10,7 +10,6 @@ var _content = _interopRequireDefault(require("./content.style"));
|
|
|
10
10
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
11
11
|
var _fullScreenHeading = _interopRequireDefault(require("../../__internal__/full-screen-heading/full-screen-heading.style"));
|
|
12
12
|
var _heading = require("../heading/heading.style");
|
|
13
|
-
var _form = require("../form/form.style");
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -31,10 +30,6 @@ const StyledDialogFullScreen = _styledComponents.default.div`
|
|
|
31
30
|
display: flex;
|
|
32
31
|
flex-direction: column;
|
|
33
32
|
|
|
34
|
-
${_form.StyledForm} {
|
|
35
|
-
min-height: 100%;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
${_heading.StyledHeaderContent} {
|
|
39
34
|
align-items: baseline;
|
|
40
35
|
}
|
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.Form = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _sidebar = _interopRequireDefault(require("../sidebar/__internal__/sidebar.context"));
|
|
10
|
-
var _modal = _interopRequireDefault(require("../modal/__internal__/modal.context"));
|
|
11
9
|
var _formSummary = _interopRequireDefault(require("./__internal__/form-summary.component"));
|
|
12
10
|
var _form = require("./form.style");
|
|
13
11
|
var _form2 = require("./form.config");
|
|
14
12
|
var _formSpacingProvider = _interopRequireDefault(require("../../__internal__/form-spacing-provider"));
|
|
13
|
+
var _modal = _interopRequireDefault(require("../modal/__internal__/modal.context"));
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -33,45 +32,37 @@ const Form = ({
|
|
|
33
32
|
footerPadding = {},
|
|
34
33
|
...rest
|
|
35
34
|
}) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
} = (0, _react.useContext)(_sidebar.default);
|
|
35
|
+
const formRef = (0, _react.useRef)(null);
|
|
36
|
+
const formFooterRef = (0, _react.useRef)(null);
|
|
39
37
|
const {
|
|
40
38
|
isInModal
|
|
41
39
|
} = (0, _react.useContext)(_modal.default);
|
|
42
|
-
const formRef = (0, _react.useRef)(null);
|
|
43
|
-
const formFooterRef = (0, _react.useRef)(null);
|
|
44
|
-
const hasPadding = !!Object.keys(footerPadding).length;
|
|
45
40
|
const renderFooter = !!(saveButton || leftSideButtons || rightSideButtons || errorCount || warningCount);
|
|
46
|
-
const classNames = `${stickyFooter ? "sticky" : ""} ${hasPadding ? "padded" : ""}`.trimEnd();
|
|
47
41
|
return /*#__PURE__*/_react.default.createElement(_form.StyledForm, _extends({
|
|
48
42
|
ref: formRef,
|
|
43
|
+
className: stickyFooter ? "sticky" : "",
|
|
49
44
|
stickyFooter: stickyFooter,
|
|
50
45
|
onSubmit: onSubmit,
|
|
51
46
|
"data-component": "form",
|
|
52
47
|
fieldSpacing: fieldSpacing,
|
|
53
48
|
noValidate: noValidate,
|
|
54
|
-
isInSidebar: isInSidebar,
|
|
55
49
|
height: height,
|
|
56
50
|
isInModal: isInModal
|
|
57
51
|
}, rest), /*#__PURE__*/_react.default.createElement(_form.StyledFormContent, {
|
|
58
52
|
"data-element": "form-content",
|
|
59
53
|
"data-role": "form-content",
|
|
60
|
-
className: stickyFooter ? "sticky" : "",
|
|
61
54
|
stickyFooter: stickyFooter,
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
isInModal: isInModal
|
|
64
57
|
}, /*#__PURE__*/_react.default.createElement(_formSpacingProvider.default, {
|
|
65
58
|
marginBottom: _form2.formSpacing[fieldSpacing]
|
|
66
59
|
}, children)), renderFooter && /*#__PURE__*/_react.default.createElement(_form.StyledFormFooter, _extends({
|
|
67
60
|
"data-element": "form-footer",
|
|
68
61
|
"data-role": "form-footer",
|
|
69
|
-
className: classNames,
|
|
70
62
|
ref: formFooterRef,
|
|
71
63
|
stickyFooter: stickyFooter,
|
|
72
64
|
buttonAlignment: buttonAlignment,
|
|
73
|
-
fullWidthButtons: fullWidthButtons
|
|
74
|
-
isInModal: isInModal
|
|
65
|
+
fullWidthButtons: fullWidthButtons
|
|
75
66
|
}, footerPadding), leftSideButtons && /*#__PURE__*/_react.default.createElement(_form.StyledLeftButtons, {
|
|
76
67
|
"data-role": "form-left-buttons",
|
|
77
68
|
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 {};
|
|
@@ -13,18 +13,14 @@ var _textarea = _interopRequireDefault(require("../textarea/textarea.style"));
|
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
const StyledFormContent = exports.StyledFormContent = _styledComponents.default.div
|
|
17
|
-
${({
|
|
16
|
+
const StyledFormContent = exports.StyledFormContent = _styledComponents.default.div(({
|
|
18
17
|
stickyFooter,
|
|
19
18
|
isInModal
|
|
20
|
-
}) => (0, _styledComponents.css)`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
overflow-y:
|
|
24
|
-
|
|
25
|
-
`}
|
|
26
|
-
`}
|
|
27
|
-
`;
|
|
19
|
+
}) => stickyFooter && isInModal && (0, _styledComponents.css)`
|
|
20
|
+
flex-grow: 1;
|
|
21
|
+
min-height: 0;
|
|
22
|
+
overflow-y: auto;
|
|
23
|
+
`);
|
|
28
24
|
const StyledFormFooter = exports.StyledFormFooter = _styledComponents.default.div`
|
|
29
25
|
align-items: center;
|
|
30
26
|
display: flex;
|
|
@@ -39,8 +35,7 @@ const StyledFormFooter = exports.StyledFormFooter = _styledComponents.default.di
|
|
|
39
35
|
|
|
40
36
|
${({
|
|
41
37
|
stickyFooter,
|
|
42
|
-
fullWidthButtons
|
|
43
|
-
isInModal
|
|
38
|
+
fullWidthButtons
|
|
44
39
|
}) => (0, _styledComponents.css)`
|
|
45
40
|
${!stickyFooter && (0, _styledComponents.css)`
|
|
46
41
|
margin-top: 48px;
|
|
@@ -53,9 +48,7 @@ const StyledFormFooter = exports.StyledFormFooter = _styledComponents.default.di
|
|
|
53
48
|
padding: 16px 32px;
|
|
54
49
|
width: 100%;
|
|
55
50
|
z-index: 1000;
|
|
56
|
-
|
|
57
|
-
position: sticky;
|
|
58
|
-
`}
|
|
51
|
+
position: sticky;
|
|
59
52
|
bottom: 0;
|
|
60
53
|
`}
|
|
61
54
|
|
|
@@ -70,9 +63,6 @@ const StyledFormFooter = exports.StyledFormFooter = _styledComponents.default.di
|
|
|
70
63
|
StyledFormFooter.defaultProps = {
|
|
71
64
|
theme: _base.default
|
|
72
65
|
};
|
|
73
|
-
|
|
74
|
-
// Accounts for height of the header of Modal parent, the height form footer and some additional spacing
|
|
75
|
-
const HEIGHT_SPACING = 216;
|
|
76
66
|
const StyledForm = exports.StyledForm = _styledComponents.default.form`
|
|
77
67
|
${_styledSystem.space}
|
|
78
68
|
|
|
@@ -89,19 +79,16 @@ const StyledForm = exports.StyledForm = _styledComponents.default.form`
|
|
|
89
79
|
|
|
90
80
|
${({
|
|
91
81
|
stickyFooter,
|
|
92
|
-
isInModal
|
|
93
|
-
isInSidebar
|
|
82
|
+
isInModal
|
|
94
83
|
}) => stickyFooter && (0, _styledComponents.css)`
|
|
95
84
|
display: flex;
|
|
96
85
|
flex-direction: column;
|
|
97
86
|
position: relative;
|
|
98
87
|
|
|
99
88
|
${isInModal && (0, _styledComponents.css)`
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
${isInSidebar && (0, _styledComponents.css)`
|
|
104
|
-
min-height: 100%;
|
|
89
|
+
flex-grow: 1;
|
|
90
|
+
min-height: 0;
|
|
91
|
+
height: 100%;
|
|
105
92
|
`}
|
|
106
93
|
`}
|
|
107
94
|
`;
|
|
@@ -7,12 +7,11 @@ exports.default = exports.Sidebar = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _modal = _interopRequireDefault(require("../modal"));
|
|
10
|
-
var _sidebar =
|
|
10
|
+
var _sidebar = require("./sidebar.style");
|
|
11
11
|
var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
12
12
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
13
13
|
var _focusTrap = _interopRequireDefault(require("../../__internal__/focus-trap"));
|
|
14
14
|
var _sidebarHeader = _interopRequireDefault(require("./__internal__/sidebar-header"));
|
|
15
|
-
var _box = _interopRequireDefault(require("../box"));
|
|
16
15
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
17
16
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
18
17
|
var _utils = require("../../style/utils");
|
|
@@ -53,7 +52,6 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
53
52
|
const {
|
|
54
53
|
current: headerId
|
|
55
54
|
} = (0, _react.useRef)((0, _guid.default)());
|
|
56
|
-
const hasStickyFooter = (0, _react.useMemo)(() => _react.default.Children.toArray(children).some(child => /*#__PURE__*/_react.default.isValidElement(child) && child.props.stickyFooter), [children]);
|
|
57
55
|
const sidebarRef = (0, _react.useRef)(null);
|
|
58
56
|
const setRefs = (0, _react.useCallback)(reference => {
|
|
59
57
|
sidebarRef.current = reference;
|
|
@@ -72,7 +70,7 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
72
70
|
type: "close"
|
|
73
71
|
}));
|
|
74
72
|
};
|
|
75
|
-
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.
|
|
73
|
+
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.StyledSidebar, {
|
|
76
74
|
"aria-modal": !enableBackgroundUI && isTopModal,
|
|
77
75
|
"aria-describedby": ariaDescribedBy,
|
|
78
76
|
"aria-label": ariaLabel,
|
|
@@ -84,24 +82,16 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
84
82
|
position: position,
|
|
85
83
|
size: size,
|
|
86
84
|
onCancel: onCancel,
|
|
87
|
-
role: role
|
|
88
|
-
}, (0, _utils.filterStyledSystemPaddingProps)(rest), {
|
|
85
|
+
role: role,
|
|
89
86
|
width: width
|
|
90
|
-
}
|
|
87
|
+
}, header && /*#__PURE__*/_react.default.createElement(_sidebarHeader.default, _extends({
|
|
91
88
|
closeIcon: closeIcon()
|
|
92
89
|
}, headerPadding, {
|
|
93
90
|
id: headerId
|
|
94
|
-
}), header), !header && closeIcon(), /*#__PURE__*/_react.default.createElement(
|
|
91
|
+
}), header), !header && closeIcon(), /*#__PURE__*/_react.default.createElement(_sidebar.StyledSidebarContent, _extends({
|
|
95
92
|
"data-element": "sidebar-content",
|
|
96
|
-
"data-role": "sidebar-content"
|
|
97
|
-
|
|
98
|
-
pb: "var(--spacing400)",
|
|
99
|
-
px: "var(--spacing400)"
|
|
100
|
-
}, (0, _utils.filterStyledSystemPaddingProps)(rest), {
|
|
101
|
-
scrollVariant: "light",
|
|
102
|
-
overflow: hasStickyFooter ? undefined : "auto",
|
|
103
|
-
flex: "1"
|
|
104
|
-
}), /*#__PURE__*/_react.default.createElement(_sidebar2.default.Provider, {
|
|
93
|
+
"data-role": "sidebar-content"
|
|
94
|
+
}, (0, _utils.filterStyledSystemPaddingProps)(rest)), /*#__PURE__*/_react.default.createElement(_sidebar2.default.Provider, {
|
|
105
95
|
value: {
|
|
106
96
|
isInSidebar: true
|
|
107
97
|
}
|
|
@@ -9,7 +9,3 @@ 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.
|
|
6
|
+
exports.SIDEBAR_SIZES_CSS = exports.SIDEBAR_SIZES = exports.SIDEBAR_ALIGNMENTS = void 0;
|
|
7
7
|
const SIDEBAR_SIZES_CSS = exports.SIDEBAR_SIZES_CSS = {
|
|
8
8
|
"extra-small": "214px",
|
|
9
9
|
small: "314px",
|
|
@@ -14,8 +14,4 @@ const SIDEBAR_SIZES_CSS = exports.SIDEBAR_SIZES_CSS = {
|
|
|
14
14
|
"extra-large": "814px"
|
|
15
15
|
};
|
|
16
16
|
const SIDEBAR_SIZES = exports.SIDEBAR_SIZES = ["extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
17
|
-
const SIDEBAR_ALIGNMENTS = exports.SIDEBAR_ALIGNMENTS = ["left", "right"];
|
|
18
|
-
const SIDEBAR_TOP_SPACING = exports.SIDEBAR_TOP_SPACING = "27px";
|
|
19
|
-
const SIDEBAR_BOTTOM_SPACING = exports.SIDEBAR_BOTTOM_SPACING = "var(--spacing400)";
|
|
20
|
-
const SIDEBAR_LEFT_PADDING = exports.SIDEBAR_LEFT_PADDING = "var(--spacing400)";
|
|
21
|
-
const SIDEBAR_RIGHT_PADDING = exports.SIDEBAR_RIGHT_PADDING = "var(--spacing400)";
|
|
17
|
+
const SIDEBAR_ALIGNMENTS = exports.SIDEBAR_ALIGNMENTS = ["left", "right"];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
2
|
import { SidebarProps } from "./sidebar.component";
|
|
3
|
-
declare
|
|
4
|
-
|
|
3
|
+
declare type StyledSidebarProps = Pick<SidebarProps, "onCancel" | "position" | "size" | "width">;
|
|
4
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps, never>;
|
|
5
|
+
declare const StyledSidebarContent: import("styled-components").StyledComponent<"div", any, PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
6
|
+
export { StyledSidebar, StyledSidebarContent };
|
|
@@ -3,32 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.StyledSidebarContent = exports.StyledSidebar = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
8
9
|
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
9
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
11
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
11
|
-
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
12
|
-
var _form = require("../form/form.style");
|
|
13
12
|
var _sidebar = require("./sidebar.config");
|
|
13
|
+
var _form = require("../form/form.style");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
-
const StyledSidebar = _styledComponents.default.div`
|
|
17
|
+
const StyledSidebar = exports.StyledSidebar = _styledComponents.default.div`
|
|
18
18
|
// prevents outline being added in safari
|
|
19
19
|
:focus {
|
|
20
20
|
outline: none;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
${_form.StyledFormContent} {
|
|
24
|
-
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, true, "sidebar")}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
${_form.StyledFormFooter}.sticky {
|
|
28
|
-
${_formStyleUtils.calculateWidthValue}
|
|
29
|
-
${props => (0, _formStyleUtils.calculateFormSpacingValues)(props, false, "sidebar")}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
${({
|
|
33
24
|
onCancel,
|
|
34
25
|
position,
|
|
@@ -67,7 +58,29 @@ const StyledSidebar = _styledComponents.default.div`
|
|
|
67
58
|
`}
|
|
68
59
|
`}
|
|
69
60
|
`;
|
|
61
|
+
const StyledSidebarContent = exports.StyledSidebarContent = _styledComponents.default.div`
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
display: block;
|
|
64
|
+
overflow-y: auto;
|
|
65
|
+
flex-grow: 1;
|
|
66
|
+
|
|
67
|
+
padding: var(--spacing300) var(--spacing400) var(--spacing400);
|
|
68
|
+
${_styledSystem.padding}
|
|
69
|
+
|
|
70
|
+
&:has(${_form.StyledForm}.sticky) {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
overflow-y: hidden;
|
|
74
|
+
padding: 0;
|
|
75
|
+
|
|
76
|
+
${_form.StyledForm}.sticky {
|
|
77
|
+
${_form.StyledFormContent} {
|
|
78
|
+
padding: var(--spacing300) var(--spacing400) var(--spacing400);
|
|
79
|
+
${_styledSystem.padding}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
70
84
|
StyledSidebar.defaultProps = {
|
|
71
85
|
theme: _base.default
|
|
72
|
-
};
|
|
73
|
-
var _default = exports.default = StyledSidebar;
|
|
86
|
+
};
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
":not(.padded)"?: {
|
|
14
|
-
"padding-left": string;
|
|
15
|
-
"padding-right": string;
|
|
16
|
-
} | undefined;
|
|
17
|
-
"margin-bottom": string;
|
|
18
|
-
"margin-left": string;
|
|
19
|
-
"margin-right": string;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
const parsePadding = paddingString => {
|
|
5
|
-
const paddingValues = paddingString.split(/\s+/);
|
|
6
|
-
let paddingTop, paddingBottom, paddingLeft, paddingRight;
|
|
7
|
-
switch (paddingValues.length) {
|
|
8
|
-
case 1:
|
|
9
|
-
{
|
|
10
|
-
const [value] = paddingValues;
|
|
11
|
-
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [value, value, value, value];
|
|
12
|
-
break;
|
|
13
|
-
}
|
|
14
|
-
case 2:
|
|
15
|
-
{
|
|
16
|
-
const [vertical, horizontal] = paddingValues;
|
|
17
|
-
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [vertical, horizontal, vertical, horizontal];
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case 3:
|
|
21
|
-
{
|
|
22
|
-
const [top, horizontal, bottom] = paddingValues;
|
|
23
|
-
[paddingTop, paddingRight, paddingBottom, paddingLeft] = [top, horizontal, bottom, horizontal];
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
case 4:
|
|
27
|
-
{
|
|
28
|
-
[paddingTop, paddingRight, paddingBottom, paddingLeft] = paddingValues;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
/* istanbul ignore next */
|
|
32
|
-
default:
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
paddingTop,
|
|
37
|
-
paddingBottom,
|
|
38
|
-
paddingLeft,
|
|
39
|
-
paddingRight
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const calculatePadding = props => {
|
|
43
|
-
const {
|
|
44
|
-
padding,
|
|
45
|
-
...individualPaddingProperties
|
|
46
|
-
} = paddingFn(props);
|
|
47
|
-
const result = padding ? parsePadding(padding) : {};
|
|
48
|
-
Object.assign(result, individualPaddingProperties);
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
export const calculateWidthValue = props => {
|
|
52
|
-
const {
|
|
53
|
-
paddingLeft,
|
|
54
|
-
paddingRight
|
|
55
|
-
} = calculatePadding(props);
|
|
56
|
-
const paddingValue = `(${paddingLeft ?? `${HORIZONTAL_PADDING}px`} + ${paddingRight ?? `${HORIZONTAL_PADDING}px`})`;
|
|
57
|
-
return `width: calc(100% + ${paddingValue});`;
|
|
58
|
-
};
|
|
59
|
-
export const calculateFormSpacingValues = (props, isFormContent, containerComponent = "dialog") => {
|
|
60
|
-
const {
|
|
61
|
-
paddingTop,
|
|
62
|
-
paddingBottom,
|
|
63
|
-
paddingLeft,
|
|
64
|
-
paddingRight
|
|
65
|
-
} = calculatePadding(props);
|
|
66
|
-
const isSidebar = containerComponent === "sidebar";
|
|
67
|
-
const spacingTopValue = paddingTop ?? (isSidebar ? SIDEBAR_TOP_SPACING : `${CONTENT_TOP_PADDING}px`);
|
|
68
|
-
const spacingRightValue = paddingRight ?? `${HORIZONTAL_PADDING}px`;
|
|
69
|
-
const spacingBottomValue = paddingBottom ?? (isSidebar ? SIDEBAR_BOTTOM_SPACING : `${CONTENT_BOTTOM_PADDING}px`);
|
|
70
|
-
const spacingLeftValue = paddingLeft ?? `${HORIZONTAL_PADDING}px`;
|
|
71
|
-
const setNegativeValue = value => `calc(-1 * ${value})`;
|
|
72
|
-
return {
|
|
73
|
-
"margin-left": setNegativeValue(spacingLeftValue),
|
|
74
|
-
"margin-right": setNegativeValue(spacingRightValue),
|
|
75
|
-
...(isFormContent ? {
|
|
76
|
-
"margin-top": setNegativeValue(spacingTopValue),
|
|
77
|
-
"padding-top": spacingTopValue,
|
|
78
|
-
"padding-bottom": isSidebar ? undefined : spacingBottomValue,
|
|
79
|
-
"padding-left": spacingLeftValue,
|
|
80
|
-
"padding-right": spacingRightValue
|
|
81
|
-
} : {
|
|
82
|
-
"margin-bottom": setNegativeValue(spacingBottomValue),
|
|
83
|
-
...(isSidebar && {
|
|
84
|
-
// if footer already has custom padding do not set
|
|
85
|
-
":not(.padded)": {
|
|
86
|
-
"padding-left": SIDEBAR_LEFT_PADDING,
|
|
87
|
-
"padding-right": SIDEBAR_RIGHT_PADDING
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
":not(.padded)"?: {
|
|
14
|
-
"padding-left": string;
|
|
15
|
-
"padding-right": string;
|
|
16
|
-
} | undefined;
|
|
17
|
-
"margin-bottom": string;
|
|
18
|
-
"margin-left": string;
|
|
19
|
-
"margin-right": string;
|
|
20
|
-
};
|
|
21
|
-
export {};
|