carbon-react 110.2.4 → 110.4.1

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 (101) hide show
  1. package/esm/__internal__/i18n-context/index.d.ts +2 -1
  2. package/esm/__internal__/popover/popover.component.d.ts +2 -1
  3. package/esm/__internal__/popover/popover.component.js +15 -4
  4. package/esm/__internal__/popover/popover.style.d.ts +6 -2
  5. package/esm/__internal__/popover/popover.style.js +6 -2
  6. package/esm/__internal__/radio-button-mapper/index.d.ts +2 -0
  7. package/esm/__internal__/radio-button-mapper/index.js +1 -0
  8. package/esm/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
  9. package/esm/__internal__/sticky-footer/index.d.ts +1 -0
  10. package/esm/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
  11. package/esm/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
  12. package/esm/__internal__/utils/helpers/tags/index.d.ts +1 -0
  13. package/esm/__spec_helper__/mock-resize-observer.d.ts +1 -1
  14. package/esm/__spec_helper__/mock-resize-observer.js +2 -2
  15. package/esm/components/button-toggle/button-toggle.component.d.ts +3 -3
  16. package/esm/components/button-toggle/button-toggle.component.js +21 -20
  17. package/esm/components/button-toggle/button-toggle.style.d.ts +1 -1
  18. package/esm/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
  19. package/esm/components/button-toggle-group/button-toggle-group.component.js +187 -92
  20. package/esm/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
  21. package/esm/components/button-toggle-group/button-toggle-group.style.js +2 -2
  22. package/esm/components/button-toggle-group/index.d.ts +2 -1
  23. package/esm/components/drawer/drawer.component.d.ts +37 -0
  24. package/esm/components/drawer/drawer.component.js +43 -54
  25. package/esm/components/drawer/drawer.style.d.ts +27 -0
  26. package/esm/components/drawer/drawer.style.js +2 -2
  27. package/esm/components/drawer/index.d.ts +2 -1
  28. package/esm/components/drawer/index.js +1 -2
  29. package/esm/components/i18n-provider/i18n-provider.component.d.ts +8 -0
  30. package/esm/components/i18n-provider/i18n-provider.component.js +100 -80
  31. package/esm/components/i18n-provider/index.d.ts +2 -1
  32. package/esm/components/menu/__internal__/submenu/submenu.component.js +22 -4
  33. package/esm/components/menu/menu-item/menu-item.component.js +6 -1
  34. package/esm/components/menu/menu-item/menu-item.d.ts +4 -0
  35. package/esm/components/menu/menu-item/menu-item.style.js +158 -149
  36. package/esm/components/menu/scrollable-block/scrollable-block.component.js +21 -5
  37. package/esm/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
  38. package/esm/components/menu/scrollable-block/scrollable-block.style.js +1 -1
  39. package/esm/components/select/filterable-select/filterable-select.component.js +7 -5
  40. package/esm/components/select/multi-select/multi-select.component.js +4 -3
  41. package/esm/components/select/select-list/select-list.component.js +34 -18
  42. package/esm/components/select/simple-select/simple-select.component.js +4 -3
  43. package/esm/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
  44. package/esm/components/tabs/tab/tab.style.d.ts +2 -0
  45. package/esm/components/tabs/tabs.style.d.ts +2 -0
  46. package/lib/__internal__/i18n-context/index.d.ts +2 -1
  47. package/lib/__internal__/popover/popover.component.d.ts +2 -1
  48. package/lib/__internal__/popover/popover.component.js +16 -5
  49. package/lib/__internal__/popover/popover.style.d.ts +6 -2
  50. package/lib/__internal__/popover/popover.style.js +8 -3
  51. package/lib/__internal__/radio-button-mapper/index.d.ts +2 -0
  52. package/lib/{components/button-toggle-group/documentation → __internal__/radio-button-mapper}/index.js +2 -2
  53. package/lib/__internal__/radio-button-mapper/package.json +6 -0
  54. package/lib/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
  55. package/lib/__internal__/sticky-footer/index.d.ts +1 -0
  56. package/lib/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
  57. package/lib/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
  58. package/lib/__internal__/utils/helpers/tags/index.d.ts +1 -0
  59. package/lib/__spec_helper__/mock-resize-observer.d.ts +1 -1
  60. package/lib/__spec_helper__/mock-resize-observer.js +2 -2
  61. package/lib/components/button-toggle/button-toggle.component.d.ts +3 -3
  62. package/lib/components/button-toggle/button-toggle.component.js +22 -20
  63. package/lib/components/button-toggle/button-toggle.style.d.ts +1 -1
  64. package/lib/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
  65. package/lib/components/button-toggle-group/button-toggle-group.component.js +190 -93
  66. package/lib/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
  67. package/lib/components/button-toggle-group/button-toggle-group.style.js +2 -2
  68. package/lib/components/button-toggle-group/index.d.ts +2 -1
  69. package/lib/components/drawer/drawer.component.d.ts +37 -0
  70. package/lib/components/drawer/drawer.component.js +43 -55
  71. package/lib/components/drawer/drawer.style.d.ts +27 -0
  72. package/lib/components/drawer/drawer.style.js +3 -3
  73. package/lib/components/drawer/index.d.ts +2 -1
  74. package/lib/components/i18n-provider/i18n-provider.component.d.ts +8 -0
  75. package/lib/components/i18n-provider/i18n-provider.component.js +102 -82
  76. package/lib/components/i18n-provider/index.d.ts +2 -1
  77. package/lib/components/menu/__internal__/submenu/submenu.component.js +23 -4
  78. package/lib/components/menu/menu-item/menu-item.component.js +6 -1
  79. package/lib/components/menu/menu-item/menu-item.d.ts +4 -0
  80. package/lib/components/menu/menu-item/menu-item.style.js +158 -149
  81. package/lib/components/menu/scrollable-block/scrollable-block.component.js +22 -5
  82. package/lib/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
  83. package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
  84. package/lib/components/select/filterable-select/filterable-select.component.js +7 -5
  85. package/lib/components/select/multi-select/multi-select.component.js +4 -3
  86. package/lib/components/select/select-list/select-list.component.js +34 -18
  87. package/lib/components/select/simple-select/simple-select.component.js +4 -3
  88. package/lib/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
  89. package/lib/components/tabs/tab/tab.style.d.ts +2 -0
  90. package/lib/components/tabs/tabs.style.d.ts +2 -0
  91. package/package.json +1 -1
  92. package/esm/components/button-toggle-group/__definition__.js +0 -38
  93. package/esm/components/button-toggle-group/button-toggle-group.d.ts +0 -58
  94. package/esm/components/button-toggle-group/documentation/index.js +0 -1
  95. package/esm/components/drawer/drawer.d.ts +0 -44
  96. package/esm/components/i18n-provider/i18n-provider.d.ts +0 -11
  97. package/lib/components/button-toggle-group/__definition__.js +0 -50
  98. package/lib/components/button-toggle-group/button-toggle-group.d.ts +0 -58
  99. package/lib/components/button-toggle-group/documentation/package.json +0 -6
  100. package/lib/components/drawer/drawer.d.ts +0 -44
  101. package/lib/components/i18n-provider/i18n-provider.d.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { StyledButtonToggleLabel } from "../button-toggle/button-toggle.style";
