carbon-react 110.2.4 → 110.3.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 (44) hide show
  1. package/esm/__internal__/sticky-footer/index.d.ts +1 -0
  2. package/esm/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
  3. package/esm/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
  4. package/esm/__spec_helper__/mock-resize-observer.d.ts +1 -1
  5. package/esm/__spec_helper__/mock-resize-observer.js +2 -2
  6. package/esm/components/drawer/drawer.component.d.ts +37 -0
  7. package/esm/components/drawer/drawer.component.js +43 -54
  8. package/esm/components/drawer/drawer.style.d.ts +27 -0
  9. package/esm/components/drawer/drawer.style.js +2 -2
  10. package/esm/components/drawer/index.d.ts +2 -1
  11. package/esm/components/drawer/index.js +1 -2
  12. package/esm/components/menu/__internal__/submenu/submenu.component.js +22 -4
  13. package/esm/components/menu/menu-item/menu-item.component.js +6 -1
  14. package/esm/components/menu/menu-item/menu-item.d.ts +4 -0
  15. package/esm/components/menu/menu-item/menu-item.style.js +158 -149
  16. package/esm/components/menu/scrollable-block/scrollable-block.component.js +21 -5
  17. package/esm/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
  18. package/esm/components/menu/scrollable-block/scrollable-block.style.js +1 -1
  19. package/esm/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
  20. package/esm/components/tabs/tab/tab.style.d.ts +2 -0
  21. package/esm/components/tabs/tabs.style.d.ts +2 -0
  22. package/lib/__internal__/sticky-footer/index.d.ts +1 -0
  23. package/lib/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
  24. package/lib/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
  25. package/lib/__spec_helper__/mock-resize-observer.d.ts +1 -1
  26. package/lib/__spec_helper__/mock-resize-observer.js +2 -2
  27. package/lib/components/drawer/drawer.component.d.ts +37 -0
  28. package/lib/components/drawer/drawer.component.js +43 -55
  29. package/lib/components/drawer/drawer.style.d.ts +27 -0
  30. package/lib/components/drawer/drawer.style.js +3 -3
  31. package/lib/components/drawer/index.d.ts +2 -1
  32. package/lib/components/menu/__internal__/submenu/submenu.component.js +23 -4
  33. package/lib/components/menu/menu-item/menu-item.component.js +6 -1
  34. package/lib/components/menu/menu-item/menu-item.d.ts +4 -0
  35. package/lib/components/menu/menu-item/menu-item.style.js +158 -149
  36. package/lib/components/menu/scrollable-block/scrollable-block.component.js +22 -5
  37. package/lib/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
  38. package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
  39. package/lib/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
  40. package/lib/components/tabs/tab/tab.style.d.ts +2 -0
  41. package/lib/components/tabs/tabs.style.d.ts +2 -0
  42. package/package.json +1 -1
  43. package/esm/components/drawer/drawer.d.ts +0 -44
  44. package/lib/components/drawer/drawer.d.ts +0 -44
@@ -15,6 +15,7 @@ const StyledMenuItemWrapper = styled.a`
15
15
  clickToOpen,
16
16
  maxWidth,
17
17
  inFullscreenView,
18
+ overrideColor,
18
19
  as
19
20
  }) => css`
20
21
  display: inline-block;
@@ -23,43 +24,51 @@ const StyledMenuItemWrapper = styled.a`
23
24
  height: 40px;
24
25
  position: relative;
25
26
  cursor: pointer;
26
- background-color: ${menuConfigVariants[menuType].background};
27
+ ${!overrideColor && css`
28
+ background-color: ${menuConfigVariants[menuType].background};
29
+ `}};
30
+
31
+ ${overrideColor && css`
32
+ &&&& {
33
+ background-color: ${variant === "alternate" ? menuConfigVariants[menuType].alternate : menuConfigVariants[menuType].submenuItemBackground};
34
+ }
35
+ `}
27
36
 
28
37
  ${!inFullscreenView && css`
