carbon-react 115.0.0 → 115.0.2
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/action-popover/action-popover-item/action-popover-item.component.js +2 -6
- package/esm/components/action-popover/action-popover.component.js +9 -0
- package/esm/components/multi-action-button/multi-action-button.component.d.ts +1 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +13 -3
- package/esm/components/pages/pages.component.d.ts +0 -2
- package/esm/components/pages/pages.component.js +0 -1
- package/esm/components/split-button/split-button.component.js +2 -2
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -6
- package/lib/components/action-popover/action-popover.component.js +10 -0
- package/lib/components/multi-action-button/multi-action-button.component.d.ts +1 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +13 -3
- package/lib/components/pages/pages.component.d.ts +0 -2
- package/lib/components/pages/pages.component.js +0 -1
- package/lib/components/split-button/split-button.component.js +2 -2
- package/package.json +1 -1
|
@@ -129,11 +129,7 @@ const ActionPopoverItem = ({
|
|
|
129
129
|
}
|
|
130
130
|
}, [disabled, focusButton, onClickProp, setOpenPopover]);
|
|
131
131
|
const onKeyDown = useCallback(e => {
|
|
132
|
-
if (Events.
|
|
133
|
-
e.stopPropagation();
|
|
134
|
-
setOpenPopover(false);
|
|
135
|
-
focusButton();
|
|
136
|
-
} else if (Events.isSpaceKey(e)) {
|
|
132
|
+
if (Events.isSpaceKey(e)) {
|
|
137
133
|
e.preventDefault();
|
|
138
134
|
e.stopPropagation();
|
|
139
135
|
} else if (!disabled) {
|
|
@@ -182,7 +178,7 @@ const ActionPopoverItem = ({
|
|
|
182
178
|
} else if (Events.isEnterKey(e)) {
|
|
183
179
|
e.stopPropagation();
|
|
184
180
|
}
|
|
185
|
-
}, [disabled, download,
|
|
181
|
+
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
186
182
|
const itemSubmenuProps = { ...(!disabled && {
|
|
187
183
|
onMouseEnter: e => {
|
|
188
184
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
@@ -12,6 +12,7 @@ import ActionPopoverMenu from "./action-popover-menu/action-popover-menu.compone
|
|
|
12
12
|
import ActionPopoverItem from "./action-popover-item/action-popover-item.component";
|
|
13
13
|
import ActionPopoverDivider from "./action-popover-divider/action-popover-divider.component";
|
|
14
14
|
import ActionPopoverContext from "./action-popover-context";
|
|
15
|
+
import useModalManager from "../../hooks/__internal__/useModalManager";
|
|
15
16
|
|
|
16
17
|
const onOpenDefault = () => {};
|
|
17
18
|
|
|
@@ -107,6 +108,14 @@ const ActionPopover = ({
|
|
|
107
108
|
setOpen(true);
|
|
108
109
|
}
|
|
109
110
|
}, [itemCount, setOpen]);
|
|
111
|
+
const handleEscapeKey = useCallback(e => {
|
|
112
|
+
/* istanbul ignore else */
|
|
113
|
+
if (Events.isEscKey(e)) {
|
|
114
|
+
setOpen(false);
|
|
115
|
+
focusButton();
|
|
116
|
+
}
|
|
117
|
+
}, [setOpen, focusButton]);
|
|
118
|
+
useModalManager(isOpen, handleEscapeKey, buttonRef);
|
|
110
119
|
useEffect(() => {
|
|
111
120
|
const handler = ({
|
|
112
121
|
target
|
|
@@ -7,5 +7,5 @@ export interface MultiActionButtonProps extends WidthProps, Omit<SplitButtonProp
|
|
|
7
7
|
/** Second text child, renders under main text, only when size is "large" */
|
|
8
8
|
subtext?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare const MultiActionButton: ({ align, disabled, buttonType, size, children, text, subtext, width, "data-element": dataElement, "data-role": dataRole, ...rest }: MultiActionButtonProps) => JSX.Element;
|
|
10
|
+
export declare const MultiActionButton: ({ align, disabled, buttonType, size, children, text, subtext, width, onClick, "data-element": dataElement, "data-role": dataRole, ...rest }: MultiActionButtonProps) => JSX.Element;
|
|
11
11
|
export default MultiActionButton;
|
|
@@ -19,6 +19,7 @@ const MultiActionButton = ({
|
|
|
19
19
|
text,
|
|
20
20
|
subtext,
|
|
21
21
|
width,
|
|
22
|
+
onClick,
|
|
22
23
|
"data-element": dataElement,
|
|
23
24
|
"data-role": dataRole,
|
|
24
25
|
...rest
|
|
@@ -85,11 +86,23 @@ const MultiActionButton = ({
|
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
|
|
89
|
+
const handleInsideClick = useClickAwayListener(hideButtons);
|
|
90
|
+
|
|
91
|
+
const handleClick = ev => {
|
|
92
|
+
showButtons();
|
|
93
|
+
handleInsideClick();
|
|
94
|
+
|
|
95
|
+
if (onClick) {
|
|
96
|
+
onClick(ev);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
88
100
|
const mainButtonProps = {
|
|
89
101
|
disabled,
|
|
90
102
|
displayed: showAdditionalButtons,
|
|
91
103
|
onTouchStart: showButtons,
|
|
92
104
|
onKeyDown: handleMainButtonKeyDown,
|
|
105
|
+
onClick: handleClick,
|
|
93
106
|
buttonType,
|
|
94
107
|
size,
|
|
95
108
|
subtext,
|
|
@@ -112,16 +125,13 @@ const MultiActionButton = ({
|
|
|
112
125
|
onKeyDown: handleKeyDown
|
|
113
126
|
}, childrenWithProps()));
|
|
114
127
|
|
|
115
|
-
const handleClick = useClickAwayListener(hideButtons);
|
|
116
128
|
const hideButtonsIfTriggerNotFocused = useCallback(() => {
|
|
117
129
|
if (buttonRef.current === document.activeElement) return;
|
|
118
130
|
setShowAdditionalButtons(false);
|
|
119
131
|
}, []);
|
|
120
132
|
const marginProps = filterStyledSystemMarginProps(rest);
|
|
121
133
|
return /*#__PURE__*/React.createElement(StyledMultiActionButton, _extends({
|
|
122
|
-
"aria-haspopup": "true",
|
|
123
134
|
onMouseLeave: hideButtonsIfTriggerNotFocused,
|
|
124
|
-
onClick: handleClick,
|
|
125
135
|
ref: ref,
|
|
126
136
|
"data-component": "multi-action-button",
|
|
127
137
|
"data-element": dataElement,
|
|
@@ -2,8 +2,6 @@ import React from "react";
|
|
|
2
2
|
import Page from "./page";
|
|
3
3
|
import { ThemeObject } from "../../style/themes/base";
|
|
4
4
|
export interface PagesProps {
|
|
5
|
-
/** [legacy] Custom className */
|
|
6
|
-
className?: string;
|
|
7
5
|
/** The selected tab on page load */
|
|
8
6
|
initialpageIndex?: number | string;
|
|
9
7
|
/** The current page's index */
|
|
@@ -86,7 +86,6 @@ const Pages = ({
|
|
|
86
86
|
|
|
87
87
|
Pages.propTypes = {
|
|
88
88
|
"children": PropTypes.node,
|
|
89
|
-
"className": PropTypes.string,
|
|
90
89
|
"initialpageIndex": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
91
90
|
"pageIndex": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
92
91
|
"theme": PropTypes.shape({
|
|
@@ -95,7 +95,8 @@ const SplitButton = ({
|
|
|
95
95
|
buttonType,
|
|
96
96
|
size,
|
|
97
97
|
...(!disabled && {
|
|
98
|
-
onMouseEnter: showButtons
|
|
98
|
+
onMouseEnter: showButtons,
|
|
99
|
+
onClick: showButtons
|
|
99
100
|
})
|
|
100
101
|
};
|
|
101
102
|
|
|
@@ -175,7 +176,6 @@ const SplitButton = ({
|
|
|
175
176
|
const handleClick = useClickAwayListener(hideButtons);
|
|
176
177
|
const marginProps = filterStyledSystemMarginProps(rest);
|
|
177
178
|
return /*#__PURE__*/React.createElement(StyledSplitButton, _extends({
|
|
178
|
-
"aria-haspopup": "true",
|
|
179
179
|
onMouseLeave: hideButtonsIfTriggerNotFocused,
|
|
180
180
|
onClick: handleClick,
|
|
181
181
|
ref: splitButtonNode
|
|
@@ -151,11 +151,7 @@ const ActionPopoverItem = ({
|
|
|
151
151
|
}
|
|
152
152
|
}, [disabled, focusButton, onClickProp, setOpenPopover]);
|
|
153
153
|
const onKeyDown = (0, _react.useCallback)(e => {
|
|
154
|
-
if (_events.default.
|
|
155
|
-
e.stopPropagation();
|
|
156
|
-
setOpenPopover(false);
|
|
157
|
-
focusButton();
|
|
158
|
-
} else if (_events.default.isSpaceKey(e)) {
|
|
154
|
+
if (_events.default.isSpaceKey(e)) {
|
|
159
155
|
e.preventDefault();
|
|
160
156
|
e.stopPropagation();
|
|
161
157
|
} else if (!disabled) {
|
|
@@ -204,7 +200,7 @@ const ActionPopoverItem = ({
|
|
|
204
200
|
} else if (_events.default.isEnterKey(e)) {
|
|
205
201
|
e.stopPropagation();
|
|
206
202
|
}
|
|
207
|
-
}, [disabled, download,
|
|
203
|
+
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
208
204
|
const itemSubmenuProps = { ...(!disabled && {
|
|
209
205
|
onMouseEnter: e => {
|
|
210
206
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
@@ -29,6 +29,8 @@ var _actionPopoverDivider = _interopRequireDefault(require("./action-popover-div
|
|
|
29
29
|
|
|
30
30
|
var _actionPopoverContext = _interopRequireDefault(require("./action-popover-context"));
|
|
31
31
|
|
|
32
|
+
var _useModalManager = _interopRequireDefault(require("../../hooks/__internal__/useModalManager"));
|
|
33
|
+
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
34
36
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -132,6 +134,14 @@ const ActionPopover = ({
|
|
|
132
134
|
setOpen(true);
|
|
133
135
|
}
|
|
134
136
|
}, [itemCount, setOpen]);
|
|
137
|
+
const handleEscapeKey = (0, _react.useCallback)(e => {
|
|
138
|
+
/* istanbul ignore else */
|
|
139
|
+
if (_events.default.isEscKey(e)) {
|
|
140
|
+
setOpen(false);
|
|
141
|
+
focusButton();
|
|
142
|
+
}
|
|
143
|
+
}, [setOpen, focusButton]);
|
|
144
|
+
(0, _useModalManager.default)(isOpen, handleEscapeKey, buttonRef);
|
|
135
145
|
(0, _react.useEffect)(() => {
|
|
136
146
|
const handler = ({
|
|
137
147
|
target
|
|
@@ -7,5 +7,5 @@ export interface MultiActionButtonProps extends WidthProps, Omit<SplitButtonProp
|
|
|
7
7
|
/** Second text child, renders under main text, only when size is "large" */
|
|
8
8
|
subtext?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare const MultiActionButton: ({ align, disabled, buttonType, size, children, text, subtext, width, "data-element": dataElement, "data-role": dataRole, ...rest }: MultiActionButtonProps) => JSX.Element;
|
|
10
|
+
export declare const MultiActionButton: ({ align, disabled, buttonType, size, children, text, subtext, width, onClick, "data-element": dataElement, "data-role": dataRole, ...rest }: MultiActionButtonProps) => JSX.Element;
|
|
11
11
|
export default MultiActionButton;
|
|
@@ -40,6 +40,7 @@ const MultiActionButton = ({
|
|
|
40
40
|
text,
|
|
41
41
|
subtext,
|
|
42
42
|
width,
|
|
43
|
+
onClick,
|
|
43
44
|
"data-element": dataElement,
|
|
44
45
|
"data-role": dataRole,
|
|
45
46
|
...rest
|
|
@@ -106,11 +107,23 @@ const MultiActionButton = ({
|
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
109
|
|
|
110
|
+
const handleInsideClick = (0, _useClickAwayListener.default)(hideButtons);
|
|
111
|
+
|
|
112
|
+
const handleClick = ev => {
|
|
113
|
+
showButtons();
|
|
114
|
+
handleInsideClick();
|
|
115
|
+
|
|
116
|
+
if (onClick) {
|
|
117
|
+
onClick(ev);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
109
121
|
const mainButtonProps = {
|
|
110
122
|
disabled,
|
|
111
123
|
displayed: showAdditionalButtons,
|
|
112
124
|
onTouchStart: showButtons,
|
|
113
125
|
onKeyDown: handleMainButtonKeyDown,
|
|
126
|
+
onClick: handleClick,
|
|
114
127
|
buttonType,
|
|
115
128
|
size,
|
|
116
129
|
subtext,
|
|
@@ -133,16 +146,13 @@ const MultiActionButton = ({
|
|
|
133
146
|
onKeyDown: handleKeyDown
|
|
134
147
|
}, childrenWithProps()));
|
|
135
148
|
|
|
136
|
-
const handleClick = (0, _useClickAwayListener.default)(hideButtons);
|
|
137
149
|
const hideButtonsIfTriggerNotFocused = (0, _react.useCallback)(() => {
|
|
138
150
|
if (buttonRef.current === document.activeElement) return;
|
|
139
151
|
setShowAdditionalButtons(false);
|
|
140
152
|
}, []);
|
|
141
153
|
const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
|
|
142
154
|
return /*#__PURE__*/_react.default.createElement(_multiActionButton.StyledMultiActionButton, _extends({
|
|
143
|
-
"aria-haspopup": "true",
|
|
144
155
|
onMouseLeave: hideButtonsIfTriggerNotFocused,
|
|
145
|
-
onClick: handleClick,
|
|
146
156
|
ref: ref,
|
|
147
157
|
"data-component": "multi-action-button",
|
|
148
158
|
"data-element": dataElement,
|
|
@@ -2,8 +2,6 @@ import React from "react";
|
|
|
2
2
|
import Page from "./page";
|
|
3
3
|
import { ThemeObject } from "../../style/themes/base";
|
|
4
4
|
export interface PagesProps {
|
|
5
|
-
/** [legacy] Custom className */
|
|
6
|
-
className?: string;
|
|
7
5
|
/** The selected tab on page load */
|
|
8
6
|
initialpageIndex?: number | string;
|
|
9
7
|
/** The current page's index */
|
|
@@ -113,7 +113,6 @@ const Pages = ({
|
|
|
113
113
|
|
|
114
114
|
Pages.propTypes = {
|
|
115
115
|
"children": _propTypes.default.node,
|
|
116
|
-
"className": _propTypes.default.string,
|
|
117
116
|
"initialpageIndex": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
118
117
|
"pageIndex": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
119
118
|
"theme": _propTypes.default.shape({
|
|
@@ -124,7 +124,8 @@ const SplitButton = ({
|
|
|
124
124
|
buttonType,
|
|
125
125
|
size,
|
|
126
126
|
...(!disabled && {
|
|
127
|
-
onMouseEnter: showButtons
|
|
127
|
+
onMouseEnter: showButtons,
|
|
128
|
+
onClick: showButtons
|
|
128
129
|
})
|
|
129
130
|
};
|
|
130
131
|
|
|
@@ -204,7 +205,6 @@ const SplitButton = ({
|
|
|
204
205
|
const handleClick = (0, _useClickAwayListener.default)(hideButtons);
|
|
205
206
|
const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
|
|
206
207
|
return /*#__PURE__*/_react.default.createElement(_splitButton.default, _extends({
|
|
207
|
-
"aria-haspopup": "true",
|
|
208
208
|
onMouseLeave: hideButtonsIfTriggerNotFocused,
|
|
209
209
|
onClick: handleClick,
|
|
210
210
|
ref: splitButtonNode
|