carbon-react 106.6.3 → 106.6.6
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.
- package/esm/components/button/button.style.js +1 -6
- package/esm/components/button-bar/button-bar-test.stories.js +122 -0
- package/esm/components/button-bar/button-bar.component.d.ts +12 -15
- package/esm/components/button-bar/button-bar.component.js +331 -33
- package/esm/components/button-bar/button-bar.config.d.ts +2 -2
- package/esm/components/button-bar/button-bar.style.d.ts +4 -4
- package/esm/components/button-bar/button-bar.style.js +18 -33
- package/esm/components/button-bar/index.d.ts +2 -1
- package/esm/components/heading/heading.component.d.ts +7 -47
- package/esm/components/heading/heading.component.js +1 -48
- package/esm/components/link/link.component.js +1 -5
- package/esm/components/menu/__internal__/spec-helper/index.js +2 -1
- package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/esm/components/menu/menu.component.js +2 -1
- package/esm/components/menu/scrollable-block/scrollable-block.component.js +4 -2
- package/lib/components/button/button.style.js +1 -6
- package/lib/components/button-bar/button-bar-test.stories.js +145 -0
- package/lib/components/button-bar/button-bar.component.d.ts +12 -15
- package/lib/components/button-bar/button-bar.component.js +336 -35
- package/lib/components/button-bar/button-bar.config.d.ts +2 -2
- package/lib/components/button-bar/button-bar.style.d.ts +4 -4
- package/lib/components/button-bar/button-bar.style.js +18 -35
- package/lib/components/button-bar/index.d.ts +2 -1
- package/lib/components/heading/heading.component.d.ts +7 -47
- package/lib/components/heading/heading.component.js +1 -48
- package/lib/components/link/link.component.js +1 -5
- package/lib/components/menu/__internal__/spec-helper/index.js +2 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/lib/components/menu/menu.component.js +2 -1
- package/lib/components/menu/scrollable-block/scrollable-block.component.js +4 -2
- package/package.json +1 -1
- package/esm/components/button-bar/button-bar.d.ts +0 -24
- package/lib/components/button-bar/button-bar.d.ts +0 -24
|
@@ -56,14 +56,7 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
56
56
|
|
|
57
57
|
_createClass(Heading, [{
|
|
58
58
|
key: "help",
|
|
59
|
-
get:
|
|
60
|
-
/**
|
|
61
|
-
* Returns the help component.
|
|
62
|
-
*
|
|
63
|
-
* @method help
|
|
64
|
-
* @return {Object} JSX
|
|
65
|
-
*/
|
|
66
|
-
function () {
|
|
59
|
+
get: function () {
|
|
67
60
|
if (!this.props.help && !this.props.helpLink) {
|
|
68
61
|
return null;
|
|
69
62
|
}
|
|
@@ -75,13 +68,6 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
75
68
|
ariaLabel: this.props.helpAriaLabel
|
|
76
69
|
}, this.props.help);
|
|
77
70
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns the back button.
|
|
80
|
-
*
|
|
81
|
-
* @method back
|
|
82
|
-
* @return {Object} JSX
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
71
|
}, {
|
|
86
72
|
key: "back",
|
|
87
73
|
get: function () {
|
|
@@ -110,13 +96,6 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
110
96
|
divider: this.props.divider
|
|
111
97
|
}));
|
|
112
98
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Returns the subheader.
|
|
115
|
-
*
|
|
116
|
-
* @method subheader
|
|
117
|
-
* @return {Object} JSX
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
99
|
}, {
|
|
121
100
|
key: "subheader",
|
|
122
101
|
get: function () {
|
|
@@ -131,25 +110,11 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
131
110
|
hasSeparator: this.props.separator
|
|
132
111
|
}, this.props.subheader);
|
|
133
112
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Returns the separator if enabled and needed.
|
|
136
|
-
*
|
|
137
|
-
* @method separator
|
|
138
|
-
* @return {Object} JSX
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
113
|
}, {
|
|
142
114
|
key: "separator",
|
|
143
115
|
get: function () {
|
|
144
116
|
return this.props.separator ? /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, null) : null;
|
|
145
117
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Returns the separator if enabled and needed.
|
|
148
|
-
*
|
|
149
|
-
* @method divider
|
|
150
|
-
* @return {Object} JSX
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
118
|
}, {
|
|
154
119
|
key: "divider",
|
|
155
120
|
get: function () {
|
|
@@ -157,13 +122,6 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
157
122
|
"data-element": "divider"
|
|
158
123
|
}) : null;
|
|
159
124
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Returns pills if provided
|
|
162
|
-
*
|
|
163
|
-
* @method pills
|
|
164
|
-
* @return {Object} JSX
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
125
|
}, {
|
|
168
126
|
key: "pills",
|
|
169
127
|
get: function () {
|
|
@@ -171,11 +129,6 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
171
129
|
"data-element": "pills"
|
|
172
130
|
}, this.props.pills) : null;
|
|
173
131
|
}
|
|
174
|
-
/**
|
|
175
|
-
* @method render
|
|
176
|
-
* @return {Object} JSX
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
132
|
}, {
|
|
180
133
|
key: "render",
|
|
181
134
|
value: function render() {
|
|
@@ -106,11 +106,7 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
106
106
|
type = "button";
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(type,
|
|
110
|
-
...(type === "button" && {
|
|
111
|
-
role: "link"
|
|
112
|
-
})
|
|
113
|
-
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLinkIcon(), /*#__PURE__*/_react.default.createElement(_link.StyledContent, null, isSkipLink ? l.link.skipLinkLabel() : children), renderLinkIcon("right")));
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(type, componentProps, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLinkIcon(), /*#__PURE__*/_react.default.createElement(_link.StyledContent, null, isSkipLink ? l.link.skipLinkLabel() : children), renderLinkIcon("right")));
|
|
114
110
|
};
|
|
115
111
|
|
|
116
112
|
return /*#__PURE__*/_react.default.createElement(_link.StyledLink, _extends({
|
|
@@ -20,7 +20,8 @@ const events = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const openSubmenu = wrapper => {
|
|
23
|
-
const
|
|
23
|
+
const menuWrapper = wrapper.find('[data-component="submenu-wrapper"]');
|
|
24
|
+
const menuItem = menuWrapper.exists("a") ? menuWrapper.find("a") : menuWrapper.find("button");
|
|
24
25
|
menuItem.getDOMNode().focus();
|
|
25
26
|
(0, _testUtils.act)(() => {
|
|
26
27
|
wrapper.find(_menuItem.default).at(0).props().onKeyDown(events.space);
|
|
@@ -50,6 +50,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
50
50
|
asPassiveItem,
|
|
51
51
|
onSubmenuOpen,
|
|
52
52
|
onSubmenuClose,
|
|
53
|
+
onClick,
|
|
53
54
|
...rest
|
|
54
55
|
}, ref) => {
|
|
55
56
|
const [blockDoubleFocus, setBlockDoubleFocus] = (0, _react.useState)(false);
|
|
@@ -214,6 +215,17 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
214
215
|
closeSubmenu();
|
|
215
216
|
}
|
|
216
217
|
}, [closeSubmenu]);
|
|
218
|
+
|
|
219
|
+
const handleClick = event => {
|
|
220
|
+
if (clickToOpen) {
|
|
221
|
+
openSubmenu();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (onClick) {
|
|
225
|
+
onClick(event);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
217
229
|
(0, _react.useEffect)(() => {
|
|
218
230
|
if (characterString !== "") {
|
|
219
231
|
const nextIndex = (0, _keyboardNavigation.characterNavigation)(characterString, _react.default.Children.toArray(formattedChildren), submenuFocusIndex);
|
|
@@ -267,7 +279,6 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
267
279
|
"data-component": "submenu-wrapper",
|
|
268
280
|
onMouseOver: !clickToOpen ? () => openSubmenu() : undefined,
|
|
269
281
|
onMouseLeave: () => closeSubmenu(),
|
|
270
|
-
onClick: clickToOpen ? () => openSubmenu() : undefined,
|
|
271
282
|
ref: submenuRef,
|
|
272
283
|
isSubmenuOpen: submenuOpen
|
|
273
284
|
}, /*#__PURE__*/_react.default.createElement(_menuItem.default, _extends({}, rest, {
|
|
@@ -282,14 +293,17 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
282
293
|
hasSubmenu: true,
|
|
283
294
|
showDropdownArrow: showDropdownArrow,
|
|
284
295
|
onKeyDown: handleKeyDown,
|
|
296
|
+
onClick: handleClick,
|
|
285
297
|
clickToOpen: clickToOpen,
|
|
286
298
|
href: href,
|
|
287
|
-
maxWidth: maxWidth
|
|
299
|
+
maxWidth: maxWidth,
|
|
300
|
+
"aria-expanded": submenuOpen
|
|
288
301
|
}), title), submenuOpen && /*#__PURE__*/_react.default.createElement(_submenu.StyledSubmenu, {
|
|
289
302
|
"data-component": "submenu",
|
|
290
303
|
submenuDirection: submenuDirection,
|
|
291
304
|
variant: variant,
|
|
292
|
-
menuType: menuContext.menuType
|
|
305
|
+
menuType: menuContext.menuType,
|
|
306
|
+
role: "list"
|
|
293
307
|
}, _react.default.Children.map(children, (child, index) => /*#__PURE__*/_react.default.createElement(_submenu2.default.Provider, {
|
|
294
308
|
value: {
|
|
295
309
|
isFocused: !blockDoubleFocus && submenuFocusIndex === index,
|
|
@@ -347,7 +361,10 @@ Submenu.propTypes = {
|
|
|
347
361
|
onSubmenuOpen: _propTypes.default.func,
|
|
348
362
|
|
|
349
363
|
/** Callback triggered when submenu closes. Only valid with submenu prop */
|
|
350
|
-
onSubmenuClose: _propTypes.default.func
|
|
364
|
+
onSubmenuClose: _propTypes.default.func,
|
|
365
|
+
|
|
366
|
+
/** Callback triggered when the top-level menu item is clicked */
|
|
367
|
+
onClick: _propTypes.default.func
|
|
351
368
|
};
|
|
352
369
|
var _default = Submenu;
|
|
353
370
|
exports.default = _default;
|
|
@@ -61,7 +61,8 @@ const Menu = ({
|
|
|
61
61
|
"data-component": "menu",
|
|
62
62
|
menuType: menuType
|
|
63
63
|
}, rest, {
|
|
64
|
-
ref: ref
|
|
64
|
+
ref: ref,
|
|
65
|
+
role: "list"
|
|
65
66
|
}), _react.default.Children.map(children, (child, index) => {
|
|
66
67
|
const isFocused = focusedItemIndex === index;
|
|
67
68
|
return /*#__PURE__*/_react.default.createElement(_menu2.default.Provider, {
|
|
@@ -47,12 +47,14 @@ const ScrollableBlock = ({
|
|
|
47
47
|
return /*#__PURE__*/_react.default.createElement(_scrollableBlock.default, _extends({
|
|
48
48
|
"data-component": "submenu-scrollable-block",
|
|
49
49
|
menuType: menuContext.menuType,
|
|
50
|
-
variant: variant
|
|
50
|
+
variant: variant,
|
|
51
|
+
role: "presentation"
|
|
51
52
|
}, rest), /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
52
53
|
overflowY: "scroll",
|
|
53
54
|
scrollVariant: scrollVariants[menuContext.menuType],
|
|
54
55
|
height: height,
|
|
55
|
-
p: 0
|
|
56
|
+
p: 0,
|
|
57
|
+
role: "presentation"
|
|
56
58
|
}, _react.default.Children.map(children, (child, index) => {
|
|
57
59
|
let isFocused = false;
|
|
58
60
|
const blockItemFocused = focusIndex >= blockIndex;
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Button from "components/button/button";
|
|
2
|
-
import IconButton from "components/icon-button";
|
|
3
|
-
import { SpaceProps } from "styled-system";
|
|
4
|
-
|
|
5
|
-
type ButtonBarChild =
|
|
6
|
-
| typeof Button
|
|
7
|
-
| typeof IconButton
|
|
8
|
-
| boolean
|
|
9
|
-
| null
|
|
10
|
-
| undefined;
|
|
11
|
-
|
|
12
|
-
export interface ButtonBarProps extends SpaceProps {
|
|
13
|
-
children: ButtonBarChild | ButtonBarChild[];
|
|
14
|
-
/** Apply fullWidth style to the button bar */
|
|
15
|
-
fullWidth?: boolean;
|
|
16
|
-
/** Defines an Icon position for buttons: "before" | "after" */
|
|
17
|
-
iconPosition?: "before" | "after";
|
|
18
|
-
/** Assigns a size to the buttons: "small" | "medium" | "large" */
|
|
19
|
-
size?: "small" | "medium" | "large";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function ButtonBar(props: ButtonBarProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default ButtonBar;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Button from "components/button/button";
|
|
2
|
-
import IconButton from "components/icon-button";
|
|
3
|
-
import { SpaceProps } from "styled-system";
|
|
4
|
-
|
|
5
|
-
type ButtonBarChild =
|
|
6
|
-
| typeof Button
|
|
7
|
-
| typeof IconButton
|
|
8
|
-
| boolean
|
|
9
|
-
| null
|
|
10
|
-
| undefined;
|
|
11
|
-
|
|
12
|
-
export interface ButtonBarProps extends SpaceProps {
|
|
13
|
-
children: ButtonBarChild | ButtonBarChild[];
|
|
14
|
-
/** Apply fullWidth style to the button bar */
|
|
15
|
-
fullWidth?: boolean;
|
|
16
|
-
/** Defines an Icon position for buttons: "before" | "after" */
|
|
17
|
-
iconPosition?: "before" | "after";
|
|
18
|
-
/** Assigns a size to the buttons: "small" | "medium" | "large" */
|
|
19
|
-
size?: "small" | "medium" | "large";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare function ButtonBar(props: ButtonBarProps): JSX.Element;
|
|
23
|
-
|
|
24
|
-
export default ButtonBar;
|