29
- max-width: inherit;
30
-
31
- a,
32
- button {
33
- ${maxWidth && css`
34
- box-sizing: border-box;
35
- max-width: inherit;
36
- text-overflow: ellipsis;
37
- overflow: hidden;
38
- white-space: nowrap;
39
- vertical-align: bottom;
40
- `}
41
- }
42
-
43
- a:focus,
44
- button:focus {
45
- box-shadow: inset 0 0 0 var(--borderWidth300)
46
- var(--colorsSemanticFocus500);
47
- background-color: ${menuConfigVariants[menuType].background};
48
- color: ${menuConfigVariants[menuType].color};
49
- z-index: 1;
50
- position: relative;
51
- }
38
+ max-width: inherit;
39
+
40
+ a,
41
+ button {
42
+ ${maxWidth && css`
43
+ box-sizing: border-box;
44
+ max-width: inherit;
45
+ text-overflow: ellipsis;
46
+ overflow: hidden;
47
+ white-space: nowrap;
48
+ vertical-align: bottom;
49
+ `}
50
+ }
52
51
 
53
- a:hover,
54
- button:hover {
55
- background-color: var(--colorsComponentsMenuAutumnStandard600);
56
- color: var(--colorsComponentsMenuYang100);
52
+ a:focus,
53
+ button:focus {
54
+ box-shadow: inset 0 0 0 var(--borderWidth300)
55
+ var(--colorsSemanticFocus500);
56
+ background-color: ${menuConfigVariants[menuType].background};
57
+ color: ${menuConfigVariants[menuType].color};
58
+ z-index: 1;
59
+ position: relative;
60
+ }
57
61
 
58
- [data-component="icon"] {
62
+ a:hover,
63
+ button:hover {
64
+ background-color: var(--colorsComponentsMenuAutumnStandard600);
59
65
  color: var(--colorsComponentsMenuYang100);
66
+
67
+ [data-component="icon"] {
68
+ color: var(--colorsComponentsMenuYang100);
69
+ }
60
70
  }
61
- }
62
- `}
71
+ `}
63
72
 
64
73
  a,
65
74
  ${StyledLink} a,
@@ -92,159 +101,159 @@ const StyledMenuItemWrapper = styled.a`
92
101
  }
93
102
 
94
103
  ${selected && css`
95
- background-color: ${menuConfigVariants[menuType].selected};
96
-
97
- a:focus,
98
- button:focus {
99
104
  background-color: ${menuConfigVariants[menuType].selected};
100
- }
101
105
 
102
- a:hover,
103
- button:hover {
104
- background-color: var(--colorsComponentsMenuAutumnStandard600);
105
- }
106
- `}
106
+ a:focus,
107
+ button:focus {
108
+ background-color: ${menuConfigVariants[menuType].selected};
109
+ }
110
+
111
+ a:hover,
112
+ button:hover {
113
+ background-color: var(--colorsComponentsMenuAutumnStandard600);
114
+ }
115
+ `}
107
116
 
108
117
  ${variant === "alternate" && !inFullscreenView && css`
109
- &&& {
110
- background-color: ${menuConfigVariants[menuType].alternate};
111
- }
118
+ &&& {
119
+ background-color: ${menuConfigVariants[menuType].alternate};
120
+ }
112
121
 
113
- &&& a:focus,
114
- &&& button:focus {
115
- background-color: ${menuConfigVariants[menuType].alternate};
116
- }
122
+ &&& a:focus,
123
+ &&& button:focus {
124
+ background-color: ${menuConfigVariants[menuType].alternate};
125
+ }
117
126
 
118
- &&& a:hover,
119
- &&& button:hover {
120
- background-color: ${menuConfigVariants[menuType].alternateHover};
121
- }
122
- `}
127
+ &&& a:hover,
128
+ &&& button:hover {
129
+ background-color: ${menuConfigVariants[menuType].alternateHover};
130
+ }
131
+ `}
123
132
 
124
133
  ${isOpen && css`
