carbon-react 118.4.0 → 118.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.
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +30 -24
- package/esm/components/action-popover/action-popover.style.d.ts +2 -1
- package/esm/components/action-popover/action-popover.style.js +9 -2
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +29 -23
- package/lib/components/action-popover/action-popover.style.d.ts +2 -1
- package/lib/components/action-popover/action-popover.style.js +10 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState, useContext } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import invariant from "invariant";
|
|
6
|
-
import { MenuItemIcon, SubMenuItemIcon, StyledMenuItem } from "../action-popover.style";
|
|
6
|
+
import { MenuItemIcon, SubMenuItemIcon, StyledMenuItem, StyledMenuItemWrapper } from "../action-popover.style";
|
|
7
7
|
import Events from "../../../__internal__/utils/helpers/events";
|
|
8
8
|
import createGuid from "../../../__internal__/utils/helpers/guid";
|
|
9
9
|
import ActionPopoverContext from "../action-popover-context";
|
|
@@ -172,7 +172,8 @@ const ActionPopoverItem = ({
|
|
|
172
172
|
(_ref$current5 = ref.current) === null || _ref$current5 === void 0 ? void 0 : _ref$current5.click();
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
e.preventDefault();
|
|
175
|
+
e.preventDefault(); // this type assertion should be safe as the onclick handler is designed to catch events propagating from the inner buttons
|
|
176
|
+
|
|
176
177
|
onClick(e);
|
|
177
178
|
}
|
|
178
179
|
} else if (Events.isEnterKey(e)) {
|
|
@@ -180,6 +181,21 @@ const ActionPopoverItem = ({
|
|
|
180
181
|
}
|
|
181
182
|
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
182
183
|
const itemSubmenuProps = { ...(!disabled && {
|
|
184
|
+
onClick: e => {
|
|
185
|
+
var _ref$current6;
|
|
186
|
+
|
|
187
|
+
setOpen(true);
|
|
188
|
+
(_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.focus();
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
e.stopPropagation();
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
"aria-haspopup": "true",
|
|
194
|
+
"aria-label": l.actionPopover.ariaLabel(),
|
|
195
|
+
"aria-controls": `ActionPopoverMenu_${guid}`,
|
|
196
|
+
"aria-expanded": isOpen
|
|
197
|
+
};
|
|
198
|
+
const wrapperDivProps = { ...(!disabled && {
|
|
183
199
|
onMouseEnter: e => {
|
|
184
200
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
185
201
|
setFocusIndex(-1);
|
|
@@ -194,20 +210,8 @@ const ActionPopoverItem = ({
|
|
|
194
210
|
setOpen(false);
|
|
195
211
|
}, INTERVAL);
|
|
196
212
|
e.stopPropagation();
|
|
197
|
-
},
|
|
198
|
-
onClick: e => {
|
|
199
|
-
var _ref$current6;
|
|
200
|
-
|
|
201
|
-
setOpen(true);
|
|
202
|
-
(_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.focus();
|
|
203
|
-
e.preventDefault();
|
|
204
|
-
e.stopPropagation();
|
|
205
213
|
}
|
|
206
|
-
})
|
|
207
|
-
"aria-haspopup": "true",
|
|
208
|
-
"aria-label": l.actionPopover.ariaLabel(),
|
|
209
|
-
"aria-controls": `ActionPopoverMenu_${guid}`,
|
|
210
|
-
"aria-expanded": isOpen
|
|
214
|
+
})
|
|
211
215
|
};
|
|
212
216
|
|
|
213
217
|
const renderMenuItemIcon = () => {
|
|
@@ -217,13 +221,15 @@ const ActionPopoverItem = ({
|
|
|
217
221
|
});
|
|
218
222
|
};
|
|
219
223
|
|
|
220
|
-
return /*#__PURE__*/React.createElement(
|
|
224
|
+
return /*#__PURE__*/React.createElement(StyledMenuItemWrapper, submenu && wrapperDivProps, /*#__PURE__*/React.createElement("div", {
|
|
225
|
+
onKeyDown: onKeyDown,
|
|
226
|
+
role: "presentation"
|
|
227
|
+
}, /*#__PURE__*/React.createElement(StyledMenuItem, _extends({}, rest, {
|
|
221
228
|
ref: ref,
|
|
222
229
|
onClick: onClick,
|
|
223
|
-
onKeyDown: onKeyDown,
|
|
224
230
|
type: "button",
|
|
225
|
-
tabIndex: 0,
|
|
226
231
|
role: "menuitem",
|
|
232
|
+
tabIndex: 0,
|
|
227
233
|
isDisabled: disabled,
|
|
228
234
|
horizontalAlignment: horizontalAlignment
|
|
229
235
|
}, disabled && {
|
|
@@ -232,7 +238,11 @@ const ActionPopoverItem = ({
|
|
|
232
238
|
as: "a",
|
|
233
239
|
download,
|
|
234
240
|
href
|
|
235
|
-
}, submenu && itemSubmenuProps),
|
|
241
|
+
}, submenu && itemSubmenuProps), submenu && checkRef(ref) && isLeftAligned ? /*#__PURE__*/React.createElement(SubMenuItemIcon, {
|
|
242
|
+
type: "chevron_left"
|
|
243
|
+
}) : null, horizontalAlignment === "left" ? renderMenuItemIcon() : null, children, horizontalAlignment === "right" ? renderMenuItemIcon() : null, submenu && checkRef(ref) && !isLeftAligned ? /*#__PURE__*/React.createElement(SubMenuItemIcon, {
|
|
244
|
+
type: "chevron_right"
|
|
245
|
+
}) : null), /*#__PURE__*/React.isValidElement(submenu) ? /*#__PURE__*/React.cloneElement(submenu, {
|
|
236
246
|
parentID: `ActionPopoverItem_${guid}`,
|
|
237
247
|
menuID: `ActionPopoverMenu_${guid}`,
|
|
238
248
|
"data-element": "action-popover-submenu",
|
|
@@ -242,11 +252,7 @@ const ActionPopoverItem = ({
|
|
|
242
252
|
setOpen,
|
|
243
253
|
setFocusIndex,
|
|
244
254
|
focusIndex
|
|
245
|
-
}) : null
|
|
246
|
-
type: "chevron_left"
|
|
247
|
-
}) : null, horizontalAlignment === "left" ? renderMenuItemIcon() : null, children, horizontalAlignment === "right" ? renderMenuItemIcon() : null, submenu && checkRef(ref) && !isLeftAligned ? /*#__PURE__*/React.createElement(SubMenuItemIcon, {
|
|
248
|
-
type: "chevron_right"
|
|
249
|
-
}) : null);
|
|
255
|
+
}) : null));
|
|
250
256
|
};
|
|
251
257
|
|
|
252
258
|
ActionPopoverItem.propTypes = {
|
|
@@ -7,6 +7,7 @@ declare type StyledMenuItemProps = {
|
|
|
7
7
|
horizontalAlignment: "left" | "right";
|
|
8
8
|
};
|
|
9
9
|
declare const StyledMenuItem: import("styled-components").StyledComponent<"button", any, StyledMenuItemProps, never>;
|
|
10
|
+
declare const StyledMenuItemWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
11
|
declare const MenuItemDivider: import("styled-components").StyledComponent<"div", any, {
|
|
11
12
|
"data-element": string;
|
|
12
13
|
}, "data-element">;
|
|
@@ -16,4 +17,4 @@ declare const StyledButtonIcon: import("styled-components").StyledComponent<"div
|
|
|
16
17
|
declare const MenuItemIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
17
18
|
declare const SubMenuItemIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
18
19
|
declare const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
19
|
-
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, };
|
|
20
|
+
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, StyledMenuItemWrapper, };
|
|
@@ -16,7 +16,11 @@ const Menu = styled.div`
|
|
|
16
16
|
background-color: var(--colorsUtilityYang100);
|
|
17
17
|
z-index: ${({
|
|
18
18
|
theme
|
|
19
|
-
}) =>
|
|
19
|
+
}) => {
|
|
20
|
+
var _theme$zIndex;
|
|
21
|
+
|
|
22
|
+
return `${(_theme$zIndex = theme.zIndex) === null || _theme$zIndex === void 0 ? void 0 : _theme$zIndex.popover}`;
|
|
23
|
+
}}; // TODO (tokens): implement elevation tokens - FE-4437
|
|
20
24
|
`;
|
|
21
25
|
const StyledMenuItem = styled.button`
|
|
22
26
|
text-decoration: none;
|
|
@@ -69,6 +73,9 @@ const StyledMenuItem = styled.button`
|
|
|
69
73
|
}
|
|
70
74
|
`}
|
|
71
75
|
`;
|
|
76
|
+
const StyledMenuItemWrapper = styled.div`
|
|
77
|
+
position: relative;
|
|
78
|
+
`;
|
|
72
79
|
const MenuItemDivider = styled.div.attrs({
|
|
73
80
|
"data-element": "action-popover-divider"
|
|
74
81
|
})`
|
|
@@ -135,4 +142,4 @@ const MenuButtonOverrideWrapper = styled.div`
|
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
144
|
`;
|
|
138
|
-
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem };
|
|
145
|
+
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, StyledMenuItemWrapper };
|
|
@@ -194,7 +194,8 @@ const ActionPopoverItem = ({
|
|
|
194
194
|
(_ref$current5 = ref.current) === null || _ref$current5 === void 0 ? void 0 : _ref$current5.click();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
e.preventDefault();
|
|
197
|
+
e.preventDefault(); // this type assertion should be safe as the onclick handler is designed to catch events propagating from the inner buttons
|
|
198
|
+
|
|
198
199
|
onClick(e);
|
|
199
200
|
}
|
|
200
201
|
} else if (_events.default.isEnterKey(e)) {
|
|
@@ -202,6 +203,21 @@ const ActionPopoverItem = ({
|
|
|
202
203
|
}
|
|
203
204
|
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
204
205
|
const itemSubmenuProps = { ...(!disabled && {
|
|
206
|
+
onClick: e => {
|
|
207
|
+
var _ref$current6;
|
|
208
|
+
|
|
209
|
+
setOpen(true);
|
|
210
|
+
(_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.focus();
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
}
|
|
214
|
+
}),
|
|
215
|
+
"aria-haspopup": "true",
|
|
216
|
+
"aria-label": l.actionPopover.ariaLabel(),
|
|
217
|
+
"aria-controls": `ActionPopoverMenu_${guid}`,
|
|
218
|
+
"aria-expanded": isOpen
|
|
219
|
+
};
|
|
220
|
+
const wrapperDivProps = { ...(!disabled && {
|
|
205
221
|
onMouseEnter: e => {
|
|
206
222
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
207
223
|
setFocusIndex(-1);
|
|
@@ -216,20 +232,8 @@ const ActionPopoverItem = ({
|
|
|
216
232
|
setOpen(false);
|
|
217
233
|
}, INTERVAL);
|
|
218
234
|
e.stopPropagation();
|
|
219
|
-
},
|
|
220
|
-
onClick: e => {
|
|
221
|
-
var _ref$current6;
|
|
222
|
-
|
|
223
|
-
setOpen(true);
|
|
224
|
-
(_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.focus();
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
e.stopPropagation();
|
|
227
235
|
}
|
|
228
|
-
})
|
|
229
|
-
"aria-haspopup": "true",
|
|
230
|
-
"aria-label": l.actionPopover.ariaLabel(),
|
|
231
|
-
"aria-controls": `ActionPopoverMenu_${guid}`,
|
|
232
|
-
"aria-expanded": isOpen
|
|
236
|
+
})
|
|
233
237
|
};
|
|
234
238
|
|
|
235
239
|
const renderMenuItemIcon = () => {
|
|
@@ -239,13 +243,15 @@ const ActionPopoverItem = ({
|
|
|
239
243
|
});
|
|
240
244
|
};
|
|
241
245
|
|
|
242
|
-
return /*#__PURE__*/_react.default.createElement(_actionPopover.
|
|
246
|
+
return /*#__PURE__*/_react.default.createElement(_actionPopover.StyledMenuItemWrapper, submenu && wrapperDivProps, /*#__PURE__*/_react.default.createElement("div", {
|
|
247
|
+
onKeyDown: onKeyDown,
|
|
248
|
+
role: "presentation"
|
|
249
|
+
}, /*#__PURE__*/_react.default.createElement(_actionPopover.StyledMenuItem, _extends({}, rest, {
|
|
243
250
|
ref: ref,
|
|
244
251
|
onClick: onClick,
|
|
245
|
-
onKeyDown: onKeyDown,
|
|
246
252
|
type: "button",
|
|
247
|
-
tabIndex: 0,
|
|
248
253
|
role: "menuitem",
|
|
254
|
+
tabIndex: 0,
|
|
249
255
|
isDisabled: disabled,
|
|
250
256
|
horizontalAlignment: horizontalAlignment
|
|
251
257
|
}, disabled && {
|
|
@@ -254,7 +260,11 @@ const ActionPopoverItem = ({
|
|
|
254
260
|
as: "a",
|
|
255
261
|
download,
|
|
256
262
|
href
|
|
257
|
-
}, submenu && itemSubmenuProps),
|
|
263
|
+
}, submenu && itemSubmenuProps), submenu && checkRef(ref) && isLeftAligned ? /*#__PURE__*/_react.default.createElement(_actionPopover.SubMenuItemIcon, {
|
|
264
|
+
type: "chevron_left"
|
|
265
|
+
}) : null, horizontalAlignment === "left" ? renderMenuItemIcon() : null, children, horizontalAlignment === "right" ? renderMenuItemIcon() : null, submenu && checkRef(ref) && !isLeftAligned ? /*#__PURE__*/_react.default.createElement(_actionPopover.SubMenuItemIcon, {
|
|
266
|
+
type: "chevron_right"
|
|
267
|
+
}) : null), /*#__PURE__*/_react.default.isValidElement(submenu) ? /*#__PURE__*/_react.default.cloneElement(submenu, {
|
|
258
268
|
parentID: `ActionPopoverItem_${guid}`,
|
|
259
269
|
menuID: `ActionPopoverMenu_${guid}`,
|
|
260
270
|
"data-element": "action-popover-submenu",
|
|
@@ -264,11 +274,7 @@ const ActionPopoverItem = ({
|
|
|
264
274
|
setOpen,
|
|
265
275
|
setFocusIndex,
|
|
266
276
|
focusIndex
|
|
267
|
-
}) : null
|
|
268
|
-
type: "chevron_left"
|
|
269
|
-
}) : null, horizontalAlignment === "left" ? renderMenuItemIcon() : null, children, horizontalAlignment === "right" ? renderMenuItemIcon() : null, submenu && checkRef(ref) && !isLeftAligned ? /*#__PURE__*/_react.default.createElement(_actionPopover.SubMenuItemIcon, {
|
|
270
|
-
type: "chevron_right"
|
|
271
|
-
}) : null);
|
|
277
|
+
}) : null));
|
|
272
278
|
};
|
|
273
279
|
|
|
274
280
|
exports.ActionPopoverItem = ActionPopoverItem;
|
|
@@ -7,6 +7,7 @@ declare type StyledMenuItemProps = {
|
|
|
7
7
|
horizontalAlignment: "left" | "right";
|
|
8
8
|
};
|
|
9
9
|
declare const StyledMenuItem: import("styled-components").StyledComponent<"button", any, StyledMenuItemProps, never>;
|
|
10
|
+
declare const StyledMenuItemWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
11
|
declare const MenuItemDivider: import("styled-components").StyledComponent<"div", any, {
|
|
11
12
|
"data-element": string;
|
|
12
13
|
}, "data-element">;
|
|
@@ -16,4 +17,4 @@ declare const StyledButtonIcon: import("styled-components").StyledComponent<"div
|
|
|
16
17
|
declare const MenuItemIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
17
18
|
declare const SubMenuItemIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
18
19
|
declare const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
19
|
-
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, };
|
|
20
|
+
export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, StyledMenuItemWrapper, };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyledMenuItem = exports.MenuButtonOverrideWrapper = exports.SubMenuItemIcon = exports.MenuItemDivider = exports.MenuItemIcon = exports.StyledButtonIcon = exports.ButtonIcon = exports.MenuButton = exports.Menu = void 0;
|
|
6
|
+
exports.StyledMenuItemWrapper = exports.StyledMenuItem = exports.MenuButtonOverrideWrapper = exports.SubMenuItemIcon = exports.MenuItemDivider = exports.MenuItemIcon = exports.StyledButtonIcon = exports.ButtonIcon = exports.MenuButton = exports.Menu = void 0;
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
@@ -35,7 +35,11 @@ const Menu = _styledComponents.default.div`
|
|
|
35
35
|
background-color: var(--colorsUtilityYang100);
|
|
36
36
|
z-index: ${({
|
|
37
37
|
theme
|
|
38
|
-
}) =>
|
|
38
|
+
}) => {
|
|
39
|
+
var _theme$zIndex;
|
|
40
|
+
|
|
41
|
+
return `${(_theme$zIndex = theme.zIndex) === null || _theme$zIndex === void 0 ? void 0 : _theme$zIndex.popover}`;
|
|
42
|
+
}}; // TODO (tokens): implement elevation tokens - FE-4437
|
|
39
43
|
`;
|
|
40
44
|
exports.Menu = Menu;
|
|
41
45
|
const StyledMenuItem = _styledComponents.default.button`
|
|
@@ -90,6 +94,10 @@ const StyledMenuItem = _styledComponents.default.button`
|
|
|
90
94
|
`}
|
|
91
95
|
`;
|
|
92
96
|
exports.StyledMenuItem = StyledMenuItem;
|
|
97
|
+
const StyledMenuItemWrapper = _styledComponents.default.div`
|
|
98
|
+
position: relative;
|
|
99
|
+
`;
|
|
100
|
+
exports.StyledMenuItemWrapper = StyledMenuItemWrapper;
|
|
93
101
|
const MenuItemDivider = _styledComponents.default.div.attrs({
|
|
94
102
|
"data-element": "action-popover-divider"
|
|
95
103
|
})`
|