carbon-react 142.2.2 → 142.3.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 (53) hide show
  1. package/esm/components/decimal/decimal.component.js +2 -1
  2. package/esm/components/flat-table/flat-table-body/flat-table-body.component.d.ts +2 -1
  3. package/esm/components/flat-table/flat-table-body/flat-table-body.component.js +5 -2
  4. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +2 -1
  5. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +1 -0
  6. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -1
  7. package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +2 -1
  8. package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +2 -1
  9. package/esm/components/flat-table/flat-table.component.js +1 -1
  10. package/esm/components/flat-table/sort/sort.component.d.ts +3 -2
  11. package/esm/components/flat-table/sort/sort.component.js +10 -3
  12. package/esm/components/link/link.style.js +1 -2
  13. package/esm/components/menu/__internal__/submenu/submenu.component.d.ts +3 -0
  14. package/esm/components/menu/__internal__/submenu/submenu.component.js +8 -3
  15. package/esm/components/menu/__internal__/submenu/submenu.context.d.ts +1 -0
  16. package/esm/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
  17. package/esm/components/menu/__internal__/submenu/submenu.style.js +36 -4
  18. package/esm/components/menu/menu-item/menu-item.component.d.ts +7 -2
  19. package/esm/components/menu/menu-item/menu-item.component.js +3 -1
  20. package/esm/components/menu/menu-item/menu-item.style.js +126 -17
  21. package/esm/components/menu/menu-segment-title/menu-segment-title.component.js +6 -1
  22. package/esm/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -0
  23. package/esm/components/menu/menu-segment-title/menu-segment-title.style.js +4 -2
  24. package/esm/components/menu/menu.style.js +1 -7
  25. package/esm/components/navigation-bar/navigation-bar.style.js +0 -1
  26. package/esm/components/note/note.component.js +0 -4
  27. package/lib/components/decimal/decimal.component.js +2 -1
  28. package/lib/components/flat-table/flat-table-body/flat-table-body.component.d.ts +2 -1
  29. package/lib/components/flat-table/flat-table-body/flat-table-body.component.js +5 -2
  30. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +2 -1
  31. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +1 -0
  32. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -1
  33. package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +2 -1
  34. package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +2 -1
  35. package/lib/components/flat-table/flat-table.component.js +1 -1
  36. package/lib/components/flat-table/sort/sort.component.d.ts +3 -2
  37. package/lib/components/flat-table/sort/sort.component.js +10 -3
  38. package/lib/components/link/link.style.js +1 -2
  39. package/lib/components/menu/__internal__/submenu/submenu.component.d.ts +3 -0
  40. package/lib/components/menu/__internal__/submenu/submenu.component.js +8 -3
  41. package/lib/components/menu/__internal__/submenu/submenu.context.d.ts +1 -0
  42. package/lib/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
  43. package/lib/components/menu/__internal__/submenu/submenu.style.js +36 -4
  44. package/lib/components/menu/menu-item/menu-item.component.d.ts +7 -2
  45. package/lib/components/menu/menu-item/menu-item.component.js +3 -1
  46. package/lib/components/menu/menu-item/menu-item.style.js +125 -16
  47. package/lib/components/menu/menu-segment-title/menu-segment-title.component.js +6 -1
  48. package/lib/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -0
  49. package/lib/components/menu/menu-segment-title/menu-segment-title.style.js +4 -2
  50. package/lib/components/menu/menu.style.js +0 -6
  51. package/lib/components/navigation-bar/navigation-bar.style.js +0 -1
  52. package/lib/components/note/note.component.js +0 -4
  53. package/package.json +1 -1
@@ -181,7 +181,8 @@ const Decimal = /*#__PURE__*/React.forwardRef(({
181
181
  name: name,
182
182
  value: toStandardDecimal(stateValue),
183
183
  type: "hidden",
184
- "data-component": "hidden-input"
184
+ "data-component": "hidden-input",
185
+ "data-role": "hidden-input"
185
186
  }));