125
- a,
126
- button {
127
- background-color: ${menuConfigVariants[menuType].submenuItemBackground};
128
- color: ${menuConfigVariants[menuType].color};
129
- }
130
- `}
134
+ a,
135
+ button {
136
+ background-color: ${menuConfigVariants[menuType].submenuItemBackground};
137
+ color: ${menuConfigVariants[menuType].color};
138
+ }
139
+ `}
131
140
 
132
141
  ${hasSubmenu && css`
133
- background-color: ${menuConfigVariants[menuType].submenuBackground};
134
-
135
- a:focus,
136
- button:focus {
137
142
  background-color: ${menuConfigVariants[menuType].submenuBackground};
138
- color: ${menuConfigVariants[menuType].color};
139
143
 
140
- [data-component="icon"] {
144
+ a:focus,
145
+ button:focus {
146
+ background-color: ${menuConfigVariants[menuType].submenuBackground};
141
147
  color: ${menuConfigVariants[menuType].color};
148
+
149
+ [data-component="icon"] {
150
+ color: ${menuConfigVariants[menuType].color};
151
+ }
152
+
153
+ ${clickToOpen && isOpen && css`
154
+ background-color: ${menuConfigVariants[menuType].submenuOpenedBackground};
155
+ `}
142
156
  }
143
157
 
144
- ${clickToOpen && isOpen && css`
158
+ a:hover,
159
+ button:hover {
145
160
  background-color: ${menuConfigVariants[menuType].submenuOpenedBackground};
146
- `}
147
- }
161
+ color: var(--colorsComponentsMenuYang100);
148
162
 
149
- a:hover,
150
- button:hover {
151
- background-color: ${menuConfigVariants[menuType].submenuOpenedBackground};
152
- color: var(--colorsComponentsMenuYang100);
163
+ ${!(href || clickToOpen) && css`
164
+ cursor: default;
165
+ background-color: ${menuConfigVariants[menuType].submenuItemBackground};
166
+ color: ${menuConfigVariants[menuType].color};
167
+ `}
153
168
 
154
- ${!(href || clickToOpen) && css`
155
- cursor: default;
156
- background-color: ${menuConfigVariants[menuType].submenuItemBackground};
157
- color: ${menuConfigVariants[menuType].color};
158
- `}
159
-
160
- [data-component="icon"] {
161
- color: ${menuConfigVariants[menuType].color};
169
+ [data-component="icon"] {
170
+ color: ${menuConfigVariants[menuType].color};
171
+ }
162
172
  }
163
- }
164
173
 
165
- ${selected && css`
166
- background-color: ${menuConfigVariants[menuType].submenuSelected};
167
-
168
- a:focus,
169
- button:focus {
174
+ ${selected && css`
170
175
  background-color: ${menuConfigVariants[menuType].submenuSelected};
171
- }
172
176
 
173
- a:hover,
174
- button:hover {
175
- background-color: var(--colorsComponentsMenuAutumnStandard600);
176
- color: var(--colorsComponentsMenuYang100);
177
- }
178
- `}
177
+ a:focus,
178
+ button:focus {
179
+ background-color: ${menuConfigVariants[menuType].submenuSelected};
180
+ }
179
181
 
180
- ${showDropdownArrow && css`
181
- > a,
182
- > button {
183
- padding-right: 32px;
184
- }
182
+ a:hover,
183
+ button:hover {
184
+ background-color: var(--colorsComponentsMenuAutumnStandard600);
185
+ color: var(--colorsComponentsMenuYang100);
186
+ }
187
+ `}
185
188
 
186
- a::before,
187
- button::before {
188
- display: block;
189
- margin-top: -2px;
190
- pointer-events: none;
191
- position: absolute;
192
- right: 16px;
193
- top: 50%;
194
- z-index: 2;
195
- content: "";
196
- width: 0;
197
- height: 0;
198
- border-top: 5px solid ${menuConfigVariants[menuType].text};
199
- border-right: 4px solid transparent;
200
- border-bottom: 4px solid transparent;
201
- border-left: 4px solid transparent;
202
- }
203
- `};
204
- `}
189
+ ${showDropdownArrow && css`
190
+ > a,
191
+ > button {
192
+ padding-right: 32px;
193
+ }
194
+
195
+ a::before,
196
+ button::before {
197
+ display: block;
198
+ margin-top: -2px;
199
+ pointer-events: none;
200
+ position: absolute;
201
+ right: 16px;
202
+ top: 50%;
203
+ z-index: 2;
204
+ content: "";
205
+ width: 0;
206
+ height: 0;
207
+ border-top: 5px solid ${menuConfigVariants[menuType].text};
208
+ border-right: 4px solid transparent;
209
+ border-bottom: 4px solid transparent;
210
+ border-left: 4px solid transparent;
211
+ }
212
+ `}
213
+ `}
205
214
 
206
215
  ${isSearch && css`
207
- padding: 2px 16px;
208
- `}
216
+ padding: 2px 16px;
217
+ `}
209
218
 
210
219
  ${inFullscreenView && css`
211
- ${as === "div" && css`
212
- cursor: default;
213
- padding: 0 16px;
220
+ ${as === "div" && css`
221
+ cursor: default;
222
+ padding: 0 16px;
214
223
 
215
- :hover {
216
- background: transparent;
217
- }
218
- `}
224
+ :hover {
225
+ background: transparent;
226
+ }
227
+ `}
219
228
 
220
- a,
229
+ a,
221
230
  ${StyledLink} a,
222
231
  button,
223
232
  ${StyledLink} button {
224
- width: 100vw;
225
- box-sizing: border-box;
226
- }
227
-
228
- a:focus,
229
- button:focus {
230
- box-shadow: inset 0 0 0 var(--borderWidth300)
231
- var(--colorsSemanticFocus500);
232
- z-index: 1;
233
- position: relative;
234
- }
235
-
236
- a:focus,
237
- a:hover,
238
- button:focus,
239
- button:hover {
240
- background-color: var(--colorsComponentsMenuAutumnStandard600);
241
- color: var(--colorsComponentsMenuYang100);
242
-
243
- [data-component="icon"] {
233
+ width: 100vw;
234
+ box-sizing: border-box;
235
+ }
236
+
237
+ a:focus,
238
+ button:focus {
239
+ box-shadow: inset 0 0 0 var(--borderWidth300)
240
+ var(--colorsSemanticFocus500);
241
+ z-index: 1;
242
+ position: relative;
243
+ }
244
+
245
+ a:focus,
246
+ a:hover,
247
+ button:focus,
248
+ button:hover {
249
+ background-color: var(--colorsComponentsMenuAutumnStandard600);
244
250
  color: var(--colorsComponentsMenuYang100);
251
+
252
+ [data-component="icon"] {
253
+ color: var(--colorsComponentsMenuYang100);
254
+ }
245
255
  }
246
- }
247
- `}
256
+ `}
248
257
  `}
