carbon-react 104.54.2 → 104.55.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 (33) 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/modal/__internal__/modal-manager.d.ts +2 -2
  9. package/esm/components/modal/__internal__/modal-manager.js +18 -7
  10. package/esm/components/multi-action-button/multi-action-button.component.js +8 -0
  11. package/esm/components/select/filterable-select/filterable-select.component.js +0 -2
  12. package/esm/components/select/multi-select/multi-select.component.js +0 -2
  13. package/esm/components/select/select-textbox/select-textbox.component.js +1 -1
  14. package/esm/components/select/simple-select/simple-select.component.js +0 -2
  15. package/esm/components/split-button/split-button.component.d.ts +2 -2
  16. package/esm/components/split-button/split-button.component.js +12 -4
  17. package/lib/__spec_helper__/test-utils.d.ts +1 -1
  18. package/lib/__spec_helper__/test-utils.js +16 -17
  19. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +8 -4
  20. package/lib/components/action-popover/action-popover.style.d.ts +1 -1
  21. package/lib/components/action-popover/action-popover.style.js +2 -1
  22. package/lib/components/button/button.component.d.ts +1 -1
  23. package/lib/components/button/button.component.js +13 -2
  24. package/lib/components/modal/__internal__/modal-manager.d.ts +2 -2
  25. package/lib/components/modal/__internal__/modal-manager.js +20 -8
  26. package/lib/components/multi-action-button/multi-action-button.component.js +10 -0
  27. package/lib/components/select/filterable-select/filterable-select.component.js +0 -2
  28. package/lib/components/select/multi-select/multi-select.component.js +0 -2
  29. package/lib/components/select/select-textbox/select-textbox.component.js +1 -1
  30. package/lib/components/select/simple-select/simple-select.component.js +0 -2
  31. package/lib/components/split-button/split-button.component.d.ts +2 -2
  32. package/lib/components/split-button/split-button.component.js +14 -4
  33. 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,
@@ -1,9 +1,9 @@
1
1
  export default ModalManager;
2
- declare const ModalManager: ModalManagerInstance;
3
- declare class ModalManagerInstance {
2
+ export class ModalManagerInstance {
4
3
  addModal: (modal: any, setTriggerRefocusFlag: any) => void;
5
4
  isTopmost(modal: any): boolean;
6
5
  removeModal(modal: any): void;
7
6
  clearList(): void;
8
7
  #private;
9
8
  }
9
+ declare const ModalManager: ModalManagerInstance;
@@ -6,17 +6,17 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
6
6
 
7
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
8
 
9
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
10
-
11
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
12
-
13
9
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
14
10
 
15
11
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
16
12
 
13
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
14
+
15
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
16
+
17
17
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
18
18
 
19
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
19
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
20
20
 
21
21
  var _modalList = /*#__PURE__*/new WeakMap();
22
22
 
@@ -30,7 +30,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
30
30
 
31
31
  _modalList.set(this, {
32
32
  writable: true,
33
- value: []
33
+ value: void 0
34
34
  });
35
35
 
36
36
  _defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
@@ -48,6 +48,14 @@ let ModalManagerInstance = /*#__PURE__*/function () {
48
48
  setTriggerRefocusFlag
49
49
  });
50
50
  });
51
+
52
+ // Due to possibility of multiple carbon versions using it
53
+ // it is necessary to maintain same structure in this global variable
54
+ if (!window.__CARBON_INTERNALS_MODAL_LIST) {
55
+ window.__CARBON_INTERNALS_MODAL_LIST = [];
56
+ }
57
+
58
+ _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
51
59
  }
52
60
 
