carbon-react 128.4.0 → 129.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/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/components/text-editor/text-editor.component.js +3 -3
- package/esm/locales/__internal__/es-es.js +3 -0
- package/esm/locales/en-gb.js +3 -0
- package/esm/locales/locale.d.ts +3 -0
- 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/components/text-editor/text-editor.component.js +3 -3
- package/lib/locales/__internal__/es-es.js +3 -0
- package/lib/locales/en-gb.js +3 -0
- package/lib/locales/locale.d.ts +3 -0
- 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
|
|
|
@@ -192,12 +192,12 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
192
192
|
};
|
|
193
193
|
const handleEditorFocus = useCallback(focusValue => {
|
|
194
194
|
moveCursor.current = true;
|
|
195
|
-
|
|
196
|
-
if (!isFocused && focusValue && typeof editor === "object" && editor.current !== document.activeElement) {
|
|
195
|
+
if (focusValue && typeof editor === "object" && editor.current !== document.activeElement) {
|
|
197
196
|
editor.current?.focus();
|
|
198
197
|
setFocusToolbar(false);
|
|
199
198
|
}
|
|
200
|
-
|
|
199
|
+
setIsFocused(focusValue);
|
|
200
|
+
}, [editor]);
|
|
201
201
|
const handleInlineStyleChange = (ev, style) => {
|
|
202
202
|
ev.preventDefault();
|
|
203
203
|
setActiveInlines({
|
package/esm/locales/en-gb.js
CHANGED
package/esm/locales/locale.d.ts
CHANGED
|
@@ -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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./search.component";
|
|
2
|
-
export type { SearchProps, SearchEvent } from "./search.component";
|
|
2
|
+
export type { SearchProps, SearchEvent, SearchHandle, } from "./search.component";
|
|
@@ -20,7 +20,7 @@ const StyledSearchButton = _styledComponents.default.div`
|
|
|
20
20
|
border-bottom: none;
|
|
21
21
|
|
|
22
22
|
& ${_button.default} {
|
|
23
|
-
|
|
23
|
+
color: var(--colorsActionMajorYang100);
|
|
24
24
|
border-color: var(--colorsActionMajorTransparent);
|
|
25
25
|
border-bottom-left-radius: var(--borderRadius000);
|
|
26
26
|
border-top-left-radius: var(--borderRadius000);
|
|
@@ -28,13 +28,18 @@ const StyledSearchButton = _styledComponents.default.div`
|
|
|
28
28
|
border-top-right-radius: var(--borderRadius050);
|
|
29
29
|
|
|
30
30
|
:hover {
|
|
31
|
-
background: var(--colorsActionMajor600);
|
|
32
31
|
border-color: var(--colorsActionMajorTransparent);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
width:
|
|
34
|
+
width: fit-content;
|
|
35
|
+
|
|
36
|
+
${_icon.default}${_icon.default} {
|
|
37
|
+
color: var(--colorsActionMajorYang100);
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
margin: 0px 0px;
|
|
37
41
|
padding-bottom: 3px;
|
|
42
|
+
|
|
38
43
|
:focus {
|
|
39
44
|
z-index: ${({
|
|
40
45
|
theme
|
|
@@ -17,8 +17,6 @@ export interface SearchProps extends ValidationProps, MarginProps {
|
|
|
17
17
|
defaultValue?: string;
|
|
18
18
|
/** Prop for `id` */
|
|
19
19
|
id?: string;
|
|
20
|
-
/** A callback to retrieve the input reference */
|
|
21
|
-
inputRef?: React.MutableRefObject<HTMLInputElement | null>;
|
|
22
20
|
/** Prop for `name` */
|
|
23
21
|
name?: string;
|
|
24
22
|
/** Prop for `onBlur` events */
|
|
@@ -35,8 +33,11 @@ export interface SearchProps extends ValidationProps, MarginProps {
|
|
|
35
33
|
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
36
34
|
/** Prop for a placeholder */
|
|
37
35
|
placeholder?: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Pass a boolean to render a search Button with default text.
|
|
38
|
+
* Pass a string to override the text in the search Button
|
|
39
|
+
* */
|
|
40
|
+
searchButton?: boolean | string;
|
|
40
41
|
/**
|
|
41
42
|
* Prop for specifying an input width length.
|
|
42
43
|
* Leaving the `searchWidth` prop with no value will default the width to '100%'
|
|
@@ -47,8 +48,6 @@ export interface SearchProps extends ValidationProps, MarginProps {
|
|
|
47
48
|
* Leaving the `maxWidth` prop with no value will default the width to '100%'
|
|
48
49
|
*/
|
|
49
50
|
maxWidth?: string;
|
|
50
|
-
/** Prop for active search threshold. This must be a positive number */
|
|
51
|
-
threshold?: number;
|
|
52
51
|
/** Prop for `controlled` use */
|
|
53
52
|
value?: string;
|
|
54
53
|
/** Prop to specify the styling of the search component */
|
|
@@ -58,5 +57,9 @@ export interface SearchProps extends ValidationProps, MarginProps {
|
|
|
58
57
|
/** Overrides the default tooltip position */
|
|
59
58
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
60
59
|
}
|
|
61
|
-
export declare
|
|
60
|
+
export declare type SearchHandle = {
|
|
61
|
+
/** Programmatically focus on root container of Dialog. */
|
|
62
|
+
focus: () => void;
|
|
63
|
+
} | null;
|
|
64
|
+
export declare const Search: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<SearchHandle>>;
|
|
62
65
|
export default Search;
|