186
187
  });
187
188
  if (process.env.NODE_ENV !== "production") {
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- export interface FlatTableBodyProps {
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
+ export interface FlatTableBodyProps extends Omit<TagProps, "data-component"> {
3
4
  /** Array of FlatTableRow. */
4
5
  children: React.ReactNode;
5
6
  }
@@ -6,12 +6,15 @@ const FlatTableBody = /*#__PURE__*/React.forwardRef(({
6
6
  ...rest
7
7
  }, ref) => {
8
8
  return /*#__PURE__*/React.createElement("tbody", _extends({
9
- ref: ref
9
+ ref: ref,
10
+ "data-component": "flat-table-body"
10
11
  }, rest), children);
11
12
  });
12
13
  if (process.env.NODE_ENV !== "production") {
13
14
  FlatTableBody.propTypes = {
14
- "children": PropTypes.node
15
+ "children": PropTypes.node,
16
+ "data-element": PropTypes.string,
17
+ "data-role": PropTypes.string
15
18
  };
16
19
  }
17
20
  export { FlatTableBody };
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- export interface FlatTableBodyDraggableProps {
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
+ export interface FlatTableBodyDraggableProps extends Omit<TagProps, "data-component"> {
3
4
  /** Array of FlatTableRow. */
4
5
  children: React.ReactNode;
5
6
  /** Callback fired when order is changed */
@@ -23,6 +23,7 @@ const DropTarget = ({
23
23
  }
24
24
  });
25
25
  return /*#__PURE__*/React.createElement(StyledFlatTableBodyDraggable, _extends({
26
+ "data-component": "flat-table-body-draggable",
26
27
  "data-role": "flat-table-body-draggable",
27
28
  ref: drop,
28
29
  isDragging: isDragging
@@ -29,7 +29,7 @@ export const FlatTableCheckbox = ({
29
29
  const dataElement = `flat-table-checkbox-${as === "td" ? "cell" : "header"}`;
30
30
  const handleClick = event => {
31
31
  event.stopPropagation();
32
- if (onClick) onClick(event);
32
+ onClick?.(event);
33
33
  };
34
34
  const handleKeyDown = event => {
35
35
  if (!Events.isDownKey(event) && !Events.isUpKey(event)) {
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- export interface FlatTableHeadProps {
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
+ export interface FlatTableHeadProps extends Omit<TagProps, "data-component"> {
3
4
  /** Array of FlatTableRow. */
4
5
  children: React.ReactNode;
5
6
  }
@@ -21,7 +21,8 @@ export const FlatTableHead = ({
21
21
  }
22
22
  }, [children]);
23
23
  return /*#__PURE__*/React.createElement(StyledFlatTableHead, _extends({
24
- ref: ref
24
+ ref: ref,
25
+ "data-component": "flat-table-head"
25
26
  }, rest), /*#__PURE__*/React.createElement(FlatTableHeadContext.Provider, {
26
27
  value: {
27
28
  stickyOffsets
@@ -64,7 +64,7 @@ export const FlatTable = ({
64
64
  setHasVerticalScrollbar(bottom - top > offsetHeight);
65
65
  setHasHorizontalScrollbar(right - left > offsetWidth);
66
66
  const body = tableRef.current.querySelector("tbody");
67
- const bodyRows = body ? Array.from(body?.querySelectorAll("tr")) : [];
67
+ const bodyRows = body ? Array.from(body?.querySelectorAll("tr")) : /* istanbul ignore next */[];
68
68
  const {
69
69
  length
70
70
  } = bodyRows;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- export interface SortProps {
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
+ export interface SortProps extends Omit<TagProps, "data-component"> {
3
4
  /** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
4
5
  sortType?: "ascending" | "descending";
5
6
  /** Callback fired when the component is clicked */
@@ -9,5 +10,5 @@ export interface SortProps {
9
10
  /** Sets the accessible name of the component */
10
11
  accessibleName?: string;
11
12
  }
12
- export declare const Sort: ({ children, onClick, sortType, accessibleName, }: SortProps) => React.JSX.Element;
13
+ export declare const Sort: ({ children, onClick, sortType, accessibleName, "data-element": dataElement, "data-role": dataRole, }: SortProps) => React.JSX.Element;
13
14
  export default Sort;
@@ -10,7 +10,9 @@ export const Sort = ({
10
10
  children,
11
11
  onClick,
12
12
  sortType,
13
- accessibleName
13
+ accessibleName,
14
+ "data-element": dataElement,
15
+ "data-role": dataRole
14
16
  }) => {
15
17
  const id = useRef(guid());
16
18
  const locale = useLocale();
@@ -33,10 +35,15 @@ export const Sort = ({
33
35
  tabIndex: 0,
34
36
  onClick: onClick,
35
37
  sortType: sortType,
36
- "aria-labelledby": id.current
38
+ "aria-labelledby": id.current,
39
+ "data-component": "sort",
40
+ "data-element": dataElement,
41
+ "data-role": dataRole
37
42
  }, children, sortType && /*#__PURE__*/React.createElement(StyledSortIcon, {
38
43
  type: sortType === "ascending" ? "sort_up" : "sort_down",
39
44
  iconColor: colorTheme === "dark" ? "--colorsActionMinorYang100" : "--colorActionMinor500"
40
- })), !sortType && /*#__PURE__*/React.createElement(StyledSpaceHolder, null));
45
+ })), !sortType && /*#__PURE__*/React.createElement(StyledSpaceHolder, {
46
+ "data-role": "sort-placeholder"
47
+ }));
41
48
  };
42
49
  export default Sort;
@@ -82,7 +82,6 @@ const StyledLink = styled.span`
82
82
  text-decoration: underline var(--colorsUtilityYin100);
83
83
  text-decoration-thickness: 4px;
84
84
  text-underline-offset: 3px;
85
-
86
85
  -webkit-text-decoration: underline var(--colorsUtilityYin100);
87
86
  -webkit-text-decoration-thickness: 4px;
88
87
  -webkit-text-underline-offset: 3px;
@@ -91,7 +90,7 @@ const StyledLink = styled.span`
91
90
 
92
91
  a:focus {
93
92
  top: var(--spacing100);
94
- left: 0;
93
+ left: var(--spacing000);
95
94
  }
96
95
  `}
97
96
 
@@ -36,7 +36,10 @@ export interface SubmenuProps {
36
36
  onSubmenuClose?: () => void;
37
37
  /** Callback triggered when the top-level menu item is clicked */
38
38
  onClick?: (event: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>) => void;
39
+ /** Accessible label for when no text children are passed to menu item */
39
40
  ariaLabel?: string;
41
+ /** Sets the max-width of the submenu container element */
42
+ submenuMaxWidth?: string;
40
43
  }
41
44
  declare const Submenu: React.ForwardRefExoticComponent<SubmenuProps & React.RefAttributes<HTMLAnchorElement & HTMLButtonElement & HTMLDivElement>>;
42
45
  export default Submenu;
@@ -28,6 +28,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
28
28
  onSubmenuOpen: onSubmenuOpenProp,
29
29
  onSubmenuClose,
30
30
  onClick,
31
+ submenuMaxWidth,
31
32
  ...rest
32
33
  }, ref) => {
33
34
  const [submenuRef, setSubmenuRef] = useState(null);
@@ -328,7 +329,8 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
328
329
  clickToOpen: clickToOpen,
329
330
  href: href,
330
331
  maxWidth: maxWidth,
331
- "aria-expanded": submenuOpen
332
+ "aria-expanded": submenuOpen,
333
+ "data-role": "submenu-parent-item"
332
334
  }), title), submenuOpen && /*#__PURE__*/React.createElement(StyledSubmenu, {
333
335
  "data-component": "submenu",
334
336
  submenuDirection: submenuDirection,
@@ -337,14 +339,16 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
337
339
  role: blockIndex === 0 ? "presentation" : "list",
338
340
  maxHeight: submenuMaxHeight,
339
341
  applyFocusRadiusStyling: applyFocusRadius,
340
- applyFocusRadiusStylingToLastItem: applyFocusRadiusToLastItem
342
+ applyFocusRadiusStylingToLastItem: applyFocusRadiusToLastItem,
343
+ submenuMaxWidth: submenuMaxWidth
341
344
  }, /*#__PURE__*/React.createElement(SubmenuContext.Provider, {
342
345
  value: {
343
346
  submenuFocusId,
344
347
  handleKeyDown,
345
348
  blockIndex,
346
349
  updateFocusId: setSubmenuFocusId,
347
- shiftTabPressed: shiftTabPressed.current
350
+ shiftTabPressed: shiftTabPressed.current,
351
+ submenuHasMaxWidth: !!submenuMaxWidth
348
352
  }
349
353
  }, children)));
350
354
  });
@@ -464,6 +468,7 @@ if (process.env.NODE_ENV !== "production") {
464
468
  "onSubmenuOpen": PropTypes.func,
465
469
  "showDropdownArrow": PropTypes.bool,
466
470
  "submenuDirection": PropTypes.string,
471
+ "submenuMaxWidth": PropTypes.string,
467
472
  "title": PropTypes.string,
468
473
  "variant": PropTypes.oneOf(["alternate", "default"])
469
474
  };
@@ -5,6 +5,7 @@ export interface SubmenuContextProps {
5
5
  handleKeyDown?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void;
6
6
  shiftTabPressed?: boolean;
7
7
  blockIndex?: number;
8
+ submenuHasMaxWidth?: boolean;
8
9
  }
9
10
  declare const SubmenuContext: React.Context<SubmenuContextProps>;
10
11
  export default SubmenuContext;
@@ -8,7 +8,7 @@ interface StyledSubmenuWrapperProps extends SharedStyleProps {
8
8
  isSubmenuOpen?: boolean;
9
9
  asPassiveItem?: boolean;
10
10
  }
11
- interface StyledSubmenuProps extends SharedStyleProps, Pick<SubmenuProps, "variant"> {
11
+ interface StyledSubmenuProps extends SharedStyleProps, Pick<SubmenuProps, "variant" | "submenuMaxWidth"> {
12
12
  submenuDirection?: string;
13
13
  maxHeight?: string;
14
14
  applyFocusRadiusStyling: boolean;
@@ -43,12 +43,31 @@ const StyledSubmenu = styled.ul`
43
43
  inFullscreenView,
44
44
  maxHeight,
45
45
  applyFocusRadiusStyling,
46
- applyFocusRadiusStylingToLastItem
46
+ applyFocusRadiusStylingToLastItem,
47
+ submenuMaxWidth
47
48
  }) => css`
48
49
  ${!inFullscreenView && menuType && css`
49
50
  box-shadow: var(--boxShadow100);
50
51
  position: absolute;
51
52
  background-color: ${variant === "default" ? menuConfigVariants[menuType].submenuItemBackground : menuConfigVariants[menuType].background};
53
+
54
+ min-width: 100%;
55
+
56
+ ${submenuMaxWidth && css`
57
+ min-width: ${submenuMaxWidth};
58
+ max-width: ${submenuMaxWidth};
59
+
60
+ &&& {
61
+ a,
62
+ button,
63
+ ${StyledLink} a,
64
+ ${StyledLink} button {
65
+ white-space: normal;
66
+ height: auto;
67
+ }
68
+ }
69
+ `}
70
+
52
71
  a,
53
72
  button,
54
73
  ${StyledLink} a,
@@ -58,6 +77,8 @@ const StyledSubmenu = styled.ul`
58
77
  `}
59
78
 
60
79
  ${inFullscreenView && css`
80
+ min-width: 100%;
81
+
61
82
  ${StyledMenuItem} {
62
83
  width: 100%;
63
84
  }
@@ -108,7 +129,6 @@ const StyledSubmenu = styled.ul`
108
129
  list-style: none;
109
130
  margin: 0;
110
131
  padding: 0;
111
- min-width: 100%;
112
132
 
113
133
  ${StyledMenuItemWrapper}:after, ${StyledMenuItemWrapper}:hover:after {
114
134
  display: none;
@@ -117,8 +137,6 @@ const StyledSubmenu = styled.ul`
117
137
  ${StyledMenuItemWrapper} {
118
138
  display: flex;
119
139
  align-items: center;
120
- height: 40px;
121
- line-height: 40px;
122
140
  white-space: nowrap;
123
141
  cursor: pointer;
124
142
 
@@ -127,6 +145,11 @@ const StyledSubmenu = styled.ul`
127
145
  height: auto;
128
146
  `}
129
147
 
148
+ ${submenuMaxWidth && css`
149
+ height: auto;
150
+ min-height: 40px;
151
+ `}
152
+
130
153
  ${!inFullscreenView && menuType && css`
131
154
  background-color: ${menuConfigVariants[menuType].submenuItemBackground};
132
155
 
@@ -144,6 +167,15 @@ const StyledSubmenu = styled.ul`
144
167
  color: var(--colorsComponentsMenuYang100);
145
168
  }
146
169
  }
170
+
171
+ > a,
172
+ > button {
173
+ padding: 11px 16px 12px;
174
+
175
+ :has([data-component="icon"]) {
176
+ padding: 9px 16px 7px;
177
+ }
178
+ }
147
179
  `}
148
180
 
149
181
  a {
@@ -40,13 +40,18 @@ interface MenuItemBaseProps extends Omit<TagProps, "data-component">, LayoutProp
40
40
  overrideColor?: boolean;
41
41
  /** When set the submenu opens by click instead of hover */
42
42
  clickToOpen?: boolean;
43
- /** Sets the maxWidth of the MenuItem */
43
+ /**
44
+ * Sets the maxWidth of the MenuItem, setting this on a non-submenu
45
+ * item will truncate any text/content that may overflow
46
+ * */
44
47
  maxWidth?: MaxWidthProps["maxWidth"];
45
48
  /**
46
49
  * @private @ignore
47
50
  * Renders MenuItem as a div element
48
51
  * */
49
52
  as?: "div";
53
+ /** Sets the max-width of the submenu container element, accepts any valid CSS string */
54
+ submenuMaxWidth?: string;
50
55
  }
51
56
  export interface MenuWithChildren extends MenuItemBaseProps {
52
57
  children?: React.ReactNode;
@@ -59,7 +64,7 @@ export interface MenuWithIcon extends MenuItemBaseProps {
59
64
  children?: React.ReactNode;
60
65
  }
61
66
  export declare const MenuItem: {
62
- ({ submenu, children, href, onClick, target, submenuDirection, icon, selected, onKeyDown, variant, showDropdownArrow, ariaLabel, clickToOpen, maxWidth, onSubmenuOpen, onSubmenuClose, overrideColor, rel, as, "data-element": dataElement, "data-role": dataRole, ...rest }: MenuWithChildren | MenuWithIcon): React.JSX.Element;
67
+ ({ submenu, submenuMaxWidth, children, href, onClick, target, submenuDirection, icon, selected, onKeyDown, variant, showDropdownArrow, ariaLabel, clickToOpen, maxWidth, onSubmenuOpen, onSubmenuClose, overrideColor, rel, as, "data-element": dataElement, "data-role": dataRole, ...rest }: MenuWithChildren | MenuWithIcon): React.JSX.Element;
63
68
  displayName: string;
64
69
  };
65
70
  export default MenuItem;
@@ -12,6 +12,7 @@ import { StyledMenuItem } from "../menu.style";
12
12
  import guid from "../../../__internal__/utils/helpers/guid";
13
13
  export const MenuItem = ({
14
14
  submenu,
15
+ submenuMaxWidth,
15
16
  children,
16
17
  href,
17
18
  onClick,
@@ -149,7 +150,8 @@ export const MenuItem = ({
149
150
  asPassiveItem: asPassiveItem,
150
151
  ariaLabel: ariaLabel,
151
152
  onSubmenuOpen: onSubmenuOpen,
152
- onSubmenuClose: onSubmenuClose
153
+ onSubmenuClose: onSubmenuClose,
154
+ submenuMaxWidth: submenuMaxWidth
153
155
  }, elementProps, {
154
156
  variant: variant
155
157
  }, rest), children));
@@ -1,12 +1,79 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { padding } from "styled-system";
3
- import { StyledLink } from "../../link/link.style";
3
+ import StyledButton from "../../button/button.style";
4
+ import { StyledContent, StyledLink } from "../../link/link.style";
4
5
  import StyledIcon from "../../icon/icon.style";
5
6
  import StyledIconButton from "../../icon-button/icon-button.style";
6
7
  import menuConfigVariants from "../menu.config";
7
8
  import Link from "../../link";
8
9
  import addFocusStyling from "../../../style/utils/add-focus-styling";
9
10
  import { baseTheme } from "../../../style/themes";
11
+ const BASE_SPACING = 16;
12
+ const parsePadding = props => {
13
+ const {
14
+ paddingRight
15
+ } = props;
16
+ const paddingNumber = String(paddingRight)?.match(/\d+/)?.[0];
17
+ if (paddingRight === "var(--spacing000)" || paddingNumber === "0") {
18
+ return {
19
+ padding: "var(--spacing200)",
20
+ iconSpacing: "2px"
21
+ };
22
+ }
23
+ switch (paddingRight) {
24
+ case "var(--spacing100)":
25
+ return {
26
+ padding: "var(--spacing300)",
27
+ iconSpacing: paddingRight
28
+ };
29
+ case "var(--spacing200)":
30
+ return {
31
+ padding: "var(--spacing400)",
32
+ iconSpacing: paddingRight
33
+ };
34
+ case "var(--spacing300)":
35
+ return {
36
+ padding: "var(--spacing500)",
37
+ iconSpacing: paddingRight
38
+ };
39
+ case "var(--spacing400)":
40
+ return {
41
+ padding: "var(--spacing600)",
42
+ iconSpacing: paddingRight
43
+ };
44
+ case "var(--spacing500)":
45
+ return {
46
+ padding: "var(--spacing700)",
47
+ iconSpacing: paddingRight
48
+ };
49
+ case "var(--spacing600)":
50
+ return {
51
+ padding: "var(--spacing800)",
52
+ iconSpacing: paddingRight
53
+ };
54
+ case "var(--spacing700)":
55
+ return {
56
+ padding: "var(--spacing900)",
57
+ iconSpacing: paddingRight
58
+ };
59
+ case "var(--spacing800)":
60
+ return {
61
+ padding: "var(--spacing1000)",
62
+ iconSpacing: paddingRight
63
+ };
64
+ default:
65
+ if (paddingNumber) {
66
+ return {
67
+ padding: `${BASE_SPACING + Number(paddingNumber)}px`,
68
+ iconSpacing: `${paddingNumber}px`
69
+ };
70
+ }
71
+ return {
72
+ padding: "var(--spacing400)",
73
+ iconSpacing: "var(--spacing200)"
74
+ };
75
+ }
76
+ };
10
77
  const oldFocusStyling = `
11
78
  box-shadow: inset 0 0 0 var(--borderWidth300) var(--colorsSemanticFocus500);
12
79
  `;
@@ -29,14 +96,11 @@ const StyledMenuItemWrapper = styled.a.attrs({
29
96
  asDiv,
30
97
  hasInput
31
98
  }) => css`
32
- ${!inFullscreenView && css`
33
- ${padding}
34
- `}
35
-
36
- display: inline-block;
99
+ display: flex;
100
+ align-items: center;
37
101
  font-size: 14px;
38
102
  font-weight: 700;
39
- height: 40px;
103
+ min-height: 40px;
40
104
  position: relative;
41
105
  box-shadow: none;
42
106
 
@@ -53,9 +117,18 @@ const StyledMenuItemWrapper = styled.a.attrs({
53
117
  `}
54
118
  }
55
119
 
56
- a button:not(.search-button) {
57
- position: relative;
58
- top: -1px;
120
+ ${!maxWidth && css`
121
+ a:has([data-component="icon"]):not(:has(button))
122
+ ${StyledContent},
123
+ button:has([data-component="icon"]):not(:has(button))
124
+ ${StyledContent} {
125
+ position: relative;
126
+ top: -2px;
127
+ }
128
+ `}
129
+
130
+ :has([data-element="input"]) ${StyledContent} {
131
+ width: 100%;
59
132
  }
60
133
 
61
134
  ${!overrideColor && css`
@@ -71,6 +144,12 @@ const StyledMenuItemWrapper = styled.a.attrs({
71
144
  ${!inFullscreenView && css`
72
145
  max-width: inherit;
73
146
 
147
+ > a,
148
+ > button {
149
+ display: flex;
150
+ align-items: center;
151
+ }
152
+
74
153
  && {
75
154
  a:focus,
76
155
  button:focus {
@@ -91,8 +170,8 @@ const StyledMenuItemWrapper = styled.a.attrs({
91
170
  overflow: hidden;
92
171
  white-space: nowrap;
93
172
  vertical-align: bottom;
173
+ display: block;
94
174
  `}
95
- height: 40px;
96
175
  }
97
176
 
98
177
  a:hover,
@@ -114,6 +193,17 @@ const StyledMenuItemWrapper = styled.a.attrs({
114
193
  `}
115
194
 
116
195
  ${asPassiveItem ? `
196
+ ${!inFullscreenView && `
197
+ > a:not(:has(button)) {
198
+ padding: 11px 16px 12px;
199
+ }
200
+
201
+ > a ${StyledButton}:not(.search-button) {
202
+ min-height: 17px;
203
+ padding: 9px 0px 11px;
204
+ }
205
+ `}
206
+
117
207
  ${StyledIconButton} {
118
208
  > span {
119
209
  display: inline-flex;
@@ -132,13 +222,17 @@ const StyledMenuItemWrapper = styled.a.attrs({
132
222
  ${StyledLink} a,
133
223
  button,
134
224
  ${StyledLink} button {
135
- padding: 0 16px;
225
+
226
+ padding: ${inFullscreenView ? "0px 16px" : "11px 16px 12px"};
227
+
228
+ :has([data-component="icon"]) {
229
+ padding: 9px 16px 7px;
230
+ }
136
231
  }
137
232
  `}
138
233
 
139
234
  button,
140
235
  ${StyledLink} button {
141
- line-height: 40px;
142
236
  height: 40px;
143
237
  margin: 0px;
144
238
  text-align: left;
@@ -257,9 +351,11 @@ const StyledMenuItemWrapper = styled.a.attrs({
257
351
  `}
258
352
 
259
353
  ${showDropdownArrow && css`
260
- > a,
261
- > button:not(${StyledIconButton}) {
262
- padding-right: 32px;
354
+ &&& {
355
+ > a,
356
+ > button:not(${StyledIconButton}) {
357
+ padding-right: ${props => parsePadding(padding(props)).padding};
358
+ }
263
359
  }
264
360
 
265
361
  a::before,
@@ -268,7 +364,7 @@ const StyledMenuItemWrapper = styled.a.attrs({
268
364
  margin-top: -2px;
269
365
  pointer-events: none;
270
366
  position: absolute;
271
- right: 16px;
367
+ right: ${props => parsePadding(padding(props)).iconSpacing};
272
368
  top: 50%;
273
369
  z-index: 2;
274
370
  content: "";
@@ -312,6 +408,12 @@ const StyledMenuItemWrapper = styled.a.attrs({
312
408
  }
313
409
  `}
314
410
 
411
+
412
+ > a, > button {
413
+ min-height: 40px;
414
+ line-height: 40px;
415
+ }
416
+
315
417
  a,
316
418
  ${StyledLink} a,
317
419
  button,
@@ -344,6 +446,13 @@ const StyledMenuItemWrapper = styled.a.attrs({
344
446
  }
345
447
  `}
346
448
  `}
449
+
450
+ &&& {
451
+ > a,
452
+ > button {
453
+ ${padding}
454
+ }
455
+ }
347
456
  `;
348
457
  StyledMenuItemWrapper.defaultProps = {
349
458
  theme: baseTheme
@@ -5,6 +5,7 @@ import { StyledTitle, StyledSegmentChildren } from "./menu-segment-title.style";
5
5
  import MenuContext from "../__internal__/menu.context";
6
6
  import { StyledMenuItem } from "../menu.style";
7
7
  import tagComponent from "../../../__internal__/utils/helpers/tags";
8
+ import SubmenuContext from "../__internal__/submenu/submenu.context";
8
9
  const AS_VALUES = ["h2", "h3", "h4", "h5", "h6"];
9
10
  const MenuSegmentTitle = /*#__PURE__*/React.forwardRef(({
10
11
  children,
@@ -14,6 +15,9 @@ const MenuSegmentTitle = /*#__PURE__*/React.forwardRef(({
14
15
  ...rest
15
16
  }, ref) => {
16
17
  const menuContext = useContext(MenuContext);
18
+ const {
19
+ submenuHasMaxWidth
20
+ } = useContext(SubmenuContext);
17
21
  return /*#__PURE__*/React.createElement(StyledMenuItem, {
18
22
  inSubmenu: true
19
23
  }, /*#__PURE__*/React.createElement(StyledTitle, _extends({
@@ -21,7 +25,8 @@ const MenuSegmentTitle = /*#__PURE__*/React.forwardRef(({
21
25
  }, tagComponent("menu-segment-title", rest), {
22
26
  menuType: menuContext.menuType,
23
27
  ref: ref,
24
- variant: variant
28
+ variant: variant,
29
+ shouldWrap: submenuHasMaxWidth
25
30
  }), text), children && /*#__PURE__*/React.createElement(StyledSegmentChildren, {
26
31
  "data-role": "menu-segment-children"
27
32
  }, children));
@@ -3,6 +3,7 @@ import { MenuType } from "../__internal__/menu.context";
3
3
  interface StyledTitleProps {
4
4
  variant?: VariantType;
5
5
  menuType: MenuType;
6
+ shouldWrap?: boolean;
6
7
  }
7
8
  declare const StyledTitle: import("styled-components").StyledComponent<"h2", any, StyledTitleProps, never>;
8
9
  declare const StyledSegmentChildren: import("styled-components").StyledComponent<"ul", any, {}, never>;
@@ -3,17 +3,19 @@ import menuConfigVariants from "../menu.config";
3
3
  const StyledTitle = styled.h2`
4
4
  ${({
5
5
  menuType,
6
- variant
6
+ variant,
7
+ shouldWrap
7
8
  }) => css`
8
9
  margin: 0px;
9
10
  padding: 16px 16px 8px;
10
11
  font-size: 12px;
11
12
  font-weight: 700;
12
13
  text-transform: uppercase;
13
- line-height: 12px;
14
+ line-height: 14px;
14
15
  cursor: default;
15
16
  color: ${menuConfigVariants[menuType].title};
16
17
  ${variant === "alternate" && `background-color: ${menuConfigVariants[menuType].alternate};`}
18
+ white-space: ${shouldWrap ? "normal" : "nowrap"};
17
19
  `}
18
20
  `;
19
21
  const StyledSegmentChildren = styled.ul`