53
61
  _createClass(ModalManagerInstance, [{
@@ -91,7 +99,9 @@ let ModalManagerInstance = /*#__PURE__*/function () {
91
99
  }, {
92
100
  key: "clearList",
93
101
  value: function clearList() {
94
- _classPrivateFieldSet(this, _modalList, []);
102
+ window.__CARBON_INTERNALS_MODAL_LIST = [];
103
+
104
+ _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
95
105
  }
96
106
  }]);
97
107
 
@@ -107,4 +117,5 @@ function _getTopModal2() {
107
117
  }
108
118
 
109
119
  const ModalManager = new ModalManagerInstance();
120
+ export { ModalManagerInstance };
110
121
  export default ModalManager;
@@ -9,7 +9,9 @@ import Events from "../../__internal__/utils/helpers/events";
9
9
  import Popover from "../../__internal__/popover";
10
10
  import { filterStyledSystemMarginProps } from "../../style/utils";
11
11
  import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
12
+ import Logger from "../../__internal__/utils/logger";
12
13
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
14
+ let deprecatedWarnTriggered = false;
13
15
 
14
16
  const MultiActionButton = ({
15
17
  align = "left",
@@ -22,6 +24,12 @@ const MultiActionButton = ({
22
24
  subtext,
23
25
  ...rest
24
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
+
25
33
  const ref = useRef();
26
34
  const buttonRef = useRef();
27
35
  const buttonContainer = useRef();
@@ -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;
@@ -15,13 +15,15 @@ import Popover from "../../__internal__/popover";
15
15
  import { filterStyledSystemMarginProps } from "../../style/utils";
16
16
  import { baseTheme } from "../../style/themes";
17
17
  import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
18
+ import Logger from "../../__internal__/utils/logger";
18
19
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
19
20
  const CONTENT_WIDTH_RATIO = 0.75;
21
+ let deprecatedWarnTriggered = false;
20
22
 
21
23
  const SplitButton = ({
22
24
  align = "left",
23
- as = "secondary",
24
- buttonType,
25
+ as,
26
+ buttonType = "secondary",
25
27
  children,
26
28
  disabled = false,
27
29
  iconPosition = "before",
@@ -32,6 +34,12 @@ const SplitButton = ({
32
34
  text,
33
35
  ...rest
34
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
+
35
43
  const theme = useContext(ThemeContext) || baseTheme;
36
44
  const isToggleButtonFocused = useRef(false);
37
45
  const buttonLabelId = useRef(guid());
@@ -120,7 +128,7 @@ const SplitButton = ({
120
128
  isToggleButtonFocused.current = false;
121
129
  },
122
130
  onKeyDown: handleToggleButtonKeyDown,
123
- buttonType: buttonType || as,
131
+ buttonType: as || buttonType,
124
132
  size
125
133
  };
126
134
 
@@ -149,7 +157,7 @@ const SplitButton = ({
149
157
  primary: theme.colors.white,
150
158
  secondary: theme.colors.primary
151
159
  };
152
- return colorsMap[buttonType || as];
160
+ return colorsMap[as || buttonType];
153
161
  }
154
162
 
155
163
  function renderMainButton() {
@@ -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,
@@ -1,9 +1,9 @@
1
1
  export default ModalManager;
2
- declare const ModalManager: ModalManagerInstance;
3
- declare class ModalManagerInstance {
2
+ export class ModalManagerInstance {
4
3
  addModal: (modal: any, setTriggerRefocusFlag: any) => void;
5
4
  isTopmost(modal: any): boolean;
6
5
  removeModal(modal: any): void;
7
6
  clearList(): void;
8
7
  #private;
9
8
  }
9
+ declare const ModalManager: ModalManagerInstance;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.ModalManagerInstance = void 0;
7
7
 
8
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
9
 
@@ -13,17 +13,17 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
13
13
 
14
14
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
15
 
16
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
17
-
18
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
19
-
20
16
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
21
17
 
22
18
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
23
19
 
20
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
21
+
22
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
23
+
24
24
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
25
25
 
26
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
26
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
27
27
 
28
28
  var _modalList = /*#__PURE__*/new WeakMap();
29
29
 
@@ -37,7 +37,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
37
37
 
38
38
  _modalList.set(this, {
39
39
  writable: true,
40
- value: []
40
+ value: void 0
41
41
  });
42
42
 
43
43
  _defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
@@ -55,6 +55,14 @@ let ModalManagerInstance = /*#__PURE__*/function () {
55
55
  setTriggerRefocusFlag
56
56
  });
57
57
  });
58
+
59
+ // Due to possibility of multiple carbon versions using it
60
+ // it is necessary to maintain same structure in this global variable
61
+ if (!window.__CARBON_INTERNALS_MODAL_LIST) {
62
+ window.__CARBON_INTERNALS_MODAL_LIST = [];
63
+ }
64
+
65
+ _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
58
66
  }
59
67
 
60
68
  _createClass(ModalManagerInstance, [{
@@ -98,13 +106,17 @@ let ModalManagerInstance = /*#__PURE__*/function () {
98
106
  }, {
99
107
  key: "clearList",
100
108
  value: function clearList() {
101
- _classPrivateFieldSet(this, _modalList, []);
109
+ window.__CARBON_INTERNALS_MODAL_LIST = [];
110
+
111
+ _classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
102
112
  }
103
113
  }]);
104
114
 
105
115
  return ModalManagerInstance;
106
116
  }();
107
117
 
118
+ exports.ModalManagerInstance = ModalManagerInstance;
119
+
108
120
  function _getTopModal2() {
109
121
  if (!_classPrivateFieldGet(this, _modalList).length) {
110
122
  return {};
@@ -23,6 +23,8 @@ var _utils = require("../../style/utils");
23
23
 
24
24
  var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
25
25
 
26
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
27
+
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -32,6 +34,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
32
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); }
33
35
 
34
36
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
37
+ let deprecatedWarnTriggered = false;
35
38
 
36
39
  const MultiActionButton = ({
37
40
  align = "left",
@@ -44,6 +47,13 @@ const MultiActionButton = ({
44
47
  subtext,
45
48
  ...rest
46
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
+
47
57
  const ref = (0, _react.useRef)();
48
58
  const buttonRef = (0, _react.useRef)();
49
59
  const buttonContainer = (0, _react.useRef)();
@@ -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;
@@ -35,6 +35,8 @@ var _themes = require("../../style/themes");
35
35
 
36
36
  var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
37
37
 
38
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
39
+
38
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
41
 
40
42
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -45,11 +47,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
45
47
 
46
48
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
47
49
  const CONTENT_WIDTH_RATIO = 0.75;
50
+ let deprecatedWarnTriggered = false;
48
51
 
49
52
  const SplitButton = ({
50
53
  align = "left",
51
- as = "secondary",
52
- buttonType,
54
+ as,
55
+ buttonType = "secondary",
53
56
  children,
54
57
  disabled = false,
55
58
  iconPosition = "before",
@@ -60,6 +63,13 @@ const SplitButton = ({
60
63
  text,
61
64
  ...rest
62
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
+
63
73
  const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
64
74
 
65
75
  const isToggleButtonFocused = (0, _react.useRef)(false);
@@ -149,7 +159,7 @@ const SplitButton = ({
149
159
  isToggleButtonFocused.current = false;
150
160
  },
151
161
  onKeyDown: handleToggleButtonKeyDown,
152
- buttonType: buttonType || as,
162
+ buttonType: as || buttonType,
153
163
  size
154
164
  };
155
165
 
@@ -178,7 +188,7 @@ const SplitButton = ({
178
188
  primary: theme.colors.white,
179
189
  secondary: theme.colors.primary
180
190
  };
181
- return colorsMap[buttonType || as];
191
+ return colorsMap[as || buttonType];
182
192
  }
183
193
 
184
194
  function renderMainButton() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.54.2",
3
+ "version": "104.55.0",
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",