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.
- package/esm/components/decimal/decimal.component.js +2 -1
- package/esm/components/flat-table/flat-table-body/flat-table-body.component.d.ts +2 -1
- package/esm/components/flat-table/flat-table-body/flat-table-body.component.js +5 -2
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +2 -1
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +1 -0
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -1
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +2 -1
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +2 -1
- package/esm/components/flat-table/flat-table.component.js +1 -1
- package/esm/components/flat-table/sort/sort.component.d.ts +3 -2
- package/esm/components/flat-table/sort/sort.component.js +10 -3
- package/esm/components/link/link.style.js +1 -2
- package/esm/components/menu/__internal__/submenu/submenu.component.d.ts +3 -0
- package/esm/components/menu/__internal__/submenu/submenu.component.js +8 -3
- package/esm/components/menu/__internal__/submenu/submenu.context.d.ts +1 -0
- package/esm/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
- package/esm/components/menu/__internal__/submenu/submenu.style.js +36 -4
- package/esm/components/menu/menu-item/menu-item.component.d.ts +7 -2
- package/esm/components/menu/menu-item/menu-item.component.js +3 -1
- package/esm/components/menu/menu-item/menu-item.style.js +126 -17
- package/esm/components/menu/menu-segment-title/menu-segment-title.component.js +6 -1
- package/esm/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -0
- package/esm/components/menu/menu-segment-title/menu-segment-title.style.js +4 -2
- package/esm/components/menu/menu.style.js +1 -7
- package/esm/components/navigation-bar/navigation-bar.style.js +0 -1
- package/esm/components/note/note.component.js +0 -4
- package/lib/components/decimal/decimal.component.js +2 -1
- package/lib/components/flat-table/flat-table-body/flat-table-body.component.d.ts +2 -1
- package/lib/components/flat-table/flat-table-body/flat-table-body.component.js +5 -2
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +2 -1
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +1 -0
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -1
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +2 -1
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +2 -1
- package/lib/components/flat-table/flat-table.component.js +1 -1
- package/lib/components/flat-table/sort/sort.component.d.ts +3 -2
- package/lib/components/flat-table/sort/sort.component.js +10 -3
- package/lib/components/link/link.style.js +1 -2
- package/lib/components/menu/__internal__/submenu/submenu.component.d.ts +3 -0
- package/lib/components/menu/__internal__/submenu/submenu.component.js +8 -3
- package/lib/components/menu/__internal__/submenu/submenu.context.d.ts +1 -0
- package/lib/components/menu/__internal__/submenu/submenu.style.d.ts +1 -1
- package/lib/components/menu/__internal__/submenu/submenu.style.js +36 -4
- package/lib/components/menu/menu-item/menu-item.component.d.ts +7 -2
- package/lib/components/menu/menu-item/menu-item.component.js +3 -1
- package/lib/components/menu/menu-item/menu-item.style.js +125 -16
- package/lib/components/menu/menu-segment-title/menu-segment-title.component.js +6 -1
- package/lib/components/menu/menu-segment-title/menu-segment-title.style.d.ts +1 -0
- package/lib/components/menu/menu-segment-title/menu-segment-title.style.js +4 -2
- package/lib/components/menu/menu.style.js +0 -6
- package/lib/components/navigation-bar/navigation-bar.style.js +0 -1
- package/lib/components/note/note.component.js +0 -4
- package/package.json +1 -1
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import { layout, flexbox
|
|
2
|
+
import { layout, flexbox } from "styled-system";
|
|
3
3
|
import menuConfigVariants from "./menu.config";
|
|
4
4
|
import { StyledVerticalWrapper, StyledDivider } from "../vertical-divider/vertical-divider.style";
|
|
5
5
|
import { StyledLink } from "../link/link.style";
|
|
6
6
|
import { baseTheme } from "../../style/themes";
|
|
7
|
-
import StyledMenuItemWrapper from "./menu-item/menu-item.style";
|
|
8
7
|
const StyledMenuWrapper = styled.ul`
|
|
9
|
-
line-height: 40px;
|
|
10
8
|
list-style: none;
|
|
11
9
|
margin: 0;
|
|
12
10
|
padding: 0;
|
|
@@ -68,10 +66,6 @@ const StyledMenuItem = styled.li`
|
|
|
68
66
|
white-space: normal;
|
|
69
67
|
}
|
|
70
68
|
`}
|
|
71
|
-
|
|
72
|
-
${StyledMenuItemWrapper} {
|
|
73
|
-
${padding}
|
|
74
|
-
}
|
|
75
69
|
`;
|
|
76
70
|
StyledMenuItem.defaultProps = {
|
|
77
71
|
theme: baseTheme
|
|
@@ -25,10 +25,6 @@ export const Note = ({
|
|
|
25
25
|
...rest
|
|
26
26
|
}) => {
|
|
27
27
|
!(width > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> width must be greater than 0") : invariant(false) : void 0;
|
|
28
|
-
!createdDate ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> createdDate is required") : invariant(false) : void 0;
|
|
29
|
-
!noteContent ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> noteContent is required") : invariant(false) : void 0;
|
|
30
|
-
!(!status || status.text) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.text is required") : invariant(false) : void 0;
|
|
31
|
-
!(!status || status.timeStamp) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.timeStamp is required") : invariant(false) : void 0;
|
|
32
28
|
!(!inlineControl || /*#__PURE__*/React.isValidElement(inlineControl) && inlineControl.type === ActionPopover) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> inlineControl must be an instance of <ActionPopover>") : invariant(false) : void 0;
|
|
33
29
|
const renderStatus = () => {
|
|
34
30
|
if (!status) {
|
|
@@ -190,7 +190,8 @@ const Decimal = exports.Decimal = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
190
190
|
name: name,
|
|
191
191
|
value: toStandardDecimal(stateValue),
|
|
192
192
|
type: "hidden",
|
|
193
|
-
"data-component": "hidden-input"
|
|
193
|
+
"data-component": "hidden-input",
|
|
194
|
+
"data-role": "hidden-input"
|
|
194
195
|
}));
|
|
195
196
|
});
|
|
196
197
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
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
|
}
|
|
@@ -13,12 +13,15 @@ const FlatTableBody = exports.FlatTableBody = /*#__PURE__*/_react.default.forwar
|
|
|
13
13
|
...rest
|
|
14
14
|
}, ref) => {
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("tbody", _extends({
|
|
16
|
-
ref: ref
|
|
16
|
+
ref: ref,
|
|
17
|
+
"data-component": "flat-table-body"
|
|
17
18
|
}, rest), children);
|
|
18
19
|
});
|
|
19
20
|
if (process.env.NODE_ENV !== "production") {
|
|
20
21
|
FlatTableBody.propTypes = {
|
|
21
|
-
"children": _propTypes.default.node
|
|
22
|
+
"children": _propTypes.default.node,
|
|
23
|
+
"data-element": _propTypes.default.string,
|
|
24
|
+
"data-role": _propTypes.default.string
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
FlatTableBody.displayName = "FlatTableBody";
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
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 */
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -32,6 +32,7 @@ const DropTarget = ({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
return /*#__PURE__*/_react.default.createElement(_flatTableBodyDraggable.default, _extends({
|
|
35
|
+
"data-component": "flat-table-body-draggable",
|
|
35
36
|
"data-role": "flat-table-body-draggable",
|
|
36
37
|
ref: drop,
|
|
37
38
|
isDragging: isDragging
|
|
@@ -38,7 +38,7 @@ const FlatTableCheckbox = ({
|
|
|
38
38
|
const dataElement = `flat-table-checkbox-${as === "td" ? "cell" : "header"}`;
|
|
39
39
|
const handleClick = event => {
|
|
40
40
|
event.stopPropagation();
|
|
41
|
-
|
|
41
|
+
onClick?.(event);
|
|
42
42
|
};
|
|
43
43
|
const handleKeyDown = event => {
|
|
44
44
|
if (!_events.default.isDownKey(event) && !_events.default.isUpKey(event)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
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
|
}
|
|
@@ -30,7 +30,8 @@ const FlatTableHead = ({
|
|
|
30
30
|
}
|
|
31
31
|
}, [children]);
|
|
32
32
|
return /*#__PURE__*/_react.default.createElement(_flatTableHead.default, _extends({
|
|
33
|
-
ref: ref
|
|
33
|
+
ref: ref,
|
|
34
|
+
"data-component": "flat-table-head"
|
|
34
35
|
}, rest), /*#__PURE__*/_react.default.createElement(_flatTableHead2.default.Provider, {
|
|
35
36
|
value: {
|
|
36
37
|
stickyOffsets
|
|
@@ -73,7 +73,7 @@ const FlatTable = ({
|
|
|
73
73
|
setHasVerticalScrollbar(bottom - top > offsetHeight);
|
|
74
74
|
setHasHorizontalScrollbar(right - left > offsetWidth);
|
|
75
75
|
const body = tableRef.current.querySelector("tbody");
|
|
76
|
-
const bodyRows = body ? Array.from(body?.querySelectorAll("tr")) : [];
|
|
76
|
+
const bodyRows = body ? Array.from(body?.querySelectorAll("tr")) : /* istanbul ignore next */[];
|
|
77
77
|
const {
|
|
78
78
|
length
|
|
79
79
|
} = bodyRows;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
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;
|
|
@@ -19,7 +19,9 @@ const Sort = ({
|
|
|
19
19
|
children,
|
|
20
20
|
onClick,
|
|
21
21
|
sortType,
|
|
22
|
-
accessibleName
|
|
22
|
+
accessibleName,
|
|
23
|
+
"data-element": dataElement,
|
|
24
|
+
"data-role": dataRole
|
|
23
25
|
}) => {
|
|
24
26
|
const id = (0, _react.useRef)((0, _guid.default)());
|
|
25
27
|
const locale = (0, _useLocale.default)();
|
|
@@ -42,11 +44,16 @@ const Sort = ({
|
|
|
42
44
|
tabIndex: 0,
|
|
43
45
|
onClick: onClick,
|
|
44
46
|
sortType: sortType,
|
|
45
|
-
"aria-labelledby": id.current
|
|
47
|
+
"aria-labelledby": id.current,
|
|
48
|
+
"data-component": "sort",
|
|
49
|
+
"data-element": dataElement,
|
|
50
|
+
"data-role": dataRole
|
|
46
51
|
}, children, sortType && /*#__PURE__*/_react.default.createElement(_sort.StyledSortIcon, {
|
|
47
52
|
type: sortType === "ascending" ? "sort_up" : "sort_down",
|
|
48
53
|
iconColor: colorTheme === "dark" ? "--colorsActionMinorYang100" : "--colorActionMinor500"
|
|
49
|
-
})), !sortType && /*#__PURE__*/_react.default.createElement(_sort.StyledSpaceHolder,
|
|
54
|
+
})), !sortType && /*#__PURE__*/_react.default.createElement(_sort.StyledSpaceHolder, {
|
|
55
|
+
"data-role": "sort-placeholder"
|
|
56
|
+
}));
|
|
50
57
|
};
|
|
51
58
|
exports.Sort = Sort;
|
|
52
59
|
var _default = exports.default = Sort;
|
|
@@ -91,7 +91,6 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
91
91
|
text-decoration: underline var(--colorsUtilityYin100);
|
|
92
92
|
text-decoration-thickness: 4px;
|
|
93
93
|
text-underline-offset: 3px;
|
|
94
|
-
|
|
95
94
|
-webkit-text-decoration: underline var(--colorsUtilityYin100);
|
|
96
95
|
-webkit-text-decoration-thickness: 4px;
|
|
97
96
|
-webkit-text-underline-offset: 3px;
|
|
@@ -100,7 +99,7 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
100
99
|
|
|
101
100
|
a:focus {
|
|
102
101
|
top: var(--spacing100);
|
|
103
|
-
left:
|
|
102
|
+
left: var(--spacing000);
|
|
104
103
|
}
|
|
105
104
|
`}
|
|
106
105
|
|
|
@@ -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;
|
|
@@ -37,6 +37,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
37
37
|
onSubmenuOpen: onSubmenuOpenProp,
|
|
38
38
|
onSubmenuClose,
|
|
39
39
|
onClick,
|
|
40
|
+
submenuMaxWidth,
|
|
40
41
|
...rest
|
|
41
42
|
}, ref) => {
|
|
42
43
|
const [submenuRef, setSubmenuRef] = (0, _react.useState)(null);
|
|
@@ -337,7 +338,8 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
337
338
|
clickToOpen: clickToOpen,
|
|
338
339
|
href: href,
|
|
339
340
|
maxWidth: maxWidth,
|
|
340
|
-
"aria-expanded": submenuOpen
|
|
341
|
+
"aria-expanded": submenuOpen,
|
|
342
|
+
"data-role": "submenu-parent-item"
|
|
341
343
|
}), title), submenuOpen && /*#__PURE__*/_react.default.createElement(_submenu.StyledSubmenu, {
|
|
342
344
|
"data-component": "submenu",
|
|
343
345
|
submenuDirection: submenuDirection,
|
|
@@ -346,14 +348,16 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
346
348
|
role: blockIndex === 0 ? "presentation" : "list",
|
|
347
349
|
maxHeight: submenuMaxHeight,
|
|
348
350
|
applyFocusRadiusStyling: applyFocusRadius,
|
|
349
|
-
applyFocusRadiusStylingToLastItem: applyFocusRadiusToLastItem
|
|
351
|
+
applyFocusRadiusStylingToLastItem: applyFocusRadiusToLastItem,
|
|
352
|
+
submenuMaxWidth: submenuMaxWidth
|
|
350
353
|
}, /*#__PURE__*/_react.default.createElement(_submenu2.default.Provider, {
|
|
351
354
|
value: {
|
|
352
355
|
submenuFocusId,
|
|
353
356
|
handleKeyDown,
|
|
354
357
|
blockIndex,
|
|
355
358
|
updateFocusId: setSubmenuFocusId,
|
|
356
|
-
shiftTabPressed: shiftTabPressed.current
|
|
359
|
+
shiftTabPressed: shiftTabPressed.current,
|
|
360
|
+
submenuHasMaxWidth: !!submenuMaxWidth
|
|
357
361
|
}
|
|
358
362
|
}, children)));
|
|
359
363
|
});
|
|
@@ -473,6 +477,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
473
477
|
"onSubmenuOpen": _propTypes.default.func,
|
|
474
478
|
"showDropdownArrow": _propTypes.default.bool,
|
|
475
479
|
"submenuDirection": _propTypes.default.string,
|
|
480
|
+
"submenuMaxWidth": _propTypes.default.string,
|
|
476
481
|
"title": _propTypes.default.string,
|
|
477
482
|
"variant": _propTypes.default.oneOf(["alternate", "default"])
|
|
478
483
|
};
|
|
@@ -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;
|
|
@@ -52,12 +52,31 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
52
52
|
inFullscreenView,
|
|
53
53
|
maxHeight,
|
|
54
54
|
applyFocusRadiusStyling,
|
|
55
|
-
applyFocusRadiusStylingToLastItem
|
|
55
|
+
applyFocusRadiusStylingToLastItem,
|
|
56
|
+
submenuMaxWidth
|
|
56
57
|
}) => (0, _styledComponents.css)`
|
|
57
58
|
${!inFullscreenView && menuType && (0, _styledComponents.css)`
|
|
58
59
|
box-shadow: var(--boxShadow100);
|
|
59
60
|
position: absolute;
|
|
60
61
|
background-color: ${variant === "default" ? _menu2.default[menuType].submenuItemBackground : _menu2.default[menuType].background};
|
|
62
|
+
|
|
63
|
+
min-width: 100%;
|
|
64
|
+
|
|
65
|
+
${submenuMaxWidth && (0, _styledComponents.css)`
|
|
66
|
+
min-width: ${submenuMaxWidth};
|
|
67
|
+
max-width: ${submenuMaxWidth};
|
|
68
|
+
|
|
69
|
+
&&& {
|
|
70
|
+
a,
|
|
71
|
+
button,
|
|
72
|
+
${_link.StyledLink} a,
|
|
73
|
+
${_link.StyledLink} button {
|
|
74
|
+
white-space: normal;
|
|
75
|
+
height: auto;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`}
|
|
79
|
+
|
|
61
80
|
a,
|
|
62
81
|
button,
|
|
63
82
|
${_link.StyledLink} a,
|
|
@@ -67,6 +86,8 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
67
86
|
`}
|
|
68
87
|
|
|
69
88
|
${inFullscreenView && (0, _styledComponents.css)`
|
|
89
|
+
min-width: 100%;
|
|
90
|
+
|
|
70
91
|
${_menu.StyledMenuItem} {
|
|
71
92
|
width: 100%;
|
|
72
93
|
}
|
|
@@ -117,7 +138,6 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
117
138
|
list-style: none;
|
|
118
139
|
margin: 0;
|
|
119
140
|
padding: 0;
|
|
120
|
-
min-width: 100%;
|
|
121
141
|
|
|
122
142
|
${_menuItem.default}:after, ${_menuItem.default}:hover:after {
|
|
123
143
|
display: none;
|
|
@@ -126,8 +146,6 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
126
146
|
${_menuItem.default} {
|
|
127
147
|
display: flex;
|
|
128
148
|
align-items: center;
|
|
129
|
-
height: 40px;
|
|
130
|
-
line-height: 40px;
|
|
131
149
|
white-space: nowrap;
|
|
132
150
|
cursor: pointer;
|
|
133
151
|
|
|
@@ -136,6 +154,11 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
136
154
|
height: auto;
|
|
137
155
|
`}
|
|
138
156
|
|
|
157
|
+
${submenuMaxWidth && (0, _styledComponents.css)`
|
|
158
|
+
height: auto;
|
|
159
|
+
min-height: 40px;
|
|
160
|
+
`}
|
|
161
|
+
|
|
139
162
|
${!inFullscreenView && menuType && (0, _styledComponents.css)`
|
|
140
163
|
background-color: ${_menu2.default[menuType].submenuItemBackground};
|
|
141
164
|
|
|
@@ -153,6 +176,15 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
153
176
|
color: var(--colorsComponentsMenuYang100);
|
|
154
177
|
}
|
|
155
178
|
}
|
|
179
|
+
|
|
180
|
+
> a,
|
|
181
|
+
> button {
|
|
182
|
+
padding: 11px 16px 12px;
|
|
183
|
+
|
|
184
|
+
:has([data-component="icon"]) {
|
|
185
|
+
padding: 9px 16px 7px;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
156
188
|
`}
|
|
157
189
|
|
|
158
190
|
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
|
-
/**
|
|
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;
|
|
@@ -21,6 +21,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
21
21
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
22
22
|
const MenuItem = ({
|
|
23
23
|
submenu,
|
|
24
|
+
submenuMaxWidth,
|
|
24
25
|
children,
|
|
25
26
|
href,
|
|
26
27
|
onClick,
|
|
@@ -158,7 +159,8 @@ const MenuItem = ({
|
|
|
158
159
|
asPassiveItem: asPassiveItem,
|
|
159
160
|
ariaLabel: ariaLabel,
|
|
160
161
|
onSubmenuOpen: onSubmenuOpen,
|
|
161
|
-
onSubmenuClose: onSubmenuClose
|
|
162
|
+
onSubmenuClose: onSubmenuClose,
|
|
163
|
+
submenuMaxWidth: submenuMaxWidth
|
|
162
164
|
}, elementProps, {
|
|
163
165
|
variant: variant
|
|
164
166
|
}, rest), children));
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
|
+
var _button = _interopRequireDefault(require("../../button/button.style"));
|
|
9
10
|
var _link = require("../../link/link.style");
|
|
10
11
|
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
11
12
|
var _iconButton = _interopRequireDefault(require("../../icon-button/icon-button.style"));
|
|
@@ -16,6 +17,72 @@ var _themes = require("../../../style/themes");
|
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
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); }
|
|
18
19
|
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; }
|
|
20
|
+
const BASE_SPACING = 16;
|
|
21
|
+
const parsePadding = props => {
|
|
22
|
+
const {
|
|
23
|
+
paddingRight
|
|
24
|
+
} = props;
|
|
25
|
+
const paddingNumber = String(paddingRight)?.match(/\d+/)?.[0];
|
|
26
|
+
if (paddingRight === "var(--spacing000)" || paddingNumber === "0") {
|
|
27
|
+
return {
|
|
28
|
+
padding: "var(--spacing200)",
|
|
29
|
+
iconSpacing: "2px"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
switch (paddingRight) {
|
|
33
|
+
case "var(--spacing100)":
|
|
34
|
+
return {
|
|
35
|
+
padding: "var(--spacing300)",
|
|
36
|
+
iconSpacing: paddingRight
|
|
37
|
+
};
|
|
38
|
+
case "var(--spacing200)":
|
|
39
|
+
return {
|
|
40
|
+
padding: "var(--spacing400)",
|
|
41
|
+
iconSpacing: paddingRight
|
|
42
|
+
};
|
|
43
|
+
case "var(--spacing300)":
|
|
44
|
+
return {
|
|
45
|
+
padding: "var(--spacing500)",
|
|
46
|
+
iconSpacing: paddingRight
|
|
47
|
+
};
|
|
48
|
+
case "var(--spacing400)":
|
|
49
|
+
return {
|
|
50
|
+
padding: "var(--spacing600)",
|
|
51
|
+
iconSpacing: paddingRight
|
|
52
|
+
};
|
|
53
|
+
case "var(--spacing500)":
|
|
54
|
+
return {
|
|
55
|
+
padding: "var(--spacing700)",
|
|
56
|
+
iconSpacing: paddingRight
|
|
57
|
+
};
|
|
58
|
+
case "var(--spacing600)":
|
|
59
|
+
return {
|
|
60
|
+
padding: "var(--spacing800)",
|
|
61
|
+
iconSpacing: paddingRight
|
|
62
|
+
};
|
|
63
|
+
case "var(--spacing700)":
|
|
64
|
+
return {
|
|
65
|
+
padding: "var(--spacing900)",
|
|
66
|
+
iconSpacing: paddingRight
|
|
67
|
+
};
|
|
68
|
+
case "var(--spacing800)":
|
|
69
|
+
return {
|
|
70
|
+
padding: "var(--spacing1000)",
|
|
71
|
+
iconSpacing: paddingRight
|
|
72
|
+
};
|
|
73
|
+
default:
|
|
74
|
+
if (paddingNumber) {
|
|
75
|
+
return {
|
|
76
|
+
padding: `${BASE_SPACING + Number(paddingNumber)}px`,
|
|
77
|
+
iconSpacing: `${paddingNumber}px`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
padding: "var(--spacing400)",
|
|
82
|
+
iconSpacing: "var(--spacing200)"
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
19
86
|
const oldFocusStyling = `
|
|
20
87
|
box-shadow: inset 0 0 0 var(--borderWidth300) var(--colorsSemanticFocus500);
|
|
21
88
|
`;
|
|
@@ -38,14 +105,11 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
38
105
|
asDiv,
|
|
39
106
|
hasInput
|
|
40
107
|
}) => (0, _styledComponents.css)`
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`}
|
|
44
|
-
|
|
45
|
-
display: inline-block;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
46
110
|
font-size: 14px;
|
|
47
111
|
font-weight: 700;
|
|
48
|
-
height: 40px;
|
|
112
|
+
min-height: 40px;
|
|
49
113
|
position: relative;
|
|
50
114
|
box-shadow: none;
|
|
51
115
|
|
|
@@ -62,9 +126,18 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
62
126
|
`}
|
|
63
127
|
}
|
|
64
128
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
129
|
+
${!maxWidth && (0, _styledComponents.css)`
|
|
130
|
+
a:has([data-component="icon"]):not(:has(button))
|
|
131
|
+
${_link.StyledContent},
|
|
132
|
+
button:has([data-component="icon"]):not(:has(button))
|
|
133
|
+
${_link.StyledContent} {
|
|
134
|
+
position: relative;
|
|
135
|
+
top: -2px;
|
|
136
|
+
}
|
|
137
|
+
`}
|
|
138
|
+
|
|
139
|
+
:has([data-element="input"]) ${_link.StyledContent} {
|
|
140
|
+
width: 100%;
|
|
68
141
|
}
|
|
69
142
|
|
|
70
143
|
${!overrideColor && (0, _styledComponents.css)`
|
|
@@ -80,6 +153,12 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
80
153
|
${!inFullscreenView && (0, _styledComponents.css)`
|
|
81
154
|
max-width: inherit;
|
|
82
155
|
|
|
156
|
+
> a,
|
|
157
|
+
> button {
|
|
158
|
+
display: flex;
|
|
159
|
+
align-items: center;
|
|
160
|
+
}
|
|
161
|
+
|
|
83
162
|
&& {
|
|
84
163
|
a:focus,
|
|
85
164
|
button:focus {
|
|
@@ -100,8 +179,8 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
100
179
|
overflow: hidden;
|
|
101
180
|
white-space: nowrap;
|
|
102
181
|
vertical-align: bottom;
|
|
182
|
+
display: block;
|
|
103
183
|
`}
|
|
104
|
-
height: 40px;
|
|
105
184
|
}
|
|
106
185
|
|
|
107
186
|
a:hover,
|
|
@@ -123,6 +202,17 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
123
202
|
`}
|
|
124
203
|
|
|
125
204
|
${asPassiveItem ? `
|
|
205
|
+
${!inFullscreenView && `
|
|
206
|
+
> a:not(:has(button)) {
|
|
207
|
+
padding: 11px 16px 12px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
> a ${_button.default}:not(.search-button) {
|
|
211
|
+
min-height: 17px;
|
|
212
|
+
padding: 9px 0px 11px;
|
|
213
|
+
}
|
|
214
|
+
`}
|
|
215
|
+
|
|
126
216
|
${_iconButton.default} {
|
|
127
217
|
> span {
|
|
128
218
|
display: inline-flex;
|
|
@@ -141,13 +231,17 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
141
231
|
${_link.StyledLink} a,
|
|
142
232
|
button,
|
|
143
233
|
${_link.StyledLink} button {
|
|
144
|
-
|
|
234
|
+
|
|
235
|
+
padding: ${inFullscreenView ? "0px 16px" : "11px 16px 12px"};
|
|
236
|
+
|
|
237
|
+
:has([data-component="icon"]) {
|
|
238
|
+
padding: 9px 16px 7px;
|
|
239
|
+
}
|
|
145
240
|
}
|
|
146
241
|
`}
|
|
147
242
|
|
|
148
243
|
button,
|
|
149
244
|
${_link.StyledLink} button {
|
|
150
|
-
line-height: 40px;
|
|
151
245
|
height: 40px;
|
|
152
246
|
margin: 0px;
|
|
153
247
|
text-align: left;
|
|
@@ -266,9 +360,11 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
266
360
|
`}
|
|
267
361
|
|
|
268
362
|
${showDropdownArrow && (0, _styledComponents.css)`
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
363
|
+
&&& {
|
|
364
|
+
> a,
|
|
365
|
+
> button:not(${_iconButton.default}) {
|
|
366
|
+
padding-right: ${props => parsePadding((0, _styledSystem.padding)(props)).padding};
|
|
367
|
+
}
|
|
272
368
|
}
|
|
273
369
|
|
|
274
370
|
a::before,
|
|
@@ -277,7 +373,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
277
373
|
margin-top: -2px;
|
|
278
374
|
pointer-events: none;
|
|
279
375
|
position: absolute;
|
|
280
|
-
right:
|
|
376
|
+
right: ${props => parsePadding((0, _styledSystem.padding)(props)).iconSpacing};
|
|
281
377
|
top: 50%;
|
|
282
378
|
z-index: 2;
|
|
283
379
|
content: "";
|
|
@@ -321,6 +417,12 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
321
417
|
}
|
|
322
418
|
`}
|
|
323
419
|
|
|
420
|
+
|
|
421
|
+
> a, > button {
|
|
422
|
+
min-height: 40px;
|
|
423
|
+
line-height: 40px;
|
|
424
|
+
}
|
|
425
|
+
|
|
324
426
|
a,
|
|
325
427
|
${_link.StyledLink} a,
|
|
326
428
|
button,
|
|
@@ -353,6 +455,13 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
353
455
|
}
|
|
354
456
|
`}
|
|
355
457
|
`}
|
|
458
|
+
|
|
459
|
+
&&& {
|
|
460
|
+
> a,
|
|
461
|
+
> button {
|
|
462
|
+
${_styledSystem.padding}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
356
465
|
`;
|
|
357
466
|
StyledMenuItemWrapper.defaultProps = {
|
|
358
467
|
theme: _themes.baseTheme
|