carbon-react 138.0.1 → 138.1.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.
Files changed (24) hide show
  1. package/esm/__internal__/input-icon-toggle/input-icon-toggle.component.js +2 -1
  2. package/esm/components/button-minor/button-minor.component.d.ts +1 -4
  3. package/esm/components/button-minor/button-minor.component.js +348 -3
  4. package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -4
  5. package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +4 -1
  6. package/esm/components/menu/menu-item/menu-item.component.js +5 -1
  7. package/esm/components/menu/menu-segment-title/menu-segment-title.component.js +3 -1
  8. package/esm/components/menu/scrollable-block/scrollable-block.component.js +2 -1
  9. package/esm/components/pill/pill.style.js +34 -76
  10. package/lib/__internal__/input-icon-toggle/input-icon-toggle.component.js +2 -1
  11. package/lib/components/button-minor/button-minor.component.d.ts +1 -4
  12. package/lib/components/button-minor/button-minor.component.js +347 -4
  13. package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -4
  14. package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +4 -1
  15. package/lib/components/menu/menu-item/menu-item.component.js +5 -1
  16. package/lib/components/menu/menu-segment-title/menu-segment-title.component.js +3 -1
  17. package/lib/components/menu/scrollable-block/scrollable-block.component.js +2 -1
  18. package/lib/components/pill/pill.style.js +34 -76
  19. package/package.json +1 -1
  20. package/esm/components/menu/__internal__/spec-helper/index.d.ts +0 -3
  21. package/esm/components/menu/__internal__/spec-helper/index.js +0 -19
  22. package/lib/components/menu/__internal__/spec-helper/index.d.ts +0 -3
  23. package/lib/components/menu/__internal__/spec-helper/index.js +0 -26
  24. package/lib/components/menu/__internal__/spec-helper/package.json +0 -6
@@ -46,11 +46,14 @@ const MenuFullscreen = ({
46
46
  const flattenedChildren = _react.default.Children.toArray(children);
47
47
  const childArray = _react.default.Children.toArray(flattenedChildren.map((child, index) => {
48
48
  if (index < flattenedChildren.length - 1) {
49
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, child, /*#__PURE__*/_react.default.createElement(_menuDivider.default, null));
49
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, child, /*#__PURE__*/_react.default.createElement(_menuDivider.default, {
50
+ "data-role": "divider"
51
+ }));
50
52
  }
51
53
  return child;
52
54
  }));
