carbon-react 143.2.5 → 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.
Files changed (51) hide show
  1. package/esm/components/advanced-color-picker/advanced-color-picker.style.js +1 -5
  2. package/esm/components/dialog/dialog.component.js +29 -103
  3. package/esm/components/dialog/dialog.config.d.ts +0 -4
  4. package/esm/components/dialog/dialog.config.js +1 -5
  5. package/esm/components/dialog/dialog.style.d.ts +6 -14
  6. package/esm/components/dialog/dialog.style.js +54 -83
  7. package/esm/components/dialog-full-screen/content.style.js +32 -74
  8. package/esm/components/dialog-full-screen/dialog-full-screen.style.js +0 -5
  9. package/esm/components/form/form.component.js +8 -17
  10. package/esm/components/form/form.style.d.ts +10 -6
  11. package/esm/components/form/form.style.js +12 -25
  12. package/esm/components/menu/__internal__/submenu/submenu.style.js +8 -5
  13. package/esm/components/menu/menu-item/menu-item.component.d.ts +1 -1
  14. package/esm/components/menu/menu-item/menu-item.component.js +3 -1
  15. package/esm/components/menu/menu-item/menu-item.style.d.ts +1 -0
  16. package/esm/components/menu/menu-item/menu-item.style.js +58 -24
  17. package/esm/components/menu/menu.component.d.ts +1 -1
  18. package/esm/components/menu/menu.style.js +13 -0
  19. package/esm/components/sidebar/sidebar.component.js +8 -18
  20. package/esm/components/sidebar/sidebar.config.d.ts +0 -4
  21. package/esm/components/sidebar/sidebar.config.js +1 -5
  22. package/esm/components/sidebar/sidebar.style.d.ts +4 -2
  23. package/esm/components/sidebar/sidebar.style.js +26 -12
  24. package/lib/components/advanced-color-picker/advanced-color-picker.style.js +0 -4
  25. package/lib/components/dialog/dialog.component.js +27 -101
  26. package/lib/components/dialog/dialog.config.d.ts +0 -4
  27. package/lib/components/dialog/dialog.config.js +2 -6
  28. package/lib/components/dialog/dialog.style.d.ts +6 -14
  29. package/lib/components/dialog/dialog.style.js +54 -83
  30. package/lib/components/dialog-full-screen/content.style.js +31 -73
  31. package/lib/components/dialog-full-screen/dialog-full-screen.style.js +0 -5
  32. package/lib/components/form/form.component.js +7 -16
  33. package/lib/components/form/form.style.d.ts +10 -6
  34. package/lib/components/form/form.style.js +12 -25
  35. package/lib/components/menu/__internal__/submenu/submenu.style.js +8 -5
  36. package/lib/components/menu/menu-item/menu-item.component.d.ts +1 -1
  37. package/lib/components/menu/menu-item/menu-item.component.js +3 -1
  38. package/lib/components/menu/menu-item/menu-item.style.d.ts +1 -0
  39. package/lib/components/menu/menu-item/menu-item.style.js +58 -24
  40. package/lib/components/menu/menu.component.d.ts +1 -1
  41. package/lib/components/menu/menu.style.js +13 -0
  42. package/lib/components/sidebar/sidebar.component.js +7 -17
  43. package/lib/components/sidebar/sidebar.config.d.ts +0 -4
  44. package/lib/components/sidebar/sidebar.config.js +2 -6
  45. package/lib/components/sidebar/sidebar.style.d.ts +4 -2
  46. package/lib/components/sidebar/sidebar.style.js +28 -15
  47. package/package.json +1 -1
  48. package/esm/style/utils/form-style-utils.d.ts +0 -21
  49. package/esm/style/utils/form-style-utils.js +0 -92
  50. package/lib/style/utils/form-style-utils.d.ts +0 -21
  51. package/lib/style/utils/form-style-utils.js +0 -100
