carbon-react 143.2.4 → 144.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.
@@ -12,6 +12,7 @@ const StyledSubmenuWrapper = styled.div`
12
12
  position: relative;
13
13
  width: fit-content;
14
14
  max-width: inherit;
15
+ height: inherit;
15
16
 
16
17
  ${({
17
18
  isSubmenuOpen,
@@ -24,7 +25,8 @@ const StyledSubmenuWrapper = styled.div`
24
25
  inFullscreenView,
25
26
  menuType,
26
27
  asPassiveItem
27
- }) => inFullscreenView && css`
28
+ }) => css`
29
+ ${inFullscreenView && css`
28
30
  width: 100%;
29
31
 
30
32
  ${asPassiveItem && menuType && css`
@@ -34,6 +36,10 @@ const StyledSubmenuWrapper = styled.div`
34
36
  }
35
37
  `}
36
38
  `}
39
+ ${!inFullscreenView && css`
40
+ display: flex;
41
+ `}
42
+ `}
37
43
  `;
38
44
  const StyledSubmenu = styled.ul`
39
45
  ${({
@@ -49,6 +55,7 @@ const StyledSubmenu = styled.ul`
49
55
  ${!inFullscreenView && menuType && css`
50
56
  box-shadow: var(--boxShadow100);
51
57
  position: absolute;
58
+ top: 100%;
52
59
  background-color: ${variant === "default" ? menuConfigVariants[menuType].submenuItemBackground : menuConfigVariants[menuType].background};
53
60
 
54
61
  min-width: 100%;
@@ -170,10 +177,6 @@ const StyledSubmenu = styled.ul`
170
177
  > a,
171
178
  > button {
172
179
  padding: 11px 16px 12px;
173
-
174
- :has([data-component="icon"]) {
175
- padding: 9px 16px 7px;
176
- }
177
180
  }
178
181
  `}
179
182
 
@@ -3,7 +3,7 @@ import { FlexboxProps, LayoutProps, MaxWidthProps, PaddingProps } from "styled-s
3
3
  import { IconType } from "../../icon";
4
4
  import { TagProps } from "../../../__internal__/utils/helpers/tags";
5
5
  export declare type VariantType = "default" | "alternate";
6
- interface MenuItemBaseProps extends Omit<TagProps, "data-component">, LayoutProps, FlexboxProps, PaddingProps {
6
+ interface MenuItemBaseProps extends Omit<TagProps, "data-component">, Pick<LayoutProps, "width" | "maxWidth" | "minWidth">, FlexboxProps, PaddingProps {
7
7
  /** Custom className */
8
8
  className?: string;
9
9
  /** onClick handler */
@@ -37,6 +37,7 @@ export const MenuItem = ({
37
37
  }) => {
38
38
  !(icon || children) ? process.env.NODE_ENV !== "production" ? invariant(false, "Either prop `icon` must be defined or this node must have `children`.") : invariant(false) : void 0;
39
39
  !(children || ariaLabel || typeof submenu === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "If no text is provided an `ariaLabel` should be given to facilitate accessibility.") : invariant(false) : void 0;
40
+ !(typeof submenu === "boolean" || submenu === undefined || children && typeof submenu === "string" && submenu.length) ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not pass `children` when `submenu` is an empty string") : invariant(false) : void 0;
40
41
  const {
41
42
  inFullscreenView,
42
43
  registerItem,
@@ -182,7 +183,8 @@ export const MenuItem = ({
182
183
  placeholderTabIndex: asPassiveItem
183
184
  }, paddingProps, {
184
185
  asDiv: hasInput || as === "div",
185
- hasInput: hasInput
186
+ hasInput: hasInput,
187
+ inSubmenu: !!handleSubmenuKeyDown
186
188
  }), children));
187
189
  };
188
190
  MenuItem.displayName = "MenuItem";
@@ -15,6 +15,7 @@ interface StyledMenuItemWrapperProps extends Pick<MenuWithChildren, "href" | "sh
15
15
  asDiv?: boolean;
16
16
  hasInput?: boolean;
17
17
  menuItemVariant?: Pick<MenuWithChildren, "variant">["variant"];
18
+ inSubmenu?: boolean;
18
19
  }
19
20
  declare const StyledMenuItemWrapper: import("styled-components").StyledComponent<"a", any, {
20
21
  as: import("react").ForwardRefExoticComponent<import("../../link").LinkProps & import("react").RefAttributes<HTMLButtonElement | HTMLLinkElement>>;
@@ -94,7 +94,8 @@ const StyledMenuItemWrapper = styled.a.attrs({
94
94
  overrideColor,
95
95
  asPassiveItem,
96
96
  asDiv,
97
- hasInput
97
+ hasInput,
98
+ inSubmenu
98
99
  }) => css`
99
100
  display: flex;
100
101
  align-items: center;
@@ -107,6 +108,9 @@ const StyledMenuItemWrapper = styled.a.attrs({
107
108
  a,
108
109
  button {
109
110
  cursor: pointer;
111
+ min-height: 40px;
112
+ height: 100%;
113
+ box-sizing: border-box;
110
114
  }
111
115
 
112
116
  a:focus,
@@ -123,7 +127,7 @@ const StyledMenuItemWrapper = styled.a.attrs({
123
127
  button:has([data-component="icon"]):not(:has(button))
124
128
  ${StyledContent} {
125
129
  position: relative;
126
- top: -2px;
130
+ top: -1px;
127
131
  }
128
132
  `}
129
133
 
@@ -143,11 +147,16 @@ const StyledMenuItemWrapper = styled.a.attrs({
143
147
 
144
148
  ${!inFullscreenView && css`
145
149
  max-width: inherit;
150
+ width: inherit;
151
+ height: inherit;
146
152
 
147
153
  > a,
148
154
  > button {
149
155
  display: flex;
150
156
  align-items: center;
157
+ ${!inSubmenu ? "justify-content: center;" : ""}
158
+ width: inherit;
159
+ max-width: inherit;
151
160
  }
152
161
 
153
162
  && {
@@ -194,15 +203,29 @@ const StyledMenuItemWrapper = styled.a.attrs({
194
203
 
195
204
  ${asPassiveItem ? `
196
205
  ${!inFullscreenView && `
197
- > a:not(:has(button)) {
198
- padding: 11px 16px 12px;
199
- }
206
+ > a:not(:has(button)) {
207
+ padding: 11px 16px;
208
+ }
200
209
 
201
- > a ${StyledButton}:not(.search-button) {
202
- min-height: 17px;
203
- padding: 9px 0px 11px;
204
- }
205
- `}
210
+ > a:has(${StyledButton}:not(.search-button)) {
211
+ height: 100%;
212
+
213
+ ${StyledContent} {
214
+ height: inherit;
215
+
216
+ div {
217
+ height: inherit;
218
+ }
219
+ }
220
+
221
+ ${StyledButton} {
222
+ min-height: 40px;
223
+ padding: 10px 0px;
224
+ box-sizing: border-box;
225
+ height: 100%;
226
+ }
227
+ }
228
+ `}
206
229
 
207
230
  ${StyledIconButton} {
208
231
  > span {
@@ -218,28 +241,37 @@ const StyledMenuItemWrapper = styled.a.attrs({
218
241
  }
219
242
  }
220
243
  ` : `
221
- a,
222
- ${StyledLink} a,
223
- button,
224
- ${StyledLink} button {
225
-
226
- padding: ${inFullscreenView ? "0px 16px" : "11px 16px 12px"};
227
-
228
- :has([data-component="icon"]) {
229
- padding: 9px 16px 7px;
230
- }
231
- }
244
+ ${hasSubmenu || maxWidth ? `
245
+ a,
246
+ ${StyledLink} a,
247
+ button,
248
+ ${StyledLink} button {
249
+ padding: 11px 16px ${hasSubmenu && maxWidth ? "12px" : "10px"};
250
+ }
251
+ ` : `
252
+ a,
253
+ ${StyledLink} a,
254
+ button,
255
+ ${StyledLink} button {
256
+ padding: ${!inFullscreenView ? "11px" : "0px"} 16px;
257
+ }
258
+ `}
232
259
  `}
233
260
 
234
261
  button,
235
- ${StyledLink} button {
236
- height: 40px;
262
+ ${StyledLink} button,
263
+ a,
264
+ ${StyledLink} a {
237
265
  margin: 0px;
238
266
  text-align: left;
239
267
 
240
268
  ${inFullscreenView && css`
241
269
  height: auto;
242
270
  white-space: normal;
271
+
272
+ ${StyledIcon} {
273
+ top: -2px;
274
+ }
243
275
  `}
244
276
  }
245
277
 
@@ -258,6 +290,8 @@ const StyledMenuItemWrapper = styled.a.attrs({
258
290
  ${!inFullscreenView && css`
259
291
  a > ${StyledIcon}, button > ${StyledIcon} {
260
292
  display: inline-block;
293
+ height: 18px;
294
+ top: -2px;
261
295
  }
262
296
  `}
263
297
  }
@@ -361,7 +395,7 @@ const StyledMenuItemWrapper = styled.a.attrs({
361
395
  a::before,
362
396
  button::before {
363
397
  display: block;
364
- margin-top: -2px;
398
+ margin-top: -1px;
365
399
  pointer-events: none;
366
400
  position: absolute;
367
401
  right: ${props => parsePadding(padding(props)).iconSpacing};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { LayoutProps, FlexboxProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags";
4
4
  import { MenuType } from "./__internal__/menu.context";
5
- export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
5
+ export interface MenuProps extends TagProps, Pick<LayoutProps, "width" | "minWidth" | "maxWidth" | "overflow" | "overflowX" | "verticalAlign">, FlexboxProps {
6
6
  /** Children elements */
7
7
  children: React.ReactNode;
8
8
  /** Defines the color scheme of the component */
@@ -10,6 +10,8 @@ const StyledMenuWrapper = styled.ul`
10
10
  padding: 0;
11
11
  outline: none;
12
12
  display: flex;
13
+ align-items: stretch;
14
+ min-height: 40px;
13
15
 
14
16
  ${layout}
15
17
  ${flexbox}
@@ -32,6 +34,13 @@ const StyledMenuWrapper = styled.ul`
32
34
  }
33
35
  `;
34
36
  const StyledMenuItem = styled.li`
37
+ display: flex;
38
+ ${({
39
+ maxWidth
40
+ }) => maxWidth && css`
41
+ align-items: stretch;
42
+ `}
43
+
35
44
  ${layout}
36
45
  ${flexbox}
37
46
 
@@ -45,6 +54,10 @@ const StyledMenuItem = styled.li`
45
54
  ${inSubmenu && css`
46
55
  display: list-item;
47
56
  `}
57
+
58
+ ${!inSubmenu && css`
59
+ height: inherit;
60
+ `}
48
61
  `}
49
62
 
50
63
  ${({
@@ -17,7 +17,6 @@ const Accordion = ({
17
17
  }
18
18
  });
19
19
  return /*#__PURE__*/React.createElement(StyledContentContainer, {
20
- "aria-expanded": expanded,
21
20
  isExpanded: expanded,
22
21
  maxHeight: contentHeight,
23
22
  "data-role": "tile-select-accordion-content-container"
@@ -21,6 +21,7 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
21
21
  position: relative;
22
22
  width: fit-content;
23
23
  max-width: inherit;
24
+ height: inherit;
24
25
 
25
26
  ${({
26
27
  isSubmenuOpen,
@@ -33,7 +34,8 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
33
34
  inFullscreenView,
34
35
  menuType,
35
36
  asPassiveItem
36
- }) => inFullscreenView && (0, _styledComponents.css)`
37
+ }) => (0, _styledComponents.css)`
38
+ ${inFullscreenView && (0, _styledComponents.css)`
37
39
  width: 100%;
38
40
 
39
41
  ${asPassiveItem && menuType && (0, _styledComponents.css)`
@@ -43,6 +45,10 @@ const StyledSubmenuWrapper = exports.StyledSubmenuWrapper = _styledComponents.de
43
45
  }
44
46
  `}
45
47
  `}
48
+ ${!inFullscreenView && (0, _styledComponents.css)`
49
+ display: flex;
50
+ `}
51
+ `}
46
52
  `;
47
53
  const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
48
54
  ${({
@@ -58,6 +64,7 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
58
64
  ${!inFullscreenView && menuType && (0, _styledComponents.css)`
59
65
  box-shadow: var(--boxShadow100);
60
66
  position: absolute;
67
+ top: 100%;
61
68
  background-color: ${variant === "default" ? _menu2.default[menuType].submenuItemBackground : _menu2.default[menuType].background};
62
69
 
63
70
  min-width: 100%;
@@ -179,10 +186,6 @@ const StyledSubmenu = exports.StyledSubmenu = _styledComponents.default.ul`
179
186
  > a,
180
187
  > button {
181
188
  padding: 11px 16px 12px;
182
-
183
- :has([data-component="icon"]) {
184
- padding: 9px 16px 7px;
185
- }
186
189
  }
187
190
  `}
188
191
 
@@ -3,7 +3,7 @@ import { FlexboxProps, LayoutProps, MaxWidthProps, PaddingProps } from "styled-s
3
3
  import { IconType } from "../../icon";
4
4
  import { TagProps } from "../../../__internal__/utils/helpers/tags";
5
5
  export declare type VariantType = "default" | "alternate";
6
- interface MenuItemBaseProps extends Omit<TagProps, "data-component">, LayoutProps, FlexboxProps, PaddingProps {
6
+ interface MenuItemBaseProps extends Omit<TagProps, "data-component">, Pick<LayoutProps, "width" | "maxWidth" | "minWidth">, FlexboxProps, PaddingProps {
7
7
  /** Custom className */
8
8
  className?: string;
9
9
  /** onClick handler */
@@ -46,6 +46,7 @@ const MenuItem = ({
46
46
  }) => {
47
47
  !(icon || children) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `icon` must be defined or this node must have `children`.") : (0, _invariant.default)(false) : void 0;
48
48
  !(children || ariaLabel || typeof submenu === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "If no text is provided an `ariaLabel` should be given to facilitate accessibility.") : (0, _invariant.default)(false) : void 0;
49
+ !(typeof submenu === "boolean" || submenu === undefined || children && typeof submenu === "string" && submenu.length) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "You should not pass `children` when `submenu` is an empty string") : (0, _invariant.default)(false) : void 0;
49
50
  const {
50
51
  inFullscreenView,
51
52
  registerItem,
@@ -191,7 +192,8 @@ const MenuItem = ({
191
192
  placeholderTabIndex: asPassiveItem
192
193
  }, paddingProps, {
193
194
  asDiv: hasInput || as === "div",
194
- hasInput: hasInput
195
+ hasInput: hasInput,
196
+ inSubmenu: !!handleSubmenuKeyDown
195
197
  }), children));
196
198
  };
197
199
  exports.MenuItem = MenuItem;
@@ -15,6 +15,7 @@ interface StyledMenuItemWrapperProps extends Pick<MenuWithChildren, "href" | "sh
15
15
  asDiv?: boolean;
16
16
  hasInput?: boolean;
17
17
  menuItemVariant?: Pick<MenuWithChildren, "variant">["variant"];
18
+ inSubmenu?: boolean;
18
19
  }
19
20
  declare const StyledMenuItemWrapper: import("styled-components").StyledComponent<"a", any, {
20
21
  as: import("react").ForwardRefExoticComponent<import("../../link").LinkProps & import("react").RefAttributes<HTMLButtonElement | HTMLLinkElement>>;
@@ -103,7 +103,8 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
103
103
  overrideColor,
104
104
  asPassiveItem,
105
105
  asDiv,
106
- hasInput
106
+ hasInput,
107
+ inSubmenu
107
108
  }) => (0, _styledComponents.css)`
108
109
  display: flex;
109
110
  align-items: center;
@@ -116,6 +117,9 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
116
117
  a,
117
118
  button {
118
119
  cursor: pointer;
120
+ min-height: 40px;
121
+ height: 100%;
122
+ box-sizing: border-box;
119
123
  }
120
124
 
121
125
  a:focus,
@@ -132,7 +136,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
132
136
  button:has([data-component="icon"]):not(:has(button))
133
137
  ${_link.StyledContent} {
134
138
  position: relative;
135
- top: -2px;
139
+ top: -1px;
136
140
  }
137
141
  `}
138
142
 
@@ -152,11 +156,16 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
152
156
 
153
157
  ${!inFullscreenView && (0, _styledComponents.css)`
154
158
  max-width: inherit;
159
+ width: inherit;
160
+ height: inherit;
155
161
 
156
162
  > a,
157
163
  > button {
158
164
  display: flex;
159
165
  align-items: center;
166
+ ${!inSubmenu ? "justify-content: center;" : ""}
167
+ width: inherit;
168
+ max-width: inherit;
160
169
  }
161
170
 
162
171
  && {
@@ -203,15 +212,29 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
203
212
 
204
213
  ${asPassiveItem ? `
205
214
  ${!inFullscreenView && `
206
- > a:not(:has(button)) {
207
- padding: 11px 16px 12px;
208
- }
215
+ > a:not(:has(button)) {
216
+ padding: 11px 16px;
217
+ }
209
218
 
210
- > a ${_button.default}:not(.search-button) {
211
- min-height: 17px;
212
- padding: 9px 0px 11px;
213
- }
214
- `}
219
+ > a:has(${_button.default}:not(.search-button)) {
220
+ height: 100%;
221
+
222
+ ${_link.StyledContent} {
223
+ height: inherit;
224
+
225
+ div {
226
+ height: inherit;
227
+ }
228
+ }
229
+
230
+ ${_button.default} {
231
+ min-height: 40px;
232
+ padding: 10px 0px;
233
+ box-sizing: border-box;
234
+ height: 100%;
235
+ }
236
+ }
237
+ `}
215
238
 
216
239
  ${_iconButton.default} {
217
240
  > span {
@@ -227,28 +250,37 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
227
250
  }
228
251
  }
229
252
  ` : `
230
- a,
231
- ${_link.StyledLink} a,
232
- button,
233
- ${_link.StyledLink} button {
234
-
235
- padding: ${inFullscreenView ? "0px 16px" : "11px 16px 12px"};
236
-
237
- :has([data-component="icon"]) {
238
- padding: 9px 16px 7px;
239
- }
240
- }
253
+ ${hasSubmenu || maxWidth ? `
254
+ a,
255
+ ${_link.StyledLink} a,
256
+ button,
257
+ ${_link.StyledLink} button {
258
+ padding: 11px 16px ${hasSubmenu && maxWidth ? "12px" : "10px"};
259
+ }
260
+ ` : `
261
+ a,
262
+ ${_link.StyledLink} a,
263
+ button,
264
+ ${_link.StyledLink} button {
265
+ padding: ${!inFullscreenView ? "11px" : "0px"} 16px;
266
+ }
267
+ `}
241
268
  `}
242
269
 
243
270
  button,
244
- ${_link.StyledLink} button {
245
- height: 40px;
271
+ ${_link.StyledLink} button,
272
+ a,
273
+ ${_link.StyledLink} a {
246
274
  margin: 0px;
247
275
  text-align: left;
248
276
 
249
277
  ${inFullscreenView && (0, _styledComponents.css)`
250
278
  height: auto;
251
279
  white-space: normal;
280
+
281
+ ${_icon.default} {
282
+ top: -2px;
283
+ }
252
284
  `}
253
285
  }
254
286
 
@@ -267,6 +299,8 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
267
299
  ${!inFullscreenView && (0, _styledComponents.css)`
268
300
  a > ${_icon.default}, button > ${_icon.default} {
269
301
  display: inline-block;
302
+ height: 18px;
303
+ top: -2px;
270
304
  }
271
305
  `}
272
306
  }
@@ -370,7 +404,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
370
404
  a::before,
371
405
  button::before {
372
406
  display: block;
373
- margin-top: -2px;
407
+ margin-top: -1px;
374
408
  pointer-events: none;
375
409
  position: absolute;
376
410
  right: ${props => parsePadding((0, _styledSystem.padding)(props)).iconSpacing};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { LayoutProps, FlexboxProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags";
4
4
  import { MenuType } from "./__internal__/menu.context";
5
- export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
5
+ export interface MenuProps extends TagProps, Pick<LayoutProps, "width" | "minWidth" | "maxWidth" | "overflow" | "overflowX" | "verticalAlign">, FlexboxProps {
6
6
  /** Children elements */
7
7
  children: React.ReactNode;
8
8
  /** Defines the color scheme of the component */
@@ -19,6 +19,8 @@ const StyledMenuWrapper = exports.StyledMenuWrapper = _styledComponents.default.
19
19
  padding: 0;
20
20
  outline: none;
21
21
  display: flex;
22
+ align-items: stretch;
23
+ min-height: 40px;
22
24
 
23
25
  ${_styledSystem.layout}
24
26
  ${_styledSystem.flexbox}
@@ -41,6 +43,13 @@ const StyledMenuWrapper = exports.StyledMenuWrapper = _styledComponents.default.
41
43
  }
42
44
  `;
43
45
  const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
46
+ display: flex;
47
+ ${({
48
+ maxWidth
49
+ }) => maxWidth && (0, _styledComponents.css)`
50
+ align-items: stretch;
51
+ `}
52
+
44
53
  ${_styledSystem.layout}
45
54
  ${_styledSystem.flexbox}
46
55
 
@@ -54,6 +63,10 @@ const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
54
63
  ${inSubmenu && (0, _styledComponents.css)`
55
64
  display: list-item;
56
65
  `}
66
+
67
+ ${!inSubmenu && (0, _styledComponents.css)`
68
+ height: inherit;
69
+ `}
57
70
  `}
58
71
 
59
72
  ${({
@@ -26,7 +26,6 @@ const Accordion = ({
26
26
  }
27
27
  });
28
28
  return /*#__PURE__*/_react.default.createElement(_accordion.StyledContentContainer, {
29
- "aria-expanded": expanded,
30
29
  isExpanded: expanded,
31
30
  maxHeight: contentHeight,
32
31
  "data-role": "tile-select-accordion-content-container"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "143.2.4",
3
+ "version": "144.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",