carbon-react 104.54.1 → 104.54.4

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 (29) hide show
  1. package/esm/__spec_helper__/test-utils.d.ts +1 -1
  2. package/esm/__spec_helper__/test-utils.js +15 -16
  3. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +8 -4
  4. package/esm/components/action-popover/action-popover.style.d.ts +1 -1
  5. package/esm/components/action-popover/action-popover.style.js +2 -1
  6. package/esm/components/button/button.component.d.ts +1 -1
  7. package/esm/components/button/button.component.js +11 -2
  8. package/esm/components/multi-action-button/multi-action-button.component.js +17 -1
  9. package/esm/components/select/filterable-select/filterable-select.component.js +0 -2
  10. package/esm/components/select/multi-select/multi-select.component.js +0 -2
  11. package/esm/components/select/select-textbox/select-textbox.component.js +1 -1
  12. package/esm/components/select/simple-select/simple-select.component.js +0 -2
  13. package/esm/components/split-button/split-button.component.d.ts +2 -2
  14. package/esm/components/split-button/split-button.component.js +22 -6
  15. package/lib/__spec_helper__/test-utils.d.ts +1 -1
  16. package/lib/__spec_helper__/test-utils.js +16 -17
  17. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +8 -4
  18. package/lib/components/action-popover/action-popover.style.d.ts +1 -1
  19. package/lib/components/action-popover/action-popover.style.js +2 -1
  20. package/lib/components/button/button.component.d.ts +1 -1
  21. package/lib/components/button/button.component.js +13 -2
  22. package/lib/components/multi-action-button/multi-action-button.component.js +20 -1
  23. package/lib/components/select/filterable-select/filterable-select.component.js +0 -2
  24. package/lib/components/select/multi-select/multi-select.component.js +0 -2
  25. package/lib/components/select/select-textbox/select-textbox.component.js +1 -1
  26. package/lib/components/select/simple-select/simple-select.component.js +0 -2
  27. package/lib/components/split-button/split-button.component.d.ts +2 -2
  28. package/lib/components/split-button/split-button.component.js +25 -6
  29. package/package.json +5 -5
@@ -29,6 +29,6 @@ export function testStyledSystemWidth(component: any, styleContainer: any): void
29
29
  export function testStyledSystemLayout(component: any, styleContainer: any): void;
30
30
  export function testStyledSystemFlexBox(component: any, styleContainer: any): void;
31
31
  export function testStyledSystemBackground(component: any, styleContainer: any): void;
32
- export function expectError(errorMessage: any): () => void;
32
+ export function expectConsoleOutput(message: any, type?: string): () => void;
33
33
  declare const keydown: {};
34
34
  export { mockMatchMedia };
@@ -317,38 +317,37 @@ const testStyledSystemBackground = (component, styleContainer) => {
317
317
  }, styleContainer ? styleContainer(wrapper) : wrapper));
318
318
  });
319
319
  });
320
- };
320
+ }; // this util will catch that a console output occurred without polluting the output when running the unit tests
321
+
321
322
 
