carbon-react 119.9.2 → 119.10.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 (34) hide show
  1. package/esm/components/button/button.component.js +8 -1
  2. package/esm/components/checkbox/checkbox-group.component.d.ts +4 -0
  3. package/esm/components/checkbox/checkbox-group.component.js +45 -5
  4. package/esm/components/checkbox/checkbox-group.style.d.ts +2 -0
  5. package/esm/components/checkbox/checkbox-group.style.js +18 -1
  6. package/esm/components/checkbox/checkbox.component.js +17 -13
  7. package/esm/components/multi-action-button/multi-action-button.component.js +21 -68
  8. package/esm/components/split-button/__internal__/split-button.context.d.ts +7 -0
  9. package/esm/components/split-button/__internal__/split-button.context.js +4 -0
  10. package/esm/components/split-button/split-button.component.js +20 -61
  11. package/esm/hooks/__internal__/useChildButtons/index.d.ts +1 -0
  12. package/esm/hooks/__internal__/useChildButtons/index.js +1 -0
  13. package/esm/hooks/__internal__/useChildButtons/useChildButtons.d.ts +21 -0
  14. package/esm/hooks/__internal__/useChildButtons/useChildButtons.js +71 -0
  15. package/esm/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.d.ts +1 -1
  16. package/esm/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.js +8 -7
  17. package/lib/components/button/button.component.js +8 -1
  18. package/lib/components/checkbox/checkbox-group.component.d.ts +4 -0
  19. package/lib/components/checkbox/checkbox-group.component.js +47 -5
  20. package/lib/components/checkbox/checkbox-group.style.d.ts +2 -0
  21. package/lib/components/checkbox/checkbox-group.style.js +20 -2
  22. package/lib/components/checkbox/checkbox.component.js +17 -13
  23. package/lib/components/multi-action-button/multi-action-button.component.js +20 -67
  24. package/lib/components/split-button/__internal__/split-button.context.d.ts +7 -0
  25. package/lib/components/split-button/__internal__/split-button.context.js +12 -0
  26. package/lib/components/split-button/split-button.component.js +19 -60
  27. package/lib/hooks/__internal__/useChildButtons/index.d.ts +1 -0
  28. package/lib/hooks/__internal__/useChildButtons/index.js +13 -0
  29. package/lib/hooks/__internal__/useChildButtons/package.json +6 -0
  30. package/lib/hooks/__internal__/useChildButtons/useChildButtons.d.ts +21 -0
  31. package/lib/hooks/__internal__/useChildButtons/useChildButtons.js +79 -0
  32. package/lib/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.d.ts +1 -1
  33. package/lib/hooks/__internal__/useMenuKeyboardNavigation/useMenuKeyboardNavigation.js +7 -6
  34. package/package.json +1 -1
@@ -9,8 +9,7 @@ var _events = _interopRequireDefault(require("../../../__internal__/utils/helper
9
9
  var _focusTrapUtils = require("../../../__internal__/focus-trap/focus-trap-utils");
10
10
  var _useModalManager = _interopRequireDefault(require("../useModalManager"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- var _default = (mainControlRef, childrenRefs, hide, isOpen) => {
13
- const childrenLength = (0, _react.useMemo)(() => childrenRefs.length, [childrenRefs]);
12
+ var _default = (mainControlRef, getButtonChildren, hide, isOpen) => {
14
13
  const refocusMainControl = (0, _react.useCallback)(() => {
15
14
  hide();
16
15
  mainControlRef.current?.focus();
@@ -33,8 +32,10 @@ var _default = (mainControlRef, childrenRefs, hide, isOpen) => {
33
32
  if (!(_events.default.isEnterKey(ev) || _events.default.isSpaceKey(ev))) {
34
33
  ev.preventDefault();
35
34
  }
36
- const currentIndex = childrenRefs?.findIndex(node => node.current === document.activeElement);
35
+ const buttonChildren = getButtonChildren();
36
+ const childrenLength = buttonChildren?.length;
37
37
  let nextIndex = -1;
38
+ const currentIndex = Array.from(buttonChildren).indexOf(document.activeElement);
38
39
  const arrowModifierPressed = ev.ctrlKey || ev.metaKey;
39
40
  if (_events.default.isEndKey(ev) || arrowModifierPressed && _events.default.isDownKey(ev)) {
40
41
  nextIndex = childrenLength - 1;
@@ -61,16 +62,16 @@ var _default = (mainControlRef, childrenRefs, hide, isOpen) => {
61
62
  const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
62
63
  const indexOf = elements.indexOf(mainControlRef.current);
63
64
  elements[indexOf + 1]?.focus();
64
- // // timeout enforces that the "hide" method will be run after browser focuses on the next element
65
+ // timeout enforces that the "hide" method will be run after browser focuses on the next element
65
66
  setTimeout(hide, 0);
66
67
  } else {
67
68
  nextIndex = currentIndex + 1;
68
69
  }
69
70
  }
70
71
  if (nextIndex > -1) {
71
- childrenRefs[nextIndex].current?.focus();
72
+ buttonChildren?.[nextIndex]?.focus();
72
73
  }
73
- }, [childrenLength, hide, refocusMainControl, childrenRefs, mainControlRef]);
74
+ }, [hide, refocusMainControl, mainControlRef, getButtonChildren]);
74
75
  return handleKeyDown;
75
76
  };
76
77
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "119.9.2",
3
+ "version": "119.10.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",