carbon-react 128.4.1 → 130.0.0
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/flat-table/sort/sort.component.d.ts +7 -5
- package/esm/components/flat-table/sort/sort.component.js +8 -4
- package/esm/components/link/link.style.js +17 -17
- package/esm/components/menu/__internal__/submenu/submenu.style.js +23 -14
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +0 -17
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +12 -26
- package/esm/components/menu/menu-item/menu-item.component.js +7 -7
- package/esm/components/menu/menu-item/menu-item.style.js +9 -7
- package/esm/components/menu/menu.style.js +4 -1
- package/esm/components/search/index.d.ts +1 -1
- package/esm/components/search/search-button.style.js +8 -3
- package/esm/components/search/search.component.d.ts +10 -7
- package/esm/components/search/search.component.js +35 -42
- package/esm/components/search/search.style.d.ts +0 -1
- package/esm/components/search/search.style.js +64 -52
- package/esm/locales/__internal__/es-es.js +6 -0
- package/esm/locales/en-gb.js +6 -0
- package/esm/locales/locale.d.ts +10 -4
- package/lib/components/flat-table/sort/sort.component.d.ts +7 -5
- package/lib/components/flat-table/sort/sort.component.js +8 -4
- package/lib/components/link/link.style.js +17 -17
- package/lib/components/menu/__internal__/submenu/submenu.style.js +23 -14
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +0 -17
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +12 -26
- package/lib/components/menu/menu-item/menu-item.component.js +7 -7
- package/lib/components/menu/menu-item/menu-item.style.js +9 -7
- package/lib/components/menu/menu.style.js +4 -1
- package/lib/components/search/index.d.ts +1 -1
- package/lib/components/search/search-button.style.js +8 -3
- package/lib/components/search/search.component.d.ts +10 -7
- package/lib/components/search/search.component.js +34 -41
- package/lib/components/search/search.style.d.ts +0 -1
- package/lib/components/search/search.style.js +64 -52
- package/lib/locales/__internal__/es-es.js +6 -0
- package/lib/locales/en-gb.js +6 -0
- package/lib/locales/locale.d.ts +10 -4
- package/package.json +1 -1
|
@@ -11,47 +11,40 @@ const StyledSearch = styled.div`
|
|
|
11
11
|
isFocused,
|
|
12
12
|
searchWidth,
|
|
13
13
|
maxWidth,
|
|
14
|
-
searchIsActive,
|
|
15
14
|
searchHasValue,
|
|
16
15
|
showSearchButton,
|
|
17
16
|
theme,
|
|
18
17
|
variant
|
|
19
18
|
}) => {
|
|
20
19
|
const darkVariant = variant === "dark";
|
|
21
|
-
const variantColor = darkVariant ? "var(--
|
|
22
|
-
const iconColor = darkVariant && (searchHasValue && isFocused || !searchHasValue && isFocused || !isFocused && searchHasValue && showSearchButton);
|
|
20
|
+
const variantColor = darkVariant ? "var(--colorsUtilityYang080)" : "var(--colorsUtilityMajor300)";
|
|
23
21
|
return css`
|
|
24
22
|
${margin}
|
|
25
23
|
width: ${searchWidth ? `${searchWidth}` : "100%"};
|
|
26
24
|
max-width: ${maxWidth ? `${maxWidth}` : "100%"};
|
|
27
|
-
padding-bottom:
|
|
25
|
+
padding-bottom: var(--spacing025);
|
|
28
26
|
background-color: transparent;
|
|
29
|
-
border-bottom: 2px solid ${variantColor};
|
|
30
27
|
display: inline-flex;
|
|
31
|
-
font-size:
|
|
28
|
+
font-size: var(--fontSize100);
|
|
32
29
|
font-weight: 700;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
${(isFocused || searchHasValue) && css`
|
|
38
|
-
border-color: transparent;
|
|
39
|
-
transition: background 0.2s ease;
|
|
40
|
-
:hover {
|
|
41
|
-
border-color: transparent;
|
|
42
|
-
}
|
|
43
|
-
`}
|
|
44
|
-
${isFocused && !searchIsActive && css`
|
|
45
|
-
border-color: transparent;
|
|
46
|
-
`}
|
|
47
|
-
${!isFocused && searchHasValue && !showSearchButton && css`
|
|
48
|
-
border-bottom: 2px solid ${variantColor};
|
|
30
|
+
|
|
31
|
+
${!showSearchButton && css`
|
|
32
|
+
border-bottom: var(--spacing025) solid ${variantColor};
|
|
33
|
+
|
|
49
34
|
:hover {
|
|
50
|
-
border-bottom-color: var(--colorsUtilityMajor400);
|
|
35
|
+
border-bottom-color: ${darkVariant ? "var(--colorsUtilityYang100)" : "var(--colorsUtilityMajor400)"};
|
|
51
36
|
cursor: pointer;
|
|
52
37
|
}
|
|
53
|
-
`}
|
|
54
38
|
|
|
39
|
+
${(searchHasValue || isFocused) && css`
|
|
40
|
+
border-bottom-color: transparent;
|
|
41
|
+
|
|
42
|
+
:hover {
|
|
43
|
+
border-bottom-color: transparent;
|
|
44
|
+
cursor: default;
|
|
45
|
+
}
|
|
46
|
+
`}
|
|
47
|
+
`}
|
|
55
48
|
|
|
56
49
|
${StyledInput} {
|
|
57
50
|
::-moz-placeholder {
|
|
@@ -62,23 +55,50 @@ const StyledSearch = styled.div`
|
|
|
62
55
|
color: var(--colorsUtilityYin055);
|
|
63
56
|
}
|
|
64
57
|
|
|
65
|
-
${darkVariant &&
|
|
58
|
+
${darkVariant && css`
|
|
66
59
|
::-moz-placeholder {
|
|
67
|
-
color: var(--
|
|
60
|
+
color: var(--colorsUtilityYang080);
|
|
68
61
|
opacity: 1;
|
|
69
62
|
}
|
|
70
63
|
::placeholder {
|
|
71
|
-
color: var(--
|
|
64
|
+
color: var(--colorsUtilityYang080);
|
|
72
65
|
}
|
|
73
66
|
`}
|
|
74
67
|
|
|
75
|
-
${darkVariant &&
|
|
68
|
+
${darkVariant && searchHasValue && !showSearchButton && css`
|
|
76
69
|
color: var(--colorsUtilityYang100);
|
|
77
70
|
`}
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
${StyledInputPresentation} {
|
|
81
|
-
|
|
74
|
+
[data-element="search"] {
|
|
75
|
+
height: auto;
|
|
76
|
+
|
|
77
|
+
${!darkVariant && css`
|
|
78
|
+
color: var(--colorsUtilityYin065);
|
|
79
|
+
|
|
80
|
+
:hover {
|
|
81
|
+
color: var(--colorsUtilityYin100);
|
|
82
|
+
}
|
|
83
|
+
`}
|
|
84
|
+
|
|
85
|
+
${darkVariant && css`
|
|
86
|
+
color: var(--colorsUtilityYang080);
|
|
87
|
+
|
|
88
|
+
:hover {
|
|
89
|
+
color: var(--colorsUtilityYang100);
|
|
90
|
+
}
|
|
91
|
+
`}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
${darkVariant && !showSearchButton && css`
|
|
95
|
+
background-color: transparent;
|
|
96
|
+
border-color: var(--colorsUtilityYang080);
|
|
97
|
+
`}
|
|
98
|
+
|
|
99
|
+
${!darkVariant && css`
|
|
100
|
+
background-color: ${searchHasValue || isFocused || showSearchButton ? "var(--colorsUtilityYang100)" : "transparent"};
|
|
101
|
+
`}
|
|
82
102
|
|
|
83
103
|
${showSearchButton && css`
|
|
84
104
|
border-top-right-radius: var(--borderRadius000);
|
|
@@ -86,16 +106,17 @@ const StyledSearch = styled.div`
|
|
|
86
106
|
`}
|
|
87
107
|
|
|
88
108
|
flex: 1;
|
|
89
|
-
font-size:
|
|
109
|
+
font-size: var(--fontSize100);
|
|
90
110
|
font-weight: 700;
|
|
91
|
-
padding-bottom:
|
|
111
|
+
padding-bottom: var(--spacing025);
|
|
92
112
|
padding-top: 1px;
|
|
93
113
|
cursor: pointer;
|
|
94
|
-
|
|
114
|
+
|
|
115
|
+
${!isFocused && !searchHasValue && !showSearchButton && css`
|
|
95
116
|
border: 1px solid transparent;
|
|
96
117
|
`}
|
|
118
|
+
|
|
97
119
|
${!isFocused && searchHasValue && !showSearchButton && css`
|
|
98
|
-
border: 1px solid transparent;
|
|
99
120
|
background-color: ${darkVariant ? "transparent" : "var(--colorsUtilityYang100)"};
|
|
100
121
|
`}
|
|
101
122
|
}
|
|
@@ -104,34 +125,25 @@ const StyledSearch = styled.div`
|
|
|
104
125
|
flex: 1;
|
|
105
126
|
z-index: ${theme.zIndex.smallOverlay};
|
|
106
127
|
}
|
|
128
|
+
|
|
107
129
|
${StyledIcon} {
|
|
108
|
-
|
|
109
|
-
${
|
|
110
|
-
color: var(--
|
|
130
|
+
:not([data-element="search"]) {
|
|
131
|
+
${darkVariant && !showSearchButton && css`
|
|
132
|
+
color: var(--colorsUtilityYang080);
|
|
111
133
|
|
|
112
134
|
:hover {
|
|
113
|
-
color: var(--
|
|
135
|
+
color: var(--colorsUtilityYang100);
|
|
114
136
|
}
|
|
115
137
|
`}
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
|
|
139
|
+
${!darkVariant && css`
|
|
140
|
+
color: var(--colorsActionMinor500);
|
|
118
141
|
|
|
119
142
|
:hover {
|
|
120
|
-
color: var(--
|
|
143
|
+
color: var(--colorsActionMinor600);
|
|
121
144
|
}
|
|
122
145
|
`}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
${!darkVariant && css`
|
|
126
|
-
color: var(--colorsActionMinor500);
|
|
127
|
-
|
|
128
|
-
:hover {
|
|
129
|
-
color: var(--colorsActionMinor600);
|
|
130
|
-
}
|
|
131
|
-
`}
|
|
132
|
-
|
|
133
|
-
width: 20px;
|
|
134
|
-
height: 20px;
|
|
146
|
+
}
|
|
135
147
|
cursor: pointer;
|
|
136
148
|
}
|
|
137
149
|
|
|
@@ -137,6 +137,9 @@ const esES = {
|
|
|
137
137
|
pod: {
|
|
138
138
|
undo: () => "Deshacer"
|
|
139
139
|
},
|
|
140
|
+
search: {
|
|
141
|
+
searchButtonText: () => "Buscar"
|
|
142
|
+
},
|
|
140
143
|
select: {
|
|
141
144
|
actionButtonText: () => "Añadir un nuevo elemento",
|
|
142
145
|
placeholder: () => "Por favor seleccione...",
|
|
@@ -147,6 +150,9 @@ const esES = {
|
|
|
147
150
|
close: () => "Cerrar"
|
|
148
151
|
}
|
|
149
152
|
},
|
|
153
|
+
sort: {
|
|
154
|
+
accessibleName: (sortContent, sortType) => `Ordenar todo ${sortContent || "contenido"}${sortType ? ` en orden ${sortType === "ascending" ? "ascendente" : "descendente"}.` : " en orden ascendente o descendente."}`
|
|
155
|
+
},
|
|
150
156
|
splitButton: {
|
|
151
157
|
ariaLabel: () => "Mostrar más"
|
|
152
158
|
},
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -139,6 +139,9 @@ const enGB = {
|
|
|
139
139
|
pod: {
|
|
140
140
|
undo: () => "Undo"
|
|
141
141
|
},
|
|
142
|
+
search: {
|
|
143
|
+
searchButtonText: () => "Search"
|
|
144
|
+
},
|
|
142
145
|
select: {
|
|
143
146
|
actionButtonText: () => "Add New Item",
|
|
144
147
|
placeholder: () => "Please Select...",
|
|
@@ -149,6 +152,9 @@ const enGB = {
|
|
|
149
152
|
close: () => "Close"
|
|
150
153
|
}
|
|
151
154
|
},
|
|
155
|
+
sort: {
|
|
156
|
+
accessibleName: (sortContent, sortType) => `Sort all ${sortContent || "contents"}${sortType ? ` in an ${sortType} order.` : " in an ascending or descending order."}`
|
|
157
|
+
},
|
|
152
158
|
splitButton: {
|
|
153
159
|
ariaLabel: () => "Show more"
|
|
154
160
|
},
|
package/esm/locales/locale.d.ts
CHANGED
|
@@ -114,6 +114,9 @@ interface Locale {
|
|
|
114
114
|
pod: {
|
|
115
115
|
undo: () => string;
|
|
116
116
|
};
|
|
117
|
+
search: {
|
|
118
|
+
searchButtonText: () => string;
|
|
119
|
+
};
|
|
117
120
|
select: {
|
|
118
121
|
actionButtonText: () => string;
|
|
119
122
|
placeholder: () => string;
|
|
@@ -124,18 +127,21 @@ interface Locale {
|
|
|
124
127
|
close: () => string;
|
|
125
128
|
};
|
|
126
129
|
};
|
|
130
|
+
sort: {
|
|
131
|
+
accessibleName: (sortContent?: string, sortType?: "ascending" | "descending") => string;
|
|
132
|
+
};
|
|
127
133
|
splitButton: {
|
|
128
134
|
ariaLabel: () => string;
|
|
129
135
|
};
|
|
130
|
-
switch: {
|
|
131
|
-
on: () => string;
|
|
132
|
-
off: () => string;
|
|
133
|
-
};
|
|
134
136
|
stepFlow: {
|
|
135
137
|
stepLabel: (currentStep: number, totalSteps: number) => string;
|
|
136
138
|
screenReaderOnlyTitle: (title: string, currentStep: number, totalSteps: number, category?: string) => string;
|
|
137
139
|
closeIconAriaLabel?: () => string;
|
|
138
140
|
};
|
|
141
|
+
switch: {
|
|
142
|
+
on: () => string;
|
|
143
|
+
off: () => string;
|
|
144
|
+
};
|
|
139
145
|
textEditor: {
|
|
140
146
|
tooltipMessages: {
|
|
141
147
|
bold: () => string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface SortProps {
|
|
3
3
|
/** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
|
|
4
|
-
sortType?: "ascending" | "descending"
|
|
5
|
-
/** Callback fired when the
|
|
4
|
+
sortType?: "ascending" | "descending";
|
|
5
|
+
/** Callback fired when the component is clicked */
|
|
6
6
|
onClick?: () => void;
|
|
7
|
-
/** Sets the content of
|
|
8
|
-
children?:
|
|
7
|
+
/** Sets the text content of the component */
|
|
8
|
+
children?: string;
|
|
9
|
+
/** Sets the accessible name of the component */
|
|
10
|
+
accessibleName?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare const Sort: ({ children, onClick, sortType }: SortProps) => React.JSX.Element;
|
|
12
|
+
export declare const Sort: ({ children, onClick, sortType, accessibleName, }: SortProps) => React.JSX.Element;
|
|
11
13
|
export default Sort;
|
|
@@ -7,8 +7,10 @@ exports.default = exports.Sort = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events"));
|
|
10
|
+
var _typography = _interopRequireDefault(require("../../typography"));
|
|
10
11
|
var _sort = require("./sort.style");
|
|
11
12
|
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
13
|
+
var _useLocale = _interopRequireDefault(require("../../../hooks/__internal__/useLocale"));
|
|
12
14
|
var _flatTable = require("../flat-table.component");
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
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,9 +18,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
16
18
|
const Sort = ({
|
|
17
19
|
children,
|
|
18
20
|
onClick,
|
|
19
|
-
sortType
|
|
21
|
+
sortType,
|
|
22
|
+
accessibleName
|
|
20
23
|
}) => {
|
|
21
24
|
const id = (0, _react.useRef)((0, _guid.default)());
|
|
25
|
+
const locale = (0, _useLocale.default)();
|
|
22
26
|
const onKeyDown = e => {
|
|
23
27
|
if (_events.default.isEnterOrSpaceKey(e)) {
|
|
24
28
|
e.preventDefault();
|
|
@@ -29,10 +33,10 @@ const Sort = ({
|
|
|
29
33
|
const {
|
|
30
34
|
colorTheme
|
|
31
35
|
} = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
|
|
32
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
33
|
-
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_typography.default, {
|
|
37
|
+
screenReaderOnly: true,
|
|
34
38
|
id: id.current
|
|
35
|
-
},
|
|
39
|
+
}, accessibleName || locale.sort.accessibleName(children, sortType)), /*#__PURE__*/_react.default.createElement(_sort.StyledSort, {
|
|
36
40
|
role: "button",
|
|
37
41
|
onKeyDown: onKeyDown,
|
|
38
42
|
tabIndex: 0,
|
|
@@ -64,14 +64,14 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
64
64
|
${isSkipLink && (0, _styledComponents.css)`
|
|
65
65
|
a {
|
|
66
66
|
position: absolute;
|
|
67
|
-
padding-left:
|
|
68
|
-
padding-right:
|
|
67
|
+
padding-left: var(--spacing300);
|
|
68
|
+
padding-right: var(--spacing300);
|
|
69
69
|
line-height: 36px;
|
|
70
70
|
left: -999em;
|
|
71
71
|
z-index: ${theme.zIndex.aboveAll};
|
|
72
|
-
box-shadow: inset 0 0 0
|
|
73
|
-
border:
|
|
74
|
-
font-size:
|
|
72
|
+
box-shadow: inset 0 0 0 var(--spacing025) var(--colorsActionMajor500);
|
|
73
|
+
border: var(--spacing025) solid var(--colorsUtilityYang100);
|
|
74
|
+
font-size: var(--fontSizes200);
|
|
75
75
|
color: var(--colorsUtilityYin090);
|
|
76
76
|
|
|
77
77
|
&:hover {
|
|
@@ -89,15 +89,15 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
a:focus {
|
|
92
|
-
top:
|
|
93
|
-
left:
|
|
92
|
+
top: var(--spacing100);
|
|
93
|
+
left: var(--spacing100);
|
|
94
94
|
}
|
|
95
95
|
`}
|
|
96
96
|
|
|
97
97
|
${!isSkipLink && (0, _styledComponents.css)`
|
|
98
|
-
a,
|
|
99
|
-
button {
|
|
100
|
-
font-size:
|
|
98
|
+
> a,
|
|
99
|
+
> button {
|
|
100
|
+
font-size: var(--fontSizes100);
|
|
101
101
|
|
|
102
102
|
${!disabled && (0, _styledComponents.css)`
|
|
103
103
|
color: ${color};
|
|
@@ -108,7 +108,7 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
108
108
|
&:hover {
|
|
109
109
|
color: ${hoverColor};
|
|
110
110
|
|
|
111
|
-
${_icon.default} {
|
|
111
|
+
> ${_icon.default} {
|
|
112
112
|
color: ${hoverColor};
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -129,8 +129,8 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
129
129
|
}
|
|
130
130
|
`}
|
|
131
131
|
|
|
132
|
-
a,
|
|
133
|
-
button {
|
|
132
|
+
> a,
|
|
133
|
+
> button {
|
|
134
134
|
text-decoration: ${hasContent ? "underline" : "none"};
|
|
135
135
|
${isMenuItem && "display: inline-block;"}
|
|
136
136
|
|
|
@@ -169,20 +169,20 @@ const StyledLink = exports.StyledLink = _styledComponents.default.span`
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
${!isSkipLink && !disabled && !theme.focusRedesignOptOut && hasFocus && (0, _styledComponents.css)`
|
|
172
|
-
a,
|
|
173
|
-
button {
|
|
172
|
+
> a,
|
|
173
|
+
> button {
|
|
174
174
|
outline: none;
|
|
175
175
|
text-decoration: none;
|
|
176
176
|
border-bottom-left-radius: var(--borderRadius000);
|
|
177
177
|
border-bottom-right-radius: var(--borderRadius000);
|
|
178
178
|
}
|
|
179
179
|
max-width: fit-content;
|
|
180
|
-
box-shadow: 0
|
|
180
|
+
box-shadow: 0 var(--spacing050) 0 0 var(--colorsUtilityYin090);
|
|
181
181
|
border-bottom-left-radius: var(--borderRadius025);
|
|
182
182
|
border-bottom-right-radius: var(--borderRadius025);
|
|
183
183
|
`}
|
|
184
184
|
|
|
185
|
-
button {
|
|
185
|
+
> button {
|
|
186
186
|
background-color: transparent;
|
|
187
187
|
border: none;
|
|
188
188
|
padding: 0;
|
|
@@ -9,7 +9,7 @@ var _themes = require("../../../../style/themes");
|
|
|
9
9
|
var _link = require("../../../link/link.style");
|
|
10
10
|
var _menu = require("../../menu.style");
|
|
11
11
|
var _menuItem = _interopRequireDefault(require("../../menu-item/menu-item.style"));
|
|
12
|
-
var
|
|
12
|
+
var _icon = _interopRequireDefault(require("../../../icon/icon.style"));
|
|
13
13
|
var _menu2 = _interopRequireDefault(require("../../menu.config"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
@@ -103,17 +103,17 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
103
103
|
${!inFullscreenView && menuType && (0, _styledComponents.css)`
|
|
104
104
|
background-color: ${_menu2.default[menuType].submenuItemBackground};
|
|
105
105
|
|
|
106
|
-
a:focus,
|
|
107
|
-
button:focus {
|
|
106
|
+
> a:focus,
|
|
107
|
+
> button:focus {
|
|
108
108
|
background-color: ${_menu2.default[menuType].submenuItemBackground};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
a:hover,
|
|
112
|
-
button:hover {
|
|
111
|
+
> a:hover,
|
|
112
|
+
> button:hover {
|
|
113
113
|
background-color: transparent;
|
|
114
114
|
color: var(--colorsComponentsMenuYang100);
|
|
115
115
|
|
|
116
|
-
[data-component="icon"] {
|
|
116
|
+
> [data-component="icon"] {
|
|
117
117
|
color: var(--colorsComponentsMenuYang100);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -123,17 +123,26 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
|
|
|
123
123
|
text-decoration: none;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
${
|
|
127
|
-
|
|
126
|
+
> ${_icon.default} {
|
|
127
|
+
width: 16px;
|
|
128
|
+
height: 16px;
|
|
129
|
+
margin-right: 5px;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
[data-component="icon"] {
|
|
134
|
+
line-height: 20px;
|
|
135
|
+
|
|
136
|
+
&:before {
|
|
137
|
+
line-height: unset;
|
|
132
138
|
}
|
|
133
139
|
|
|
134
|
-
|
|
135
|
-
:
|
|
136
|
-
|
|
140
|
+
span {
|
|
141
|
+
vertical-align: middle;
|
|
142
|
+
|
|
143
|
+
svg {
|
|
144
|
+
height: 16px;
|
|
145
|
+
width: 16px;
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
}
|
|
@@ -43,22 +43,6 @@ const MenuFullscreen = ({
|
|
|
43
43
|
const isDarkVariant = ["dark", "black"].includes(menuType);
|
|
44
44
|
const transitionDuration = 200;
|
|
45
45
|
const locale = (0, _useLocale.default)();
|
|
46
|
-
|
|
47
|
-
// TODO: Remove this temporary event handler as part of FE-6078
|
|
48
|
-
const handleFocusedSearchButton = ev => {
|
|
49
|
-
const search = modalRef.current?.querySelector('[data-component="search"]');
|
|
50
|
-
const searchInput = search?.querySelector("input");
|
|
51
|
-
const searchButton = search?.querySelector("button");
|
|
52
|
-
|
|
53
|
-
// if there is no value in the search input the button disappears when the input blurs
|
|
54
|
-
// this means we need to programmatically set focus to the next menu item
|
|
55
|
-
if (searchButton && searchInput && !searchInput.value && searchInput === document.activeElement) {
|
|
56
|
-
ev.preventDefault();
|
|
57
|
-
const elements = Array.from(modalRef.current?.querySelectorAll("a, input, button"));
|
|
58
|
-
const index = elements.indexOf(searchInput);
|
|
59
|
-
elements[index + 2]?.focus();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
46
|
const flattenedChildren = _react.default.Children.toArray(children);
|
|
63
47
|
const childArray = _react.default.Children.toArray(flattenedChildren.map((child, index) => {
|
|
64
48
|
if (index < flattenedChildren.length - 1) {
|
|
@@ -97,7 +81,6 @@ const MenuFullscreen = ({
|
|
|
97
81
|
"data-element": dataElement,
|
|
98
82
|
"data-role": dataRole,
|
|
99
83
|
menuType: menuType,
|
|
100
|
-
onKeyDown: ev => _events.default.isTabKey(ev) && !_events.default.isShiftKey(ev) && handleFocusedSearchButton(ev),
|
|
101
84
|
ref: modalRef,
|
|
102
85
|
role: "dialog",
|
|
103
86
|
tabIndex: -1
|
|
@@ -13,6 +13,7 @@ var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
|
13
13
|
var _button = _interopRequireDefault(require("../../button/button.style"));
|
|
14
14
|
var _menu = _interopRequireDefault(require("../menu.config"));
|
|
15
15
|
var _addFocusStyling = _interopRequireDefault(require("../../../style/utils/add-focus-styling"));
|
|
16
|
+
var _link = require("../../link/link.style");
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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 && Object.prototype.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; }
|
|
@@ -63,10 +64,16 @@ const StyledMenuModal = exports.StyledMenuModal = _styledComponents.default.div`
|
|
|
63
64
|
width: 100vw;
|
|
64
65
|
outline: none;
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
&& {
|
|
68
|
+
${_link.StyledLink} {
|
|
69
|
+
max-width: 100vw;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
${_link.StyledLink} > a,
|
|
73
|
+
${_link.StyledLink} > button,
|
|
74
|
+
> div {
|
|
75
|
+
font-size: var(--fontSizes200);
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
${({
|
|
@@ -76,30 +83,9 @@ const StyledMenuModal = exports.StyledMenuModal = _styledComponents.default.div`
|
|
|
76
83
|
background-color: ${_menu.default[menuType].background};
|
|
77
84
|
|
|
78
85
|
&& {
|
|
79
|
-
${
|
|
80
|
-
${_search.default} span > [data-component="icon"] {
|
|
81
|
-
color: var(--colorsUtilityMajor200);
|
|
82
|
-
|
|
83
|
-
&:hover {
|
|
84
|
-
color: var(--colorsUtilityMajor150);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
`}
|
|
88
|
-
|
|
89
|
-
${menuType === "light" && (0, _styledComponents.css)`
|
|
90
|
-
${_search.default} span > [data-component="icon"] {
|
|
91
|
-
color: var(--colorsUtilityMajor200);
|
|
92
|
-
|
|
93
|
-
&:hover {
|
|
94
|
-
color: var(--colorsUtilityMajor400);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`}
|
|
98
|
-
|
|
99
|
-
${_search.default} {
|
|
86
|
+
${_search.default} {
|
|
100
87
|
${_icon.default} {
|
|
101
88
|
display: inline-flex;
|
|
102
|
-
margin-right: 0;
|
|
103
89
|
bottom: auto;
|
|
104
90
|
}
|
|
105
91
|
|
|
@@ -64,8 +64,6 @@ const MenuItem = ({
|
|
|
64
64
|
const focusFromMenu = focusId === menuItemId.current;
|
|
65
65
|
const focusFromSubmenu = submenuFocusId ? submenuFocusId === menuItemId.current : undefined;
|
|
66
66
|
const inputRef = (0, _react.useRef)(null);
|
|
67
|
-
const inputIcon = (0, _react.useRef)(null);
|
|
68
|
-
inputIcon.current = ref.current ? ref.current.querySelector("[data-element='input-icon-toggle']") : null;
|
|
69
67
|
inputRef.current = ref.current ? ref.current.querySelector("[data-element='input']") : null;
|
|
70
68
|
const focusRef = inputRef.current ? inputRef : ref;
|
|
71
69
|
(0, _react.useEffect)(() => {
|
|
@@ -80,18 +78,19 @@ const MenuItem = ({
|
|
|
80
78
|
};
|
|
81
79
|
}, [registerItem, unregisterItem]);
|
|
82
80
|
(0, _react.useEffect)(() => {
|
|
81
|
+
const inputIcon = ref.current?.querySelector("[data-element='input-icon-toggle']");
|
|
83
82
|
if (!openSubmenuId && focusFromSubmenu === undefined && focusFromMenu) {
|
|
84
83
|
/* istanbul ignore else */
|
|
85
84
|
if (focusRef.current) {
|
|
86
85
|
focusRef.current?.focus();
|
|
87
86
|
}
|
|
88
|
-
} else if (focusFromSubmenu && !(shiftTabPressed && inputIcon
|
|
87
|
+
} else if (focusFromSubmenu && !(shiftTabPressed && inputIcon?.getAttribute("tabindex") === "0")) {
|
|
89
88
|
/* istanbul ignore else */
|
|
90
89
|
if (focusRef.current) {
|
|
91
90
|
focusRef.current?.focus();
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
|
-
}, [openSubmenuId, focusFromMenu, focusFromSubmenu,
|
|
93
|
+
}, [openSubmenuId, focusFromMenu, focusFromSubmenu, shiftTabPressed, focusRef]);
|
|
95
94
|
const updateFocusOnClick = (0, _react.useCallback)(() => {
|
|
96
95
|
if (updateSubmenuFocusId) {
|
|
97
96
|
updateSubmenuFocusId(menuItemId.current);
|
|
@@ -104,16 +103,17 @@ const MenuItem = ({
|
|
|
104
103
|
if (ref.current && _events.default.isEscKey(event)) {
|
|
105
104
|
ref.current?.focus();
|
|
106
105
|
}
|
|
107
|
-
const
|
|
106
|
+
const inputIcon = ref.current?.querySelector("[data-element='input-icon-toggle']");
|
|
107
|
+
const shouldFocusIcon = inputIcon?.getAttribute("tabindex") === "0" && document.activeElement === inputRef.current && inputRef.current?.value;
|
|
108
108
|
|
|
109
109
|
// let natural tab order move focus if input icon is tabbable or input with button exists
|
|
110
|
-
if (_events.default.isTabKey(event) && (!_events.default.isShiftKey(event) && shouldFocusIcon || _events.default.isShiftKey(event) && document.activeElement === inputIcon
|
|
110
|
+
if (_events.default.isTabKey(event) && (!_events.default.isShiftKey(event) && shouldFocusIcon || _events.default.isShiftKey(event) && document.activeElement === inputIcon)) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
if (handleSubmenuKeyDown) {
|
|
114
114
|
handleSubmenuKeyDown(event);
|
|
115
115
|
}
|
|
116
|
-
}, [onKeyDown, handleSubmenuKeyDown
|
|
116
|
+
}, [onKeyDown, handleSubmenuKeyDown]);
|
|
117
117
|
const elementProps = {
|
|
118
118
|
className: href || onClick ? "carbon-menu-item--has-link" : "",
|
|
119
119
|
href,
|
|
@@ -158,9 +158,11 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
158
158
|
${!hasInput && `color: ${_menu.default[menuType].color};`}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
${
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
${!inFullscreenView && (0, _styledComponents.css)`
|
|
162
|
+
a > ${_icon.default}, button > ${_icon.default} {
|
|
163
|
+
display: inline-block;
|
|
164
|
+
}
|
|
165
|
+
`}
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
${selected && (0, _styledComponents.css)`
|
|
@@ -322,10 +324,10 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
|
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
&& {
|
|
325
|
-
a:focus,
|
|
326
|
-
a:hover,
|
|
327
|
-
button:focus,
|
|
328
|
-
button:hover {
|
|
327
|
+
> a:focus,
|
|
328
|
+
> a:hover,
|
|
329
|
+
> button:focus,
|
|
330
|
+
> button:hover {
|
|
329
331
|
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
330
332
|
color: var(--colorsComponentsMenuYang100);
|
|
331
333
|
|
|
@@ -10,6 +10,7 @@ var _menu = _interopRequireDefault(require("./menu.config"));
|
|
|
10
10
|
var _verticalDivider = require("../vertical-divider/vertical-divider.style");
|
|
11
11
|
var _link = require("../link/link.style");
|
|
12
12
|
var _themes = require("../../style/themes");
|
|
13
|
+
var _menuItem = _interopRequireDefault(require("./menu-item/menu-item.style"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
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); }
|
|
15
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 && Object.prototype.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; }
|
|
@@ -75,7 +76,9 @@ const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
|
|
|
75
76
|
}
|
|
76
77
|
`}
|
|
77
78
|
|
|
78
|
-
${
|
|
79
|
+
${_menuItem.default} {
|
|
80
|
+
${_styledSystem.padding}
|
|
81
|
+
}
|
|
79
82
|
`;
|
|
80
83
|
StyledMenuItem.defaultProps = {
|
|
81
84
|
theme: _themes.baseTheme
|