249
258
  `;
250
259
  export default StyledMenuItemWrapper;
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import React, { useContext } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import MenuContext from "../menu.context";
6
+ import MenuItem from "../menu-item";
6
7
  import SubmenuContext from "../__internal__/submenu/submenu.context";
7
8
  import StyledScrollableBlock from "./scrollable-block.style";
8
9
  import Box from "../../box";
@@ -11,6 +12,8 @@ const ScrollableBlock = ({
11
12
  children,
12
13
  height,
13
14
  variant = "default",
15
+ parent,
16
+ parentVariant,
14
17
  ...rest
15
18
  }) => {
16
19
  const menuContext = useContext(MenuContext);
@@ -29,14 +32,19 @@ const ScrollableBlock = ({
29
32
  return /*#__PURE__*/React.createElement(StyledScrollableBlock, _extends({
30
33
  "data-component": "submenu-scrollable-block",
31
34
  menuType: menuContext.menuType,
32
- variant: variant,
33
- role: "presentation"
34
- }, rest), /*#__PURE__*/React.createElement(Box, {
35
+ variant: variant
36
+ }, rest), parent && /*#__PURE__*/React.createElement(MenuItem, {
37
+ overrideColor: true,
38
+ variant: parentVariant,
39
+ as: "div",
40
+ href: "#"
41
+ }, parent), /*#__PURE__*/React.createElement(Box, {
35
42
  overflowY: "scroll",
36
43
  scrollVariant: scrollVariants[menuContext.menuType],
37
44
  height: height,
38
45
  p: 0,
39
- role: "presentation"
46
+ as: "ul",
47
+ role: "list"
40
48
  }, React.Children.map(children, (child, index) => {
41
49
  let isFocused = false;
42
50
  const blockItemFocused = focusIndex >= blockIndex;
@@ -62,6 +70,14 @@ ScrollableBlock.propTypes = {
62
70
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
63
71
 
64
72
  /** set the colour variant for a menuType */
65
- variant: PropTypes.oneOf(["default", "alternate"])
73
+ variant: PropTypes.oneOf(["default", "alternate"]),
74
+
75
+ /** the element, if any, displayed at the top of the block to be its semantic "parent",
76
+ * but not part of the scrollable section
77
+ */
78
+ parent: PropTypes.node,
79
+
80
+ /** the colour variant for the parent element, if different from the variant of the block */
81
+ parentVariant: PropTypes.oneOf(["default", "alternate"])
66
82
  };
67
83
  export default ScrollableBlock;
@@ -7,6 +7,12 @@ export interface ScrollableBlockProps {
7
7
  height?: string | number;
8
8
  /** set the colour variant for a menuType */
9
9
  variant?: "default" | "alternate";
10
+ /** the element, if any, displayed at the top of the block to be its semantic "parent",
11
+ * but not part of the scrollable section
12
+ */
13
+ parent?: React.ReactElement;
14
+ /** the colour variant for the parent element, if different from the variant of the block */
15
+ parentVariant?: "default" | "alternate";
10
16
  }
11
17
 
12
18
  declare function ScrollableBlock(props: ScrollableBlockProps): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import StyledMenuItemWrapper from "../menu-item/menu-item.style";
3
3
  import menuConfigVariants from "../menu.config";
4
- const StyledScrollableBlock = styled.div`
4
+ const StyledScrollableBlock = styled.li`
5
5
  ${({
6
6
  menuType,
7
7
  variant
@@ -0,0 +1,6 @@
1
+ export const StyledTabsHeaderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export const StyledTabsHeaderList: import("styled-components").StyledComponent<"div", any, {
3
+ alternateStyling: any;
4
+ isInSidebar: any;
5
+ position: any;
6
+ }, never>;
@@ -0,0 +1,2 @@
1
+ export default StyledTab;
2
+ declare const StyledTab: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,2 @@
1
+ export default StyledTabs;
2
+ declare const StyledTabs: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1 @@
1
+ export { default } from "./sticky-footer.component";
@@ -0,0 +1,15 @@
1
+ export default StickyFooter;
2
+ declare function StickyFooter({ children, containerRef, disableSticky, ...rest }: {
3
+ [x: string]: any;
4
+ children: any;
5
+ containerRef: any;
6
+ disableSticky: any;
7
+ }): JSX.Element;
8
+ declare namespace StickyFooter {
9
+ namespace propTypes {
10
+ const children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
11
+ const containerRef: PropTypes.Validator<any>;
12
+ const disableSticky: PropTypes.Requireable<boolean>;
13
+ }
14
+ }
15
+ import PropTypes from "prop-types";
@@ -0,0 +1,2 @@
1
+ export default StyledStickyFooter;
2
+ declare const StyledStickyFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,2 +1,2 @@
1
+ declare const setupResizeObserverMock: () => void;
1
2
  export default setupResizeObserverMock;
2
- declare function setupResizeObserverMock(): void;
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
 
8
8
  const setupResizeObserverMock = () => {
9
- if (!global.window) {
9
+ if (!window) {
10
10
  return;
11
11
  }
12
12
 
13
- global.window.ResizeObserver = global.window.ResizeObserver || jest.fn().mockImplementation(() => ({
13
+ window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({
14
14
  disconnect: jest.fn(),
15
15
  observe: jest.fn(),
16
16
  unobserve: jest.fn()
@@ -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;