53
55
  const closeModal = (0, _react.useCallback)(ev => {
56
+ /* istanbul ignore else */
54
57
  if (onClose && _events.default.isEscKey(ev)) {
55
58
  ev.stopImmediatePropagation();
56
59
  onClose(ev);
@@ -69,10 +69,13 @@ const MenuItem = ({
69
69
  const focusRef = inputRef.current ? inputRef : ref;
70
70
  (0, _react.useEffect)(() => {
71
71
  const id = menuItemId.current;
72
+
73
+ /* istanbul ignore else */
72
74
  if (registerItem) {
73
75
  registerItem(id);
74
76
  }
75
77
  return () => {
78
+ /* istanbul ignore else */
76
79
  if (unregisterItem) {
77
80
  unregisterItem(id);
78
81
  }
@@ -174,7 +177,8 @@ const MenuItem = ({
174
177
  onClick: updateFocusOnClick,
175
178
  as: as
176
179
  }), /*#__PURE__*/_react.default.createElement(_menuItem.default, _extends({
177
- menuType: menuType
180
+ menuType: menuType,
181
+ "data-role": "menu-item-wrapper"
178
182
  }, elementProps, {
179
183
  ariaLabel: ariaLabel,
180
184
  maxWidth: maxWidth,
@@ -31,7 +31,9 @@ const MenuSegmentTitle = /*#__PURE__*/_react.default.forwardRef(({
31
31
  menuType: menuContext.menuType,
32
32
  ref: ref,
33
33
  variant: variant
34
- }), text), children && /*#__PURE__*/_react.default.createElement(_menuSegmentTitle.StyledSegmentChildren, null, children));
34
+ }), text), children && /*#__PURE__*/_react.default.createElement(_menuSegmentTitle.StyledSegmentChildren, {
35
+ "data-role": "menu-segment-children"
36
+ }, children));
35
37
  });
36
38
  if (process.env.NODE_ENV !== "production") {
37
39
  MenuSegmentTitle.propTypes = {
@@ -40,7 +40,8 @@ const ScrollableBlock = ({
40
40
  overrideColor: true,
41
41
  variant: parentVariant,
42
42
  p: "2px 16px",
43
- as: "div"
43
+ as: "div",
44
+ "data-role": "scrollable-block-parent-menu-item"
44
45
  }, parent), /*#__PURE__*/_react.default.createElement(_box.default, {
45
46
  overflowY: "scroll",
46
47
  scrollVariant: scrollVariants[menuType],
@@ -15,15 +15,6 @@ var _getColorValue = _interopRequireDefault(require("../../style/utils/get-color
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
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); }
17
17
  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; }
18
- function addStyleToPillIcon(fontSize) {
19
- return `
20
- ${_icon.default} {
21
- &:before {
22
- font-size: ${fontSize};
23
- }
24
- }
25
- `;
26
- }
27
18
  const StyledPill = _styledComponents.default.span`
28
19
  ${_styledSystem.margin}
29
20
  ${({
@@ -79,13 +70,16 @@ const StyledPill = _styledComponents.default.span`
79
70
  border-radius: var(--borderRadius025);
80
71
  `}
81
72
  height: auto;
73
+
82
74
  ${!wrapText && (0, _styledComponents.css)`
83
75
  white-space: nowrap;
84
76
  `}
77
+
85
78
  ${wrapText && (0, _styledComponents.css)`
86
79
  white-space: break-spaces;
87
80
  hyphens: auto;
88
81
  `}
82
+
89
83
  color: ${contentColor};
90
84
 
91
85
  ${inFill && (0, _styledComponents.css)`
@@ -100,13 +94,10 @@ const StyledPill = _styledComponents.default.span`
100
94
  min-height: 16px;
101
95
  line-height: 16px;
102
96
  font-size: 12px;
97
+ padding: 0 8px;
103
98
 
104
99
  ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
105
100
  border-radius: 12px;
106
-
107
- button {
108
- border-radius: 0 10px 10px 0;
109
- }
110
101
  `}
111
102
  `}
112
103
 
@@ -114,13 +105,10 @@ const StyledPill = _styledComponents.default.span`
114
105
  min-height: 20px;
115
106
  line-height: 20px;
116
107
  font-size: 14px;
108
+ padding: 0 8px;
117
109
 
118
110
  ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
119
111
  border-radius: 12px;
120
-
121
- button {
122
- border-radius: 0 10px 10px 0;
123
- }
124
112
  `}
125
113
  `}
126
114
 
@@ -128,13 +116,10 @@ const StyledPill = _styledComponents.default.span`
128
116
  min-height: 24px;
129
117
  line-height: 24px;
130
118
  font-size: 14px;
119
+ padding: 0 8px;
131
120
 
132
121
  ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
133
122
  border-radius: 13px;
134
-
135
- button {
136
- border-radius: 0 11px 11px 0;
137
- }
138
123
  `}
139
124
  `}
140
125
 
@@ -142,13 +127,10 @@ const StyledPill = _styledComponents.default.span`
142
127
  min-height: 28px;
143
128
  line-height: 28px;
144
129
  font-size: 16px;
130
+ padding: 0 12px;
145
131
 
146
132
  ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
147
133
  border-radius: 15px;
148
-
149
- button {
150
- border-radius: 0 12px 12px 0;
151
- }
152
134
  `}
153
135
  `}
154
136
 
@@ -181,12 +163,10 @@ const StyledPill = _styledComponents.default.span`
181
163
  var(--borderRadius025) var(--borderRadius000);
182
164
  `}
183
165
 
184
- & {
185
- color: ${contentColor};
186
- }
187
166
  ::-moz-focus-inner {
188
167
  border: 0;
189
168
  }
169
+
190
170
  ${_icon.default} {
191
171
  color: ${contentColor};
192
172
  }
@@ -196,6 +176,7 @@ const StyledPill = _styledComponents.default.span`
196
176
  background-color: ${buttonFocusColor};
197
177
  color: ${contentColor};
198
178
  cursor: pointer;
179
+
199
180
  ${_icon.default} {
200
181
  color: ${contentColor};
201
182
  }
@@ -206,17 +187,10 @@ const StyledPill = _styledComponents.default.span`
206
187
  width: unset;
207
188
  color: ${contentColor};
208
189
 
209
- &:hover,
210
- &:focus {
211
- color: ${contentColor};
212
- }
213
- }
214
-
215
- ${!inFill && (0, _styledComponents.css)`
216
- ${_icon.default} {
190
+ ${!inFill && (0, _styledComponents.css)`
217
191
  color: ${!isDarkBackground ? "var(--colorsUtilityYin090)" : "var(--colorsUtilityYang100)"};
218
- }
219
- `}
192
+ `}
193
+ }
220
194
  }
221
195
 