3
3
  import ValidationIconStyle from "../../__internal__/validations/validation-icon.style";
4
- const ButtonToggleGroupStyle = styled.div`
4
+ const StyledButtonToggleGroup = styled.div`
5
5
  display: flex;
6
6
 
7
7
  ${({
@@ -34,4 +34,4 @@ const ButtonToggleGroupStyle = styled.div`
34
34
  margin-left: 4px;
35
35
  }
36
36
  `;
37
- export default ButtonToggleGroupStyle;
37
+ export default StyledButtonToggleGroup;
@@ -1 +1,2 @@
1
- export { default } from "./button-toggle-group";
1
+ export { default } from "./button-toggle-group.component";
2
+ export type { ButtonToggleGroupProps } from "./button-toggle-group.component";
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ export interface DrawerSidebarContextProps {
3
+ isInSidebar: boolean;
4
+ }
5
+ export interface DrawerProps {
6
+ /** Duration of a animation */
7
+ animationDuration?: string;
8
+ /** Specify an aria-label for the Drawer component */
9
+ "aria-label"?: string;
10
+ /** Sets color of sidebar's background */
11
+ backgroundColor?: string;
12
+ children: React.ReactNode;
13
+ /** Set the default state of expansion of the Drawer if component is meant to be used as uncontrolled */
14
+ defaultExpanded?: boolean;
15
+ /** Sets the expansion state of the Drawer if component is meant to be used as controlled */
16
+ expanded?: boolean;
17
+ expandedWidth?: string;
18
+ /** Sets custom height to Drawer component */
19
+ height?: string;
20
+ /** Callback fired when expansion state changes, onChange(event: object, isExpanded: boolean) */
21
+ onChange?: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>, isExpanded: boolean) => void;
22
+ sidebar?: React.ReactNode;
23
+ /** Enables expand/collapse button that controls drawer */
24
+ showControls?: boolean;
25
+ /** Sets the heading of the drawer */
26
+ title?: React.ReactNode;
27
+ /** Content to display inside of a footer */
28
+ footer?: React.ReactNode;
29
+ /** Makes the header of the drawer sticky. Title prop must also be set. */
30
+ stickyHeader?: boolean;
31
+ /** Makes the footer of the drawer sticky. Footer prop must also be set. */
32
+ stickyFooter?: boolean;
33
+ }
34
+ declare const DrawerSidebarContext: React.Context<{}>;
35
+ export declare const Drawer: ({ defaultExpanded, expanded, onChange, children, expandedWidth, sidebar, animationDuration, backgroundColor, title, footer, showControls, height, stickyHeader, stickyFooter, ...rest }: DrawerProps) => JSX.Element;
36
+ export { DrawerSidebarContext };
37
+ export default Drawer;
@@ -2,12 +2,11 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useState, useCallback, useRef, useEffect } from "react";
4
4
  import PropTypes from "prop-types";
5
- import classNames from "classnames";
6
5
  import invariant from "invariant";
7
6
  import createGuid from "../../__internal__/utils/helpers/guid";
8
7
  import usePrevious from "../../hooks/__internal__/usePrevious";
9
8
  import Icon from "../icon";
10
- import { StyledSidebarHeader, StyledDrawerWrapper, StyledDrawerContent, StyledButton, StyledDrawerChildren, StyledDrawerSidebar, StyledSidebarTitle } from "./drawer.style";
9
+ import { StyledSidebarHeader, StyledDrawerWrapper, StyledDrawerContent, StyledSidebarToggleButton, StyledDrawerChildren, StyledDrawerSidebar, StyledSidebarTitle } from "./drawer.style";
11
10
  import StickyFooter from "../../__internal__/sticky-footer";
12
11
  const DrawerSidebarContext = /*#__PURE__*/React.createContext({});
13
12
 
@@ -28,17 +27,17 @@ const Drawer = ({
28
27
  stickyFooter,
29
28
  ...rest
30
29
  }) => {
31
- const drawerSidebarContentRef = useRef();
32
- const scrollableContentRef = useRef();
30
+ const drawerSidebarContentRef = useRef(null);
31
+ const scrollableContentRef = useRef(null);
33
32
  const isControlled = useRef(expanded !== undefined);
34
33
  const [isOpening, setIsOpening] = useState(false);
35
34
  const [isClosing, setIsClosing] = useState(false);
36
35
  const [isExpanded, setIsExpanded] = useState(isControlled.current ? expanded : defaultExpanded);
37
- const timer = useRef();
36
+ const timer = useRef(null);
38
37
  const getAnimationDuration = useCallback(() => {
39
38
  if (animationDuration.indexOf("ms") !== -1) {
40
39
  const animationTime = animationDuration.substring(0, animationDuration.length - 2);
41
- return animationTime;
40
+ return parseInt(animationTime);
42
41
  }
43
42
 
44
43
  if (animationDuration.indexOf(".") !== -1 || animationDuration.indexOf("s") !== -1) {
@@ -46,11 +45,14 @@ const Drawer = ({
46
45
  return parseFloat(animationTime) * 1000;
47
46
  }
48
47
 
49
- return animationDuration;
48
+ return parseInt(animationDuration);
50
49
  }, [animationDuration]);
51
50
  const toggleAnimation = useCallback(() => {
52
51
  const timeout = getAnimationDuration();
53
- clearTimeout(timer.current);
52
+
53
+ if (timer.current) {
54
+ clearTimeout(timer.current);
55
+ }
54
56
 
55
57
  if (!isExpanded) {
56
58
  setIsClosing(false);
@@ -81,14 +83,16 @@ const Drawer = ({
81
83
  }, [expanded, toggleAnimation, previousValue, showControls]);
82
84
  useEffect(() => {
83
85
  return function cleanup() {
84
- clearTimeout(timer.current);
86
+ if (timer.current) {
87
+ clearTimeout(timer.current);
88
+ }
85
89
  };
86
90
  }, []);
87
91
  const toggleDrawer = useCallback(ev => {
88
92
  setIsExpanded(!isExpanded);
89
93
  if (onChange) onChange(ev, !isExpanded);
90
94
 
91
- if (isExpanded) {
95
+ if (isExpanded && drawerSidebarContentRef.current) {
92
96
  drawerSidebarContentRef.current.scrollTop = 0;
93
97
  }
94
98
 
@@ -97,20 +101,29 @@ const Drawer = ({
97
101
  const guid = useRef(createGuid());
98
102
  const sidebarId = `DrawerSidebar_${guid.current}`;
99
103
  const getClassNames = useCallback(() => {
100
- return classNames(isExpanded ? "open" : "closed", isOpening ? "opening" : "", isClosing ? "closing" : "");
104
+ const classes = [isExpanded ? "open" : "closed"];
105
+
106
+ if (isOpening) {
107
+ classes.push("opening");
108
+ }
109
+
110
+ if (isClosing) {
111
+ classes.push("closing");
112
+ }
113
+
114
+ return classes.join(" ");
101
115
  }, [isExpanded, isOpening, isClosing]);
102
116
 
103
117
  const getControls = () => {
104
118
  if (showControls === undefined) return null;
105
- return /*#__PURE__*/React.createElement(StyledButton, {
119
+ return /*#__PURE__*/React.createElement(StyledSidebarToggleButton, {
106
120
  "aria-label": "toggle sidebar",
107
121
  "aria-expanded": isExpanded,
108
122
  "aria-controls": sidebarId,
109
123
  "data-element": "drawer-toggle",
110
124
  onClick: toggleDrawer,
111
125
  isExpanded: isExpanded,
112
- animationDuration: animationDuration,
113
- stickyHeader: stickyHeader
126
+ animationDuration: animationDuration
114
127
  }, /*#__PURE__*/React.createElement(Icon, {
115
128
  type: "chevron_right"
116
129
  }));
@@ -147,46 +160,22 @@ const Drawer = ({
147
160
  };
148
161
 
149
162
  Drawer.propTypes = {
150
- children: PropTypes.node.isRequired,
151
-
152
- /** Set the default state of expansion of the Drawer if component is meant to be used as uncontrolled */
153
- defaultExpanded: PropTypes.bool,
154
-
155
- /** Sets the expansion state of the Drawer if component is meant to be used as controlled */
156
- expanded: PropTypes.bool,
157
-
158
- /** Callback fired when expansion state changes, onChange(event: object, isExpanded: boolean) */
159
- onChange: PropTypes.func,
160
-
161
- /* Sidebar object either html or react component */
162
- sidebar: PropTypes.node,
163
-
164
- /* The (% or px) width of the expanded sidebar */
165
- expandedWidth: PropTypes.string,
166
-
167
- /** Duration of a animation */
168
- animationDuration: PropTypes.string,
169
-
170
- /** Sets color of sidebar's background */
171
- backgroundColor: PropTypes.string,
172
-
173
- /** Sets custom height to Drawer component */
174
- height: PropTypes.string,
175
-
176
- /** Sets the heading of the drawer */
177
- title: PropTypes.node,
178
-
179
- /** Enables expand/collapse button that controls drawer */
180
- showControls: PropTypes.bool,
181
-
182
- /** Content to display inside of a footer */
183
- footer: PropTypes.node,
184
-
185
- /** Makes the header of the drawer sticky. Title prop must also be set. */
186
- stickyHeader: PropTypes.bool,
187
-
188
- /** Makes the footer of the drawer sticky. Footer prop must also be set. */
189
- stickyFooter: PropTypes.bool
163
+ "animationDuration": PropTypes.string,
164
+ "aria-label": PropTypes.string,
165
+ "backgroundColor": PropTypes.string,
166
+ "children": PropTypes.node,
167
+ "defaultExpanded": PropTypes.bool,
168
+ "expanded": PropTypes.bool,
169
+ "expandedWidth": PropTypes.string,
170
+ "footer": PropTypes.node,
171
+ "height": PropTypes.string,
172
+ "onChange": PropTypes.func,
173
+ "showControls": PropTypes.bool,
174
+ "sidebar": PropTypes.node,
175
+ "stickyFooter": PropTypes.bool,
176
+ "stickyHeader": PropTypes.bool,
177
+ "title": PropTypes.node
190
178
  };
179
+ export { Drawer };
191
180
  export { DrawerSidebarContext };
192
181
  export default Drawer;
@@ -0,0 +1,27 @@
1
+ declare const StyledSidebarHeader: import("styled-components").StyledComponent<"div", any, {
2
+ isExpanded?: boolean | undefined;
3
+ }, never>;
4
+ declare const StyledSidebarTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ declare const StyledDrawerChildren: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ interface StyledDrawerSidebarProps {
7
+ isExpanded?: boolean;
8
+ hasControls: boolean;
9
+ }
10
+ declare const StyledDrawerSidebar: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps & StyledDrawerSidebarProps, never>;
11
+ interface StyledDrawerContentProps {
12
+ animationDuration?: string;
13
+ backgroundColor?: string;
14
+ expandedWidth: string;
15
+ }
16
+ declare const StyledDrawerContent: import("styled-components").StyledComponent<"div", any, StyledDrawerContentProps, never>;
17
+ interface StyledSidebarToggleButtonProps {
18
+ animationDuration?: string;
19
+ isExpanded?: boolean;
20
+ }
21
+ declare const StyledSidebarToggleButton: import("styled-components").StyledComponent<"button", any, {
22
+ type: "button";
23
+ } & StyledSidebarToggleButtonProps, "type">;
24
+ declare const StyledDrawerWrapper: import("styled-components").StyledComponent<"div", any, {
25
+ height: string;
26
+ }, never>;
27
+ export { StyledSidebarHeader, StyledDrawerWrapper, StyledDrawerContent, StyledDrawerChildren, StyledDrawerSidebar, StyledSidebarTitle, StyledSidebarToggleButton, };
@@ -165,7 +165,7 @@ const StyledDrawerContent = styled.div`
165
165
  }
166
166
  }
167
167
  `;
168
- const StyledButton = styled.button.attrs({
168
+ const StyledSidebarToggleButton = styled.button.attrs({
169
169
  type: "button"
170
170
  })`
171
171
  ${({
@@ -207,4 +207,4 @@ const StyledDrawerWrapper = styled.div`
207
207
  height
208
208
  }) => height};
209
209
  `;
210
- export { StyledSidebarHeader, StyledDrawerWrapper, StyledDrawerContent, StyledDrawerChildren, StyledDrawerSidebar, StyledSidebarTitle, StyledButton };
210
+ export { StyledSidebarHeader, StyledDrawerWrapper, StyledDrawerContent, StyledDrawerChildren, StyledDrawerSidebar, StyledSidebarTitle, StyledSidebarToggleButton };
@@ -1 +1,2 @@
1
- export { default, DrawerSidebarContext } from "./drawer";
1
+ export { default, DrawerSidebarContext } from "./drawer.component";
2
+ export type { DrawerSidebarContextProps, DrawerProps, } from "./drawer.component";
@@ -1,2 +1 @@
1
- export { default } from "./drawer.component";
2
- export { DrawerSidebarContext } from "./drawer.component";
1
+ export { default, DrawerSidebarContext } from "./drawer.component";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import Locale from "../../locales";
3
+ export interface I18nProviderProps {
4
+ locale?: Partial<Locale>;
5
+ children: React.ReactNode;
6
+ }
7
+ export declare const I18nProvider: ({ locale, children }: I18nProviderProps) => JSX.Element;
8
+ export default I18nProvider;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import merge from "lodash/merge";
3
2
  import PropTypes from "prop-types";
3
+ import merge from "lodash/merge";
4
4
  import Context from "../../__internal__/i18n-context";
5
5
  import enGB from "../../locales/en-gb";
6
6
 
@@ -9,87 +9,107 @@ const I18nProvider = ({
9
9
  children
10
10
  }) => locale ? /*#__PURE__*/React.createElement(Context.Provider, {
11
11
  value: merge({}, enGB, locale)
12
- }, children) : children;
12
+ }, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
13
13
 
14
- I18nProvider.defaultProps = {
15
- locale: undefined
16
- };
17
14
  I18nProvider.propTypes = {
18
- locale: PropTypes.shape({
19
- locale: PropTypes.func,
20
- actions: PropTypes.shape({
21
- edit: PropTypes.func,
22
- delete: PropTypes.func,
23
- reset: PropTypes.func
24
- }),
25
- actionPopover: PropTypes.shape({
26
- ariaLabel: PropTypes.func
27
- }),
28
- batchSelection: PropTypes.shape({
29
- selected: PropTypes.func
30
- }),
31
- confirm: PropTypes.shape({
32
- no: PropTypes.func,
33
- yes: PropTypes.func
34
- }),
35
- date: PropTypes.shape({
36
- dateFnsLocale: PropTypes.func
37
- }),
38
- errors: PropTypes.shape({
39
- messages: PropTypes.shape({
40
- formSummary: PropTypes.func
41
- })
42
- }),
43
- message: PropTypes.shape({
44
- closeButtonAriaLabel: PropTypes.func
45
- }),
46
- numeralDate: PropTypes.shape({
47
- validation: PropTypes.shape({
48
- day: PropTypes.func,
49
- month: PropTypes.func,
50
- year: PropTypes.func
51
- })
52
- }),
53
- pager: PropTypes.shape({
54
- show: PropTypes.func,
55
- records: PropTypes.func,
56
- first: PropTypes.func,
57
- last: PropTypes.func,
58
- next: PropTypes.func,
59
- previous: PropTypes.func,
60
- pageX: PropTypes.func,
61
- ofY: PropTypes.func
62
- }),
63
- select: PropTypes.shape({
64
- actionButtonText: PropTypes.func,
65
- placeholder: PropTypes.func,
66
- noResultsForTerm: PropTypes.func
67
- }),
68
- switch: PropTypes.shape({
69
- on: PropTypes.func,
70
- off: PropTypes.func
71
- }),
72
- table: PropTypes.shape({
73
- noData: PropTypes.func
74
- }),
75
- textEditor: PropTypes.shape({
76
- tooltipMessages: PropTypes.shape({
77
- bold: PropTypes.func,
78
- italic: PropTypes.func,
79
- bulletList: PropTypes.func,
80
- numberList: PropTypes.func
81
- }),
82
- ariaLabels: PropTypes.shape({
83
- bold: PropTypes.func,
84
- italic: PropTypes.func,
85
- bulletList: PropTypes.func,
86
- numberList: PropTypes.func
87
- })
88
- }),
89
- titleSelect: PropTypes.shape({
90
- deselect: PropTypes.func
15
+ "children": PropTypes.node,
16
+ "locale": PropTypes.shape({
17
+ "actionPopover": PropTypes.shape({
18
+ "ariaLabel": PropTypes.func.isRequired
19
+ }),
20
+ "actions": PropTypes.shape({
21
+ "delete": PropTypes.func.isRequired,
22
+ "edit": PropTypes.func.isRequired
23
+ }),
24
+ "batchSelection": PropTypes.shape({
25
+ "selected": PropTypes.func.isRequired
26
+ }),
27
+ "confirm": PropTypes.shape({
28
+ "no": PropTypes.func.isRequired,
29
+ "yes": PropTypes.func.isRequired
30
+ }),
31
+ "date": PropTypes.shape({
32
+ "dateFnsLocale": PropTypes.func.isRequired
33
+ }),
34
+ "dialog": PropTypes.shape({
35
+ "ariaLabels": PropTypes.shape({
36
+ "close": PropTypes.func.isRequired
37
+ }).isRequired
38
+ }),
39
+ "dialogFullScreen": PropTypes.shape({
40
+ "ariaLabels": PropTypes.shape({
41
+ "close": PropTypes.func.isRequired
42
+ }).isRequired
43
+ }),
44
+ "errors": PropTypes.shape({
45
+ "messages": PropTypes.shape({
46
+ "formSummary": PropTypes.func.isRequired
47
+ }).isRequired
48
+ }),
49
+ "heading": PropTypes.shape({
50
+ "backLinkAriaLabel": PropTypes.func.isRequired
51
+ }),
52
+ "link": PropTypes.shape({
53
+ "skipLinkLabel": PropTypes.func.isRequired
54
+ }),
55
+ "locale": PropTypes.func,
56
+ "message": PropTypes.shape({
57
+ "closeButtonAriaLabel": PropTypes.func.isRequired
58
+ }),
59
+ "numeralDate": PropTypes.shape({
60
+ "validation": PropTypes.shape({
61
+ "day": PropTypes.func.isRequired,
62
+ "month": PropTypes.func.isRequired,
63
+ "year": PropTypes.func.isRequired
64
+ }).isRequired
65
+ }),
66
+ "pager": PropTypes.shape({
67
+ "first": PropTypes.func.isRequired,
68
+ "last": PropTypes.func.isRequired,
69
+ "next": PropTypes.func.isRequired,
70
+ "ofY": PropTypes.func.isRequired,
71
+ "pageX": PropTypes.func.isRequired,
72
+ "previous": PropTypes.func.isRequired,
73
+ "records": PropTypes.func.isRequired,
74
+ "show": PropTypes.func.isRequired
75
+ }),
76
+ "select": PropTypes.shape({
77
+ "actionButtonText": PropTypes.func.isRequired,
78
+ "noResultsForTerm": PropTypes.func.isRequired,
79
+ "placeholder": PropTypes.func.isRequired
80
+ }),
81
+ "sidebar": PropTypes.shape({
82
+ "ariaLabels": PropTypes.shape({
83
+ "close": PropTypes.func.isRequired
84
+ }).isRequired
85
+ }),
86
+ "switch": PropTypes.shape({
87
+ "off": PropTypes.func.isRequired,
88
+ "on": PropTypes.func.isRequired
89
+ }),
90
+ "textEditor": PropTypes.shape({
91
+ "ariaLabels": PropTypes.shape({
92
+ "bold": PropTypes.func.isRequired,
93
+ "bulletList": PropTypes.func.isRequired,
94
+ "italic": PropTypes.func.isRequired,
95
+ "numberList": PropTypes.func.isRequired
96
+ }).isRequired,
97
+ "tooltipMessages": PropTypes.shape({
98
+ "bold": PropTypes.func.isRequired,
99
+ "bulletList": PropTypes.func.isRequired,
100
+ "italic": PropTypes.func.isRequired,
101
+ "numberList": PropTypes.func.isRequired
102
+ }).isRequired
103
+ }),
104
+ "tileSelect": PropTypes.shape({
105
+ "deselect": PropTypes.func.isRequired
106
+ }),
107
+ "toast": PropTypes.shape({
108
+ "ariaLabels": PropTypes.shape({
109
+ "close": PropTypes.func.isRequired
110
+ }).isRequired
91
111
  })
92
- }),
93
- children: PropTypes.node.isRequired
112
+ })
94
113
  };
114
+ export { I18nProvider };
95
115
  export default I18nProvider;
@@ -1 +1,2 @@
1
- export { default } from "./i18n-provider";
1
+ export { default } from "./i18n-provider.component";
2
+ export type { I18nProviderProps } from "./i18n-provider.component";
@@ -41,13 +41,31 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
41
41
  const [characterString, setCharacterString] = useState("");
42
42
  const formattedChildren = React.Children.map(children, child => {
43
43
  if (child.type === ScrollableBlock) {
44
- return [...child.props.children];
44
+ const blockChildren = [...child.props.children];
45
+
46
+ if (child.props.parent) {
47
+ blockChildren.unshift( /*#__PURE__*/React.createElement(MenuItem, null, child.props.parent));
48
+ }
49
+
50
+ return blockChildren;
45
51
  }
46
52
 
47
53
  return child;
48
54
  });
49
55
  const arrayOfFormattedChildren = React.Children.toArray(formattedChildren);
50
56
  const numberOfChildren = useMemo(() => React.Children.count(formattedChildren), [formattedChildren]);
57
+ const blockIndex = useMemo(() => {
58
+ var _childrenArray$index;
59
+
60
+ const childrenArray = React.Children.toArray(children);
61
+ let index = childrenArray.findIndex(item => item.type === ScrollableBlock);
62
+
63
+ if ((_childrenArray$index = childrenArray[index]) !== null && _childrenArray$index !== void 0 && _childrenArray$index.props.parent) {
64
+ index += 1;
65
+ }
66
+
67
+ return index;
68
+ }, [children]);
51
69
  const characterTimer = useRef();
52
70
  const startCharacterTimeout = useCallback(() => {
53
71
  characterTimer.current = setTimeout(() => {
@@ -233,7 +251,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
233
251
  isFocused: submenuFocusIndex === index,
234
252
  focusIndex: submenuFocusIndex,
235
253
  handleKeyDown,
236
- blockIndex: React.Children.toArray(children).findIndex(item => item.type === ScrollableBlock)
254
+ blockIndex
237
255
  }
238
256
  }, child))));
239
257
  }
@@ -266,13 +284,13 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
266
284
  submenuDirection: submenuDirection,
267
285
  variant: variant,
268
286
  menuType: menuContext.menuType,
269
- role: "list"
287
+ role: blockIndex === 0 ? "presentation" : "list"
270
288
  }, React.Children.map(children, (child, index) => /*#__PURE__*/React.createElement(SubmenuContext.Provider, {
271
289
  value: {
272
290
  isFocused: !blockDoubleFocus && submenuFocusIndex === index,
273
291
  focusIndex: submenuFocusIndex,
274
292
  handleKeyDown,
275
- blockIndex: React.Children.toArray(children).findIndex(item => item.type === ScrollableBlock),
293
+ blockIndex,
276
294
  updateFocusIndex: setSubmenuFocusIndex,
277
295
  itemIndex: child.type === MenuItem ? index : undefined
278
296
  }
@@ -31,6 +31,7 @@ const MenuItem = ({
31
31
  menuOpen,
32
32
  onSubmenuOpen,
33
33
  onSubmenuClose,
34
+ overrideColor,
34
35
  ...rest
35
36
  }) => {
36
37
  const menuContext = useContext(MenuContext);
@@ -95,6 +96,7 @@ const MenuItem = ({
95
96
  selected,
96
97
  variant,
97
98
  onKeyDown: !inFullscreenView ? handleKeyDown : undefined,
99
+ overrideColor,
98
100
  ref
99
101
  };
100
102
  const clonedChildren = isChildSearch.current ? childrenItems.map(child => /*#__PURE__*/React.cloneElement(child, {
@@ -228,6 +230,9 @@ MenuItem.propTypes = {
228
230
  onSubmenuOpen: PropTypes.func,
229
231
 
230
232
  /** Callback triggered when submenu closes. Only valid with submenu prop */
231
- onSubmenuClose: PropTypes.func
233
+ onSubmenuClose: PropTypes.func,
234
+
235
+ /** @ignore @private */
236
+ overrideColor: PropTypes.bool
232
237
  };
233
238
  export default MenuItem;
@@ -29,6 +29,10 @@ export interface MenuItemBaseProps extends LayoutProps, FlexboxProps {
29
29
  onSubmenuOpen?: () => void;
30
30
  /** Callback triggered when submenu closes. Only valid with submenu prop */
31
31
  onSubmenuClose?: () => void;
32
+ /** @ignore @private
33
+ private prop, used inside ScrollableBlock to ensure the MenuItem's color variant overrides the CSS
34
+ for other MenuItems inside the block */
35
+ overrideColor?: boolean;
32
36
  }
33
37
 
34
38
  export interface MenuWithChildren extends MenuItemBaseProps {