322
- const expectError = errorMessage => {
323
- if (!errorMessage) {
324
- throw new Error("no error message provided");
323
+ const expectConsoleOutput = (message, type = "error") => {
324
+ if (!message) {
325
+ throw new Error(`no ${type} message provided`);
325
326
  }
326
327
 
327
328
  expect.assertions(1);
328
- const {
329
- error
330
- } = global.console;
331
- let errorArgs;
332
- jest.spyOn(global.console, "error").mockImplementation((...args) => {
329
+ const consoleType = global.console[type];
330
+ let consoleArgs;
331
+ jest.spyOn(global.console, type).mockImplementation((...args) => {
333
332
  if (!args.length) return;
334
333
  const msg = args.join(" ");
335
334
  const params = args.slice(1, args.length);
336
335
 
337
- if (sprintf(msg, ...params).includes(errorMessage)) {
338
- errorArgs = args;
336
+ if (sprintf(msg, ...params).includes(message)) {
337
+ consoleArgs = args;
339
338
  return;
340
339
  }
341
340
 
342
- error(...args);
341
+ consoleType(...args);
343
342
  });
344
343
  return () => {
345
- if (errorArgs) {
344
+ if (consoleArgs) {
346
345
  // eslint-disable-next-line no-console
347
- expect(console.error).toHaveBeenCalledWith(...errorArgs);
346
+ expect(console[type]).toHaveBeenCalledWith(...consoleArgs);
348
347
  }
349
348
 
350
- global.console.error = error;
349
+ global.console[type] = consoleType;
351
350
  };
352
351
  };
353
352
 
354
- export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectError };
353
+ export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectConsoleOutput };
@@ -79,12 +79,12 @@ const MenuItem = ({
79
79
  e.stopPropagation();
80
80
 
81
81
  if (!disabled) {
82
+ setOpenPopover(false);
83
+ focusButton();
84
+
82
85
  if (onClickProp) {
83
86
  onClickProp();
84
87
  }
85
-
86
- setOpenPopover(false);
87
- focusButton();
88
88
  } else {
89
89
  ref.current.focus();
90
90
  e.preventDefault();
@@ -128,7 +128,11 @@ const MenuItem = ({
128
128
 
129
129
  e.preventDefault();
130
130
  } else if (Events.isEnterKey(e)) {
131
- if (isHref && download) ref.current.click();
131
+ if (isHref && download) {
132
+ ref.current.click();
133
+ }
134
+
135
+ e.preventDefault();
132
136
  onClick(e);
133
137
  }
134
138
  } else if (Events.isEnterKey(e)) {
@@ -9,5 +9,5 @@ export const MenuItemDivider: import("styled-components").StyledComponent<"div",
9
9
  }, "data-element">;
10
10
  export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
11
11
  export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export const StyledMenuItem: import("styled-components").StyledComponent<"div", any, {}, never>;
12
+ export const StyledMenuItem: import("styled-components").StyledComponent<"button", any, {}, never>;
13
13
  import Icon from "../icon";
@@ -17,8 +17,9 @@ const Menu = styled.div`
17
17
  theme
18
18
  }) => `${theme.zIndex.popover}`}; // TODO (tokens): implement elevation tokens - FE-4437
19
19
  `;
20
- const StyledMenuItem = styled.div`
20
+ const StyledMenuItem = styled.button`
21
21
  text-decoration: none;
22
+ background-color: var(--colorsActionMajorYang100);
22
23
  `;
23
24
 
24
25
  const MenuItemFactory = button => styled(button)`
@@ -24,7 +24,7 @@ declare function Button({ size, subtext, as, children, forwardRef, "aria-label":
24
24
  declare namespace Button {
25
25
  const propTypes: any;
26
26
  namespace defaultProps {
27
- const as: string;
27
+ const buttonType: string;
28
28
  const size: string;
29
29
  const fullWidth: boolean;
30
30
  const disabled: boolean;
@@ -7,6 +7,7 @@ import Icon from "../icon";
7
7
  import StyledButton, { StyledButtonSubtext } from "./button.style";
8
8
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
9
9
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
10
+ import Logger from "../../__internal__/utils/logger";
10
11
 
11
12
  function renderChildren({
12
13
  /* eslint-disable react/prop-types */
@@ -51,6 +52,8 @@ function renderChildren({
51
52
  }))), iconType && iconPosition === "after" && children && /*#__PURE__*/React.createElement(Icon, iconProps));
52
53
  }
53
54
 
55
+ let deprecatedWarnTriggered = false;
56
+
54
57
  const Button = ({
55
58
  size,
56
59
  subtext,
@@ -72,8 +75,14 @@ const Button = ({
72
75
  iconTooltipPosition,
73
76
  ...rest
74
77
  }) => {
78
+ if (!deprecatedWarnTriggered && as) {
79
+ deprecatedWarnTriggered = true;
80
+ Logger.deprecate( // eslint-disable-next-line max-len
81
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
82
+ }
83
+
75
84
  const [internalRef, setInternalRef] = useState(null);
76
- const buttonType = buttonTypeProp || as;
85
+ const buttonType = as || buttonTypeProp;
77
86
 
78
87
  if (subtext.length > 0 && size !== "large") {
79
88
  throw new Error("subtext prop has no effect unless the button is large");
@@ -237,7 +246,7 @@ Button.propTypes = {
237
246
  rel: PropTypes.string
238
247
  };
239
248
  Button.defaultProps = {
240
- as: "secondary",
249
+ buttonType: "secondary",
241
250
  size: "medium",
242
251
  fullWidth: false,
243
252
  disabled: false,
@@ -8,7 +8,10 @@ import Button, { ButtonWithForwardRef } from "../button";
8
8
  import Events from "../../__internal__/utils/helpers/events";
9
9
  import Popover from "../../__internal__/popover";
10
10
  import { filterStyledSystemMarginProps } from "../../style/utils";
11
+ import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
12
+ import Logger from "../../__internal__/utils/logger";
11
13
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
14
+ let deprecatedWarnTriggered = false;
12
15
 
13
16
  const MultiActionButton = ({
14
17
  align = "left",
@@ -21,7 +24,14 @@ const MultiActionButton = ({
21
24
  subtext,
22
25
  ...rest
23
26
  }) => {
27
+ if (!deprecatedWarnTriggered && as) {
28
+ deprecatedWarnTriggered = true;
29
+ Logger.deprecate( // eslint-disable-next-line max-len
30
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
31
+ }
32
+
24
33
  const ref = useRef();
34
+ const buttonRef = useRef();
25
35
  const buttonContainer = useRef();
26
36
  const userInputType = "ontouchstart" in document.documentElement ? "touchstart" : "click";
27
37
  const buttonChildren = React.Children.toArray(children);
@@ -74,7 +84,12 @@ const MultiActionButton = ({
74
84
  nextIndex = currentIndex < children.length - 1 ? currentIndex + 1 : 0;
75
85
  ev.preventDefault();
76
86
  } else if (Events.isTabKey(ev)) {
77
- // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
87
+ var _elements$indexOf;
88
+
89
+ const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
90
+ const indexOf = elements.indexOf(buttonRef.current);
91
+ (_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
92
+
78
93
  setTimeout(hideButtons, 0);
79
94
  }
80
95
 
@@ -182,6 +197,7 @@ const MultiActionButton = ({
182
197
  key: "toggle-button",
183
198
  onKeyDown: handleMainButtonKeyDown
184
199
  }, mainButtonProps(), {
200
+ forwardRef: buttonRef,
185
201
  iconPosition: "after",
186
202
  iconType: "dropdown"
187
203
  }), text), showAdditionalButtons && renderAdditionalButtons());
@@ -414,8 +414,6 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
414
414
  flipEnabled: flipEnabled
415
415
  }, children);
416
416
  return /*#__PURE__*/React.createElement(StyledSelect, _extends({
417
- "aria-expanded": isOpen,
418
- "aria-haspopup": "listbox",
419
417
  ref: containerRef,
420
418
  hasTextCursor: true,
421
419
  readOnly: readOnly,
@@ -427,8 +427,6 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
427
427
  multiselectValues: selectedValue
428
428
  }, children);
429
429
  return /*#__PURE__*/React.createElement(StyledSelectMultiSelect, _extends({
430
- "aria-expanded": isOpen,
431
- "aria-haspopup": "listbox",
432
430
  disabled: disabled,
433
431
  readOnly: readOnly,
434
432
  hasTextCursor: true,
@@ -137,7 +137,7 @@ const SelectTextbox = ({
137
137
 
138
138
  const ariaLabelledby = hasTextCursor ? joinIds(labelId, accessibilityLabelId) : joinIds(labelId, textId.current);
139
139
  return {
140
- "aria-expanded": isOpen,
140
+ "aria-expanded": readOnly ? undefined : isOpen,
141
141
  "aria-labelledby": ariaLabelledby || undefined,
142
142
  "aria-activedescendant": activeDescendantId,
143
143
  "aria-controls": ariaControls,
@@ -340,8 +340,6 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
340
340
  transparent: transparent,
341
341
  disabled: disabled,
342
342
  readOnly: readOnly,
343
- "aria-expanded": isOpen,
344
- "aria-haspopup": "listbox",
345
343
  "data-component": dataComponent,
346
344
  "data-role": dataRole,
347
345
  "data-element": dataElement,
@@ -2,8 +2,8 @@ export default SplitButton;
2
2
  declare function SplitButton({ align, as, buttonType, children, disabled, iconPosition, iconType, onClick, size, subtext, text, ...rest }: {
3
3
  [x: string]: any;
4
4
  align?: string | undefined;
5
- as?: string | undefined;
6
- buttonType: any;
5
+ as: any;
6
+ buttonType?: string | undefined;
7
7
  children: any;
8
8
  disabled?: boolean | undefined;
9
9
  iconPosition?: string | undefined;
@@ -14,13 +14,16 @@ import guid from "../../__internal__/utils/helpers/guid";
14
14
  import Popover from "../../__internal__/popover";
15
15
  import { filterStyledSystemMarginProps } from "../../style/utils";
16
16
  import { baseTheme } from "../../style/themes";
17
+ import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
18
+ import Logger from "../../__internal__/utils/logger";
17
19
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
18
20
  const CONTENT_WIDTH_RATIO = 0.75;
21
+ let deprecatedWarnTriggered = false;
19
22
 
20
23
  const SplitButton = ({
21
24
  align = "left",
22
- as = "secondary",
23
- buttonType,
25
+ as,
26
+ buttonType = "secondary",
24
27
  children,
25
28
  disabled = false,
26
29
  iconPosition = "before",
@@ -31,11 +34,18 @@ const SplitButton = ({
31
34
  text,
32
35
  ...rest
33
36
  }) => {
37
+ if (!deprecatedWarnTriggered && as) {
38
+ deprecatedWarnTriggered = true;
39
+ Logger.deprecate( // eslint-disable-next-line max-len
40
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
41
+ }
42
+
34
43
  const theme = useContext(ThemeContext) || baseTheme;
35
44
  const isToggleButtonFocused = useRef(false);
36
45
  const buttonLabelId = useRef(guid());
37
46
  const additionalButtons = useRef([]);
38
47
  const splitButtonNode = useRef();
48
+ const toggleButton = useRef();
39
49
  const buttonContainer = useRef();
40
50
  const [showAdditionalButtons, setShowAdditionalButtons] = useState(false);
41
51
  const [minWidth, setMinWidth] = useState(0);
@@ -69,7 +79,12 @@ const SplitButton = ({
69
79
  nextIndex = currentIndex < numOfChildren ? currentIndex + 1 : 0;
70
80
  ev.preventDefault();
71
81
  } else if (Events.isTabKey(ev)) {
72
- // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
82
+ var _elements$indexOf;
83
+
84
+ const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
85
+ const indexOf = elements.indexOf(toggleButton.current);
86
+ (_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
87
+
73
88
  setTimeout(hideButtons, 0);
74
89
  }
75
90
 
@@ -113,7 +128,7 @@ const SplitButton = ({
113
128
  isToggleButtonFocused.current = false;
114
129
  },
115
130
  onKeyDown: handleToggleButtonKeyDown,
116
- buttonType: buttonType || as,
131
+ buttonType: as || buttonType,
117
132
  size
118
133
  };
119
134
 
@@ -142,7 +157,7 @@ const SplitButton = ({
142
157
  primary: theme.colors.white,
143
158
  secondary: theme.colors.primary
144
159
  };
145
- return colorsMap[buttonType || as];
160
+ return colorsMap[as || buttonType];
146
161
  }
147
162
 
148
163
  function renderMainButton() {
@@ -156,7 +171,8 @@ const SplitButton = ({
156
171
  "aria-label": "Show more",
157
172
  "data-element": "toggle-button",
158
173
  key: "toggle-button",
159
- type: "button"
174
+ type: "button",
175
+ ref: toggleButton
160
176
  }, toggleButtonProps()), /*#__PURE__*/React.createElement(Icon, {
161
177
  type: "dropdown",
162
178
  bgSize: "extra-small",
@@ -29,6 +29,6 @@ export function testStyledSystemWidth(component: any, styleContainer: any): void
29
29
  export function testStyledSystemLayout(component: any, styleContainer: any): void;
30
30
  export function testStyledSystemFlexBox(component: any, styleContainer: any): void;
31
31
  export function testStyledSystemBackground(component: any, styleContainer: any): void;
32
- export function expectError(errorMessage: any): () => void;
32
+ export function expectConsoleOutput(message: any, type?: string): () => void;
33
33
  declare const keydown: {};
34
34
  export { mockMatchMedia };
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
9
9
  return _mockMatchMedia.mockMatchMedia;
10
10
  }
11
11
  });
12
- exports.expectError = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
12
+ exports.expectConsoleOutput = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
13
13
 
14
14
  var _enzyme = require("enzyme");
15
15
 
@@ -373,40 +373,39 @@ const testStyledSystemBackground = (component, styleContainer) => {
373
373
  }, styleContainer ? styleContainer(wrapper) : wrapper));
374
374
  });
375
375
  });
376
- };
376
+ }; // this util will catch that a console output occurred without polluting the output when running the unit tests
377
+
377
378
 
378
379
  exports.testStyledSystemBackground = testStyledSystemBackground;
379
380
 
380
- const expectError = errorMessage => {
381
- if (!errorMessage) {
382
- throw new Error("no error message provided");
381
+ const expectConsoleOutput = (message, type = "error") => {
382
+ if (!message) {
383
+ throw new Error(`no ${type} message provided`);
383
384
  }
384
385
 
385
386
  expect.assertions(1);
386
- const {
387
- error
388
- } = global.console;
389
- let errorArgs;
390
- jest.spyOn(global.console, "error").mockImplementation((...args) => {
387
+ const consoleType = global.console[type];
388
+ let consoleArgs;
389
+ jest.spyOn(global.console, type).mockImplementation((...args) => {
391
390
  if (!args.length) return;
392
391
  const msg = args.join(" ");
393
392
  const params = args.slice(1, args.length);
394
393
 
395
- if ((0, _sprintfJs.sprintf)(msg, ...params).includes(errorMessage)) {
396
- errorArgs = args;
394
+ if ((0, _sprintfJs.sprintf)(msg, ...params).includes(message)) {
395
+ consoleArgs = args;
397
396
  return;
398
397
  }
399
398
 
400
- error(...args);
399
+ consoleType(...args);
401
400
  });
402
401
  return () => {
403
- if (errorArgs) {
402
+ if (consoleArgs) {
404
403
  // eslint-disable-next-line no-console
405
- expect(console.error).toHaveBeenCalledWith(...errorArgs);
404
+ expect(console[type]).toHaveBeenCalledWith(...consoleArgs);
406
405
  }
407
406
 
408
- global.console.error = error;
407
+ global.console[type] = consoleType;
409
408
  };
410
409
  };
411
410
 
412
- exports.expectError = expectError;
411
+ exports.expectConsoleOutput = expectConsoleOutput;
@@ -100,12 +100,12 @@ const MenuItem = ({
100
100
  e.stopPropagation();
101
101
 
102
102
  if (!disabled) {
103
+ setOpenPopover(false);
104
+ focusButton();
105
+
103
106
  if (onClickProp) {
104
107
  onClickProp();
105
108
  }
106
-
107
- setOpenPopover(false);
108
- focusButton();
109
109
  } else {
110
110
  ref.current.focus();
111
111
  e.preventDefault();
@@ -149,7 +149,11 @@ const MenuItem = ({
149
149
 
150
150
  e.preventDefault();
151
151
  } else if (_events.default.isEnterKey(e)) {
152
- if (isHref && download) ref.current.click();
152
+ if (isHref && download) {
153
+ ref.current.click();
154
+ }
155
+
156
+ e.preventDefault();
153
157
  onClick(e);
154
158
  }
155
159
  } else if (_events.default.isEnterKey(e)) {
@@ -9,5 +9,5 @@ export const MenuItemDivider: import("styled-components").StyledComponent<"div",
9
9
  }, "data-element">;
10
10
  export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
11
11
  export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export const StyledMenuItem: import("styled-components").StyledComponent<"div", any, {}, never>;
12
+ export const StyledMenuItem: import("styled-components").StyledComponent<"button", any, {}, never>;
13
13
  import Icon from "../icon";
@@ -37,8 +37,9 @@ const Menu = _styledComponents.default.div`
37
37
  }) => `${theme.zIndex.popover}`}; // TODO (tokens): implement elevation tokens - FE-4437
38
38
  `;
39
39
  exports.Menu = Menu;
40
- const StyledMenuItem = _styledComponents.default.div`
40
+ const StyledMenuItem = _styledComponents.default.button`
41
41
  text-decoration: none;
42
+ background-color: var(--colorsActionMajorYang100);
42
43
  `;
43
44
  exports.StyledMenuItem = StyledMenuItem;
44
45
 
@@ -24,7 +24,7 @@ declare function Button({ size, subtext, as, children, forwardRef, "aria-label":
24
24
  declare namespace Button {
25
25
  const propTypes: any;
26
26
  namespace defaultProps {
27
- const as: string;
27
+ const buttonType: string;
28
28
  const size: string;
29
29
  const fullWidth: boolean;
30
30
  const disabled: boolean;
@@ -19,6 +19,8 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
19
19
 
20
20
  var _tooltipProvider = require("../../__internal__/tooltip-provider");
21
21
 
22
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -70,6 +72,8 @@ function renderChildren({
70
72
  }))), iconType && iconPosition === "after" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps));
71
73
  }
72
74
 
75
+ let deprecatedWarnTriggered = false;
76
+
73
77
  const Button = ({
74
78
  size,
75
79
  subtext,
@@ -91,8 +95,15 @@ const Button = ({
91
95
  iconTooltipPosition,
92
96
  ...rest
93
97
  }) => {
98
+ if (!deprecatedWarnTriggered && as) {
99
+ deprecatedWarnTriggered = true;
100
+
101
+ _logger.default.deprecate( // eslint-disable-next-line max-len
102
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
103
+ }
104
+
94
105
  const [internalRef, setInternalRef] = (0, _react.useState)(null);
95
- const buttonType = buttonTypeProp || as;
106
+ const buttonType = as || buttonTypeProp;
96
107
 
97
108
  if (subtext.length > 0 && size !== "large") {
98
109
  throw new Error("subtext prop has no effect unless the button is large");
@@ -256,7 +267,7 @@ Button.propTypes = {
256
267
  rel: _propTypes.default.string
257
268
  };
258
269
  Button.defaultProps = {
259
- as: "secondary",
270
+ buttonType: "secondary",
260
271
  size: "medium",
261
272
  fullWidth: false,
262
273
  disabled: false,
@@ -21,6 +21,10 @@ var _popover = _interopRequireDefault(require("../../__internal__/popover"));
21
21
 
22
22
  var _utils = require("../../style/utils");
23
23
 
24
+ var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
25
+
26
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
27
+
24
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
29
 
26
30
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -30,6 +34,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
30
34
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
35
 
32
36
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
37
+ let deprecatedWarnTriggered = false;
33
38
 
34
39
  const MultiActionButton = ({
35
40
  align = "left",
@@ -42,7 +47,15 @@ const MultiActionButton = ({
42
47
  subtext,
43
48
  ...rest
44
49
  }) => {
50
+ if (!deprecatedWarnTriggered && as) {
51
+ deprecatedWarnTriggered = true;
52
+
53
+ _logger.default.deprecate( // eslint-disable-next-line max-len
54
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
55
+ }
56
+
45
57
  const ref = (0, _react.useRef)();
58
+ const buttonRef = (0, _react.useRef)();
46
59
  const buttonContainer = (0, _react.useRef)();
47
60
  const userInputType = "ontouchstart" in document.documentElement ? "touchstart" : "click";
48
61
 
@@ -97,7 +110,12 @@ const MultiActionButton = ({
97
110
  nextIndex = currentIndex < children.length - 1 ? currentIndex + 1 : 0;
98
111
  ev.preventDefault();
99
112
  } else if (_events.default.isTabKey(ev)) {
100
- // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
113
+ var _elements$indexOf;
114
+
115
+ const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
116
+ const indexOf = elements.indexOf(buttonRef.current);
117
+ (_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
118
+
101
119
  setTimeout(hideButtons, 0);
102
120
  }
103
121
 
@@ -205,6 +223,7 @@ const MultiActionButton = ({
205
223
  key: "toggle-button",
206
224
  onKeyDown: handleMainButtonKeyDown
207
225
  }, mainButtonProps(), {
226
+ forwardRef: buttonRef,
208
227
  iconPosition: "after",
209
228
  iconType: "dropdown"
210
229
  }), text), showAdditionalButtons && renderAdditionalButtons());
@@ -439,8 +439,6 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
439
439
  }, children);
440
440
 
441
441
  return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
442
- "aria-expanded": isOpen,
443
- "aria-haspopup": "listbox",
444
442
  ref: containerRef,
445
443
  hasTextCursor: true,
446
444
  readOnly: readOnly,
@@ -455,8 +455,6 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
455
455
  }, children);
456
456
 
457
457
  return /*#__PURE__*/_react.default.createElement(_multiSelect.StyledSelectMultiSelect, _extends({
458
- "aria-expanded": isOpen,
459
- "aria-haspopup": "listbox",
460
458
  disabled: disabled,
461
459
  readOnly: readOnly,
462
460
  hasTextCursor: true,
@@ -158,7 +158,7 @@ const SelectTextbox = ({
158
158
 
159
159
  const ariaLabelledby = hasTextCursor ? joinIds(labelId, accessibilityLabelId) : joinIds(labelId, textId.current);
160
160
  return {
161
- "aria-expanded": isOpen,
161
+ "aria-expanded": readOnly ? undefined : isOpen,
162
162
  "aria-labelledby": ariaLabelledby || undefined,
163
163
  "aria-activedescendant": activeDescendantId,
164
164
  "aria-controls": ariaControls,
@@ -365,8 +365,6 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
365
365
  transparent: transparent,
366
366
  disabled: disabled,
367
367
  readOnly: readOnly,
368
- "aria-expanded": isOpen,
369
- "aria-haspopup": "listbox",
370
368
  "data-component": dataComponent,
371
369
  "data-role": dataRole,
372
370
  "data-element": dataElement,
@@ -2,8 +2,8 @@ export default SplitButton;
2
2
  declare function SplitButton({ align, as, buttonType, children, disabled, iconPosition, iconType, onClick, size, subtext, text, ...rest }: {
3
3
  [x: string]: any;
4
4
  align?: string | undefined;
5
- as?: string | undefined;
6
- buttonType: any;
5
+ as: any;
6
+ buttonType?: string | undefined;
7
7
  children: any;
8
8
  disabled?: boolean | undefined;
9
9
  iconPosition?: string | undefined;
@@ -33,6 +33,10 @@ var _utils = require("../../style/utils");
33
33
 
34
34
  var _themes = require("../../style/themes");
35
35
 
36
+ var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
37
+
38
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
39
+
36
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
41
 
38
42
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -43,11 +47,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
43
47
 
44
48
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
45
49
  const CONTENT_WIDTH_RATIO = 0.75;
50
+ let deprecatedWarnTriggered = false;
46
51
 
47
52
  const SplitButton = ({
48
53
  align = "left",
49
- as = "secondary",
50
- buttonType,
54
+ as,
55
+ buttonType = "secondary",
51
56
  children,
52
57
  disabled = false,
53
58
  iconPosition = "before",
@@ -58,12 +63,20 @@ const SplitButton = ({
58
63
  text,
59
64
  ...rest
60
65
  }) => {
66
+ if (!deprecatedWarnTriggered && as) {
67
+ deprecatedWarnTriggered = true;
68
+
69
+ _logger.default.deprecate( // eslint-disable-next-line max-len
70
+ "The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
71
+ }
72
+
61
73
  const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
62
74
 
63
75
  const isToggleButtonFocused = (0, _react.useRef)(false);
64
76
  const buttonLabelId = (0, _react.useRef)((0, _guid.default)());
65
77
  const additionalButtons = (0, _react.useRef)([]);
66
78
  const splitButtonNode = (0, _react.useRef)();
79
+ const toggleButton = (0, _react.useRef)();
67
80
  const buttonContainer = (0, _react.useRef)();
68
81
  const [showAdditionalButtons, setShowAdditionalButtons] = (0, _react.useState)(false);
69
82
  const [minWidth, setMinWidth] = (0, _react.useState)(0);
@@ -97,7 +110,12 @@ const SplitButton = ({
97
110
  nextIndex = currentIndex < numOfChildren ? currentIndex + 1 : 0;
98
111
  ev.preventDefault();
99
112
  } else if (_events.default.isTabKey(ev)) {
100
- // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
113
+ var _elements$indexOf;
114
+
115
+ const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
116
+ const indexOf = elements.indexOf(toggleButton.current);
117
+ (_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
118
+
101
119
  setTimeout(hideButtons, 0);
102
120
  }
103
121
 
@@ -141,7 +159,7 @@ const SplitButton = ({
141
159
  isToggleButtonFocused.current = false;
142
160
  },
143
161
  onKeyDown: handleToggleButtonKeyDown,
144
- buttonType: buttonType || as,
162
+ buttonType: as || buttonType,
145
163
  size
146
164
  };
147
165
 
@@ -170,7 +188,7 @@ const SplitButton = ({
170
188
  primary: theme.colors.white,
171
189
  secondary: theme.colors.primary
172
190
  };
173
- return colorsMap[buttonType || as];
191
+ return colorsMap[as || buttonType];
174
192
  }
175
193
 
176
194
  function renderMainButton() {
@@ -184,7 +202,8 @@ const SplitButton = ({
184
202
  "aria-label": "Show more",
185
203
  "data-element": "toggle-button",
186
204
  key: "toggle-button",
187
- type: "button"
205
+ type: "button",
206
+ ref: toggleButton
188
207
  }, toggleButtonProps()), /*#__PURE__*/_react.default.createElement(_icon.default, {
189
208
  type: "dropdown",
190
209
  bgSize: "extra-small",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.54.1",
3
+ "version": "104.54.4",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -104,12 +104,12 @@
104
104
  "conventional-changelog-conventionalcommits": "^4.5.0",
105
105
  "core-js": "^3.20.3",
106
106
  "cross-env": "^5.2.0",
107
- "cypress": "^9.2.0",
108
- "cypress-axe": "^0.13.0",
107
+ "cypress": "^9.5.2",
108
+ "cypress-axe": "^0.14.0",
109
109
  "cypress-cucumber-preprocessor": "^4.3.1",
110
- "cypress-each": "^1.10.0",
110
+ "cypress-each": "^1.11.0",
111
111
  "cypress-plugin-tab": "^1.0.5",
112
- "cypress-real-events": "^1.6.0",
112
+ "cypress-real-events": "^1.7.0",
113
113
  "cypress-storybook": "^0.5.1",
114
114
  "cz-conventional-changelog": "^3.3.0",
115
115
  "date-fns-tz": "^1.2.2",