222
196
  ${size === "S" && (0, _styledComponents.css)`
@@ -225,8 +199,17 @@ const StyledPill = _styledComponents.default.span`
225
199
  button {
226
200
  padding: 0;
227
201
  line-height: 16px;
228
- top: -2px;
229
- ${addStyleToPillIcon("16px")}
202
+
203
+ ${_icon.default} {
204
+ top: -2px;
205
+ &:before {
206
+ font-size: 16px;
207
+ }
208
+ }
209
+
210
+ ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
211
+ border-radius: 0 10px 10px 0;
212
+ `}
230
213
  }
231
214
  `}
232
215
 
@@ -237,6 +220,10 @@ const StyledPill = _styledComponents.default.span`
237
220
  width: 24px;
238
221
  padding: 0;
239
222
  line-height: 15px;
223
+
224
+ ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
225
+ border-radius: 0 10px 10px 0;
226
+ `}
240
227
  }
241
228
  `}
242
229
 
@@ -247,6 +234,10 @@ const StyledPill = _styledComponents.default.span`
247
234
  width: 28px;
248
235
  padding: 0;
249
236
  line-height: 16px;
237
+
238
+ ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
239
+ border-radius: 0 11px 11px 0;
240
+ `}
250
241
  }
251
242
  `}
252
243
 
@@ -257,43 +248,10 @@ const StyledPill = _styledComponents.default.span`
257
248
  width: 32px;
258
249
  padding: 0;
259
250
  line-height: 18px;
260
- }
261
- `}
262
- `}
263
-
264
- ${!isDeletable && (0, _styledComponents.css)`
265
- ${size === "S" && (0, _styledComponents.css)`
266
- padding: 0 8px;
267
-
268
- button {
269
- padding: 0;
270
- }
271
- `}
272
251
 
273
- ${size === "M" && (0, _styledComponents.css)`
274
- padding: 0 8px;
275
-
276
- button {
277
- width: 24px;
278
- padding: 0;
279
- }
280
- `}
281
-
282
- ${size === "L" && (0, _styledComponents.css)`
283
- padding: 0 8px;
284
-
285
- button {
286
- width: 28px;
287
- padding: 0;
288
- }
289
- `}
290
-
291
- ${size === "XL" && (0, _styledComponents.css)`
292
- padding: 0 12px;
293
-
294
- button {
295
- width: 32px;
296
- padding: 0;
252
+ ${theme.roundedCornersOptOut && (0, _styledComponents.css)`
253
+ border-radius: 0 12px 12px 0;
254
+ `}
297
255
  }
298
256
  `}
299
257
  `}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "138.0.1",
3
+ "version": "138.1.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -1,3 +0,0 @@
1
- import { ReactWrapper } from "enzyme";
2
- declare const openSubmenu: (wrapper: ReactWrapper, index?: number) => void;
3
- export default openSubmenu;
@@ -1,19 +0,0 @@
1
- import { act } from "react-dom/test-utils";
2
- import StyledMenuItemWrapper from "../../menu-item/menu-item.style";
3
- import { StyledSubmenuWrapper } from "../submenu/submenu.style";
4
- const events = {
5
- space: {
6
- key: " ",
7
- preventDefault: jest.fn()
8
- }
9
- };
10
- const openSubmenu = (wrapper, index = 0) => {
11
- const menuWrapper = wrapper.find(StyledSubmenuWrapper).at(index);
12
- const menuItem = menuWrapper.exists("a") ? menuWrapper.find("a") : menuWrapper.find("button");
13
- menuItem.getDOMNode().focus();
14
- act(() => {
15
- menuWrapper.find(StyledMenuItemWrapper).props().onKeyDown(events.space);
16
- });
17
- wrapper.update();
18
- };
19
- export default openSubmenu;
@@ -1,3 +0,0 @@
1
- import { ReactWrapper } from "enzyme";
2
- declare const openSubmenu: (wrapper: ReactWrapper, index?: number) => void;
3
- export default openSubmenu;
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _testUtils = require("react-dom/test-utils");
8
- var _menuItem = _interopRequireDefault(require("../../menu-item/menu-item.style"));
9
- var _submenu = require("../submenu/submenu.style");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const events = {
12
- space: {
13
- key: " ",
14
- preventDefault: jest.fn()
15
- }
16
- };
17
- const openSubmenu = (wrapper, index = 0) => {
18
- const menuWrapper = wrapper.find(_submenu.StyledSubmenuWrapper).at(index);
19
- const menuItem = menuWrapper.exists("a") ? menuWrapper.find("a") : menuWrapper.find("button");
20
- menuItem.getDOMNode().focus();
21
- (0, _testUtils.act)(() => {
22
- menuWrapper.find(_menuItem.default).props().onKeyDown(events.space);
23
- });
24
- wrapper.update();
25
- };
26
- var _default = exports.default = openSubmenu;
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "../../../../../esm/components/menu/__internal__/spec-helper/index.js",
4
- "main": "./index.js",
5
- "types": "./index.d.ts"
6
- }