@@ -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
- ${stickyFooter && (0, _styledComponents.css)`
22
- /* Take responsibility for handling overflow away from parent modal */
23
- overflow-y: ${isInModal ? "auto" : "inherit"};
24
- flex: 1;
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
- ${!isInModal && (0, _styledComponents.css)`
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
- max-height: calc(100vh - ${HEIGHT_SPACING}px);
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
  `;
@@ -21,6 +21,7 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
21
21
  position: relative;
22
22
  width: fit-content;
23
23
  max-width: inherit;
24
+ height: inherit;
24
25
 
25
26
  ${({
26
27
  isSubmenuOpen,
@@ -33,7 +34,8 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
33
34
  inFullscreenView,
34
35
  menuType,
35
36
  asPassiveItem
36
- }) => inFullscreenView && (0, _styledComponents.css)`
37
+ }) => (0, _styledComponents.css)`
38
+ ${inFullscreenView && (0, _styledComponents.css)`
37
39
  width: 100%;
38
40
 
39
41
  ${asPassiveItem && menuType && (0, _styledComponents.css)`
@@ -43,6 +45,10 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
43
45
  }
44
46
  `}
45
47
  `}
48
+ ${!inFullscreenView && (0, _styledComponents.css)`
49
+ display: flex;
50
+ `}
51
+ `}
46
52
  `;
47
53
  const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
48
54
  ${({
@@ -58,6 +64,7 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
58
64
  ${!inFullscreenView && menuType && (0, _styledComponents.css)`
59
65
  box-shadow: var(--boxShadow100);
60
66
  position: absolute;
67
+ top: 100%;
61
68
  background-color: ${variant === "default" ? _menu2.default[menuType].submenuItemBackground : _menu2.default[menuType].background};
62
69
 
63
70
  min-width: 100%;
@@ -179,10 +186,6 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
179
186
  > a,
180
187
  > button {
181
188
  padding: 11px 16px 12px;
182
-
183
- :has([data-component="icon"]) {
184
- padding: 9px 16px 7px;
185
- }
186
189
  }
187
190
  `}
188
191
 
@@ -3,7 +3,7 @@ import { FlexboxProps, LayoutProps, MaxWidthProps, PaddingProps } from "styled-s
3
3
  import { IconType } from "../../icon";
4
4
  import { TagProps } from "../../../__internal__/utils/helpers/tags";
5
5
  export declare type VariantType = "default" | "alternate";
6
- interface MenuItemBaseProps extends Omit<TagProps, "data-component">, LayoutProps, FlexboxProps, PaddingProps {
6
+ interface MenuItemBaseProps extends Omit<TagProps, "data-component">, Pick<LayoutProps, "width" | "maxWidth" | "minWidth">, FlexboxProps, PaddingProps {
7
7
  /** Custom className */
8
8
  className?: string;
9
9
  /** onClick handler */
@@ -46,6 +46,7 @@ const MenuItem = ({
46
46
  }) => {
47
47
  !(icon || children) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `icon` must be defined or this node must have `children`.") : (0, _invariant.default)(false) : void 0;
48
48
  !(children || ariaLabel || typeof submenu === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "If no text is provided an `ariaLabel` should be given to facilitate accessibility.") : (0, _invariant.default)(false) : void 0;
49
+ !(typeof submenu === "boolean" || submenu === undefined || children && typeof submenu === "string" && submenu.length) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "You should not pass `children` when `submenu` is an empty string") : (0, _invariant.default)(false) : void 0;
49
50
  const {
50
51
  inFullscreenView,
51
52
  registerItem,
@@ -191,7 +192,8 @@ const MenuItem = ({
191
192
  placeholderTabIndex: asPassiveItem
192
193
  }, paddingProps, {
193
194
  asDiv: hasInput || as === "div",
194
- hasInput: hasInput
195
+ hasInput: hasInput,
196
+ inSubmenu: !!handleSubmenuKeyDown
195
197
  }), children));
196
198
  };
197
199
  exports.MenuItem = MenuItem;
@@ -15,6 +15,7 @@ interface StyledMenuItemWrapperProps extends Pick<MenuWithChildren, "href" | "sh
15
15
  asDiv?: boolean;
16
16
  hasInput?: boolean;
17
17
  menuItemVariant?: Pick<MenuWithChildren, "variant">["variant"];
18
+ inSubmenu?: boolean;
18
19
  }
19
20
  declare const StyledMenuItemWrapper: import("styled-components").StyledComponent<"a", any, {
20
21
  as: import("react").ForwardRefExoticComponent<import("../../link").LinkProps & import("react").RefAttributes<HTMLButtonElement | HTMLLinkElement>>;
@@ -103,7 +103,8 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
103
103
  overrideColor,
104
104
  asPassiveItem,
105
105
  asDiv,
106
- hasInput
106
+ hasInput,
107
+ inSubmenu
107
108
  }) => (0, _styledComponents.css)`
108
109
  display: flex;
109
110
  align-items: center;
@@ -116,6 +117,9 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
116
117
  a,
117
118
  button {
118
119
  cursor: pointer;
120
+ min-height: 40px;
121
+ height: 100%;
122
+ box-sizing: border-box;
119
123
  }
120
124
 
121
125
  a:focus,
@@ -132,7 +136,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
132
136
  button:has([data-component="icon"]):not(:has(button))
133
137
  ${_link.StyledContent} {
134
138
  position: relative;
135
- top: -2px;
139
+ top: -1px;
136
140
  }
137
141
  `}
138
142
 
@@ -152,11 +156,16 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
152
156
 
153
157
  ${!inFullscreenView && (0, _styledComponents.css)`
154
158
  max-width: inherit;
159
+ width: inherit;
160
+ height: inherit;
155
161
 
156
162
  > a,
157
163
  > button {
158
164
  display: flex;
159
165
  align-items: center;
166
+ ${!inSubmenu ? "justify-content: center;" : ""}
167
+ width: inherit;
168
+ max-width: inherit;
160
169
  }
161
170
 
162
171
  && {
@@ -203,15 +212,29 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
203
212
 
204
213
  ${asPassiveItem ? `
205
214
  ${!inFullscreenView && `
206
- > a:not(:has(button)) {
207
- padding: 11px 16px 12px;
208
- }
215
+ > a:not(:has(button)) {
216
+ padding: 11px 16px;
217
+ }
209
218
 
210
- > a ${_button.default}:not(.search-button) {
211
- min-height: 17px;
212
- padding: 9px 0px 11px;
213
- }
214
- `}
219
+ > a:has(${_button.default}:not(.search-button)) {
220
+ height: 100%;
221
+
222
+ ${_link.StyledContent} {
223
+ height: inherit;
224
+
225
+ div {
226
+ height: inherit;
227
+ }
228
+ }
229
+
230
+ ${_button.default} {
231
+ min-height: 40px;
232
+ padding: 10px 0px;
233
+ box-sizing: border-box;
234
+ height: 100%;
235
+ }
236
+ }
237
+ `}
215
238
 
216
239
  ${_iconButton.default} {
217
240
  > span {
@@ -227,28 +250,37 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
227
250
  }
228
251
  }
229
252
  ` : `
230
- a,
231
- ${_link.StyledLink} a,
232
- button,
233
- ${_link.StyledLink} button {
234
-
235
- padding: ${inFullscreenView ? "0px 16px" : "11px 16px 12px"};
236
-
237
- :has([data-component="icon"]) {
238
- padding: 9px 16px 7px;
239
- }
240
- }
253
+ ${hasSubmenu || maxWidth ? `
254
+ a,
255
+ ${_link.StyledLink} a,
256
+ button,
257
+ ${_link.StyledLink} button {
258
+ padding: 11px 16px ${hasSubmenu && maxWidth ? "12px" : "10px"};
259
+ }
260
+ ` : `
261
+ a,
262
+ ${_link.StyledLink} a,
263
+ button,
264
+ ${_link.StyledLink} button {
265
+ padding: ${!inFullscreenView ? "11px" : "0px"} 16px;
266
+ }
267
+ `}
241
268
  `}
242
269
 
243
270
  button,
244
- ${_link.StyledLink} button {
245
- height: 40px;
271
+ ${_link.StyledLink} button,
272
+ a,
273
+ ${_link.StyledLink} a {
246
274
  margin: 0px;
247
275
  text-align: left;
248
276
 
249
277
  ${inFullscreenView && (0, _styledComponents.css)`
250
278
  height: auto;
251
279
  white-space: normal;
280
+
281
+ ${_icon.default} {
282
+ top: -2px;
283
+ }
252
284
  `}
253
285
  }
254
286
 
@@ -267,6 +299,8 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
267
299
  ${!inFullscreenView && (0, _styledComponents.css)`
268
300
  a > ${_icon.default}, button > ${_icon.default} {
269
301
  display: inline-block;
302
+ height: 18px;
303
+ top: -2px;
270
304
  }
271
305
  `}
272
306
  }
@@ -370,7 +404,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
370
404
  a::before,
371
405
  button::before {
372
406
  display: block;
373
- margin-top: -2px;
407
+ margin-top: -1px;
374
408
  pointer-events: none;
375
409
  position: absolute;
376
410
  right: ${props => parsePadding((0, _styledSystem.padding)(props)).iconSpacing};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { LayoutProps, FlexboxProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags";
4
4
  import { MenuType } from "./__internal__/menu.context";
5
- export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
5
+ export interface MenuProps extends TagProps, Pick<LayoutProps, "width" | "minWidth" | "maxWidth" | "overflow" | "overflowX" | "verticalAlign">, FlexboxProps {
6
6
  /** Children elements */
7
7
  children: React.ReactNode;
8
8
  /** Defines the color scheme of the component */
@@ -19,6 +19,8 @@ const StyledMenuWrapper = exports.StyledMenuWrapper = _styledComponents.default.
19
19
  padding: 0;
20
20
  outline: none;
21
21
  display: flex;
22
+ align-items: stretch;
23
+ min-height: 40px;
22
24
 
23
25
  ${_styledSystem.layout}
24
26
  ${_styledSystem.flexbox}
@@ -41,6 +43,13 @@ const StyledMenuWrapper = exports.StyledMenuWrapper = _styledComponents.default.
41
43
  }
42
44
  `;
43
45
  const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
46
+ display: flex;
47
+ ${({
48
+ maxWidth
49
+ }) => maxWidth && (0, _styledComponents.css)`
50
+ align-items: stretch;
51
+ `}
52
+
44
53
  ${_styledSystem.layout}
45
54
  ${_styledSystem.flexbox}
46
55
 
@@ -54,6 +63,10 @@ const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
54
63
  ${inSubmenu && (0, _styledComponents.css)`
55
64
  display: list-item;
56
65
  `}
66
+
67
+ ${!inSubmenu && (0, _styledComponents.css)`
68
+ height: inherit;
69
+ `}
57
70
  `}
58
71
 
59
72
  ${({
@@ -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 = _interopRequireDefault(require("./sidebar.style"));
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.default, _extends({
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
- }), header && /*#__PURE__*/_react.default.createElement(_sidebarHeader.default, _extends({
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(_box.default, _extends({
91
+ }), header), !header && closeIcon(), /*#__PURE__*/_react.default.createElement(_sidebar.StyledSidebarContent, _extends({
95
92
  "data-element": "sidebar-content",
96
- "data-role": "sidebar-content",
97
- pt: "var(--spacing300)",
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.SIDEBAR_TOP_SPACING = exports.SIDEBAR_SIZES_CSS = exports.SIDEBAR_SIZES = exports.SIDEBAR_RIGHT_PADDING = exports.SIDEBAR_LEFT_PADDING = exports.SIDEBAR_BOTTOM_SPACING = exports.SIDEBAR_ALIGNMENTS = void 0;
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 const StyledSidebar: import("styled-components").StyledComponent<"div", any, Pick<SidebarProps, "width" | "onCancel" | "size" | "position"> & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
4
- export default StyledSidebar;
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.default = void 0;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "143.2.5",
3
+ "version": "144.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -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
- };