@vertigis/react-ui 9.3.0 → 9.3.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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ListItemSecondaryActionProps } from "../ListItemSecondaryAction";
|
|
3
|
+
/**
|
|
4
|
+
* For use within a MenuList (or other list that implements arrow key
|
|
5
|
+
* navigation). The standard ListItemSecondaryAction will break keyboard
|
|
6
|
+
* navigation in this type of list.
|
|
7
|
+
*
|
|
8
|
+
* @param props The component properties.
|
|
9
|
+
*/
|
|
10
|
+
declare const MenuItemSecondaryAction: FC<ListItemSecondaryActionProps>;
|
|
11
|
+
export default MenuItemSecondaryAction;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import GcxListItemSecondaryAction from "../ListItemSecondaryAction";
|
|
4
|
+
import { styled } from "../styles";
|
|
5
|
+
const StyledListItemSecondaryAction = styled(GcxListItemSecondaryAction)({
|
|
6
|
+
display: "flex",
|
|
7
|
+
flexShrink: 0,
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* For use within a MenuList (or other list that implements arrow key
|
|
11
|
+
* navigation). The standard ListItemSecondaryAction will break keyboard
|
|
12
|
+
* navigation in this type of list.
|
|
13
|
+
*
|
|
14
|
+
* @param props The component properties.
|
|
15
|
+
*/
|
|
16
|
+
const MenuItemSecondaryAction = (props) => {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const { className, ...otherProps } = props;
|
|
19
|
+
const onKeyDown = (event) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const { key } = event;
|
|
22
|
+
if (key === "ArrowUp" || key === "ArrowDown" || key === "Home" || key === "End") {
|
|
23
|
+
// Switch focus to the parent list item, then let the key event
|
|
24
|
+
// propagate to get the normal behavior of pressing these keys.
|
|
25
|
+
(_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.focus();
|
|
26
|
+
}
|
|
27
|
+
else if (key !== "Escape") {
|
|
28
|
+
// Prevent propagation to the primary action.
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return (_jsx(StyledListItemSecondaryAction, Object.assign({ className: className, onClick: (event) => {
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
}, onKeyDown: onKeyDown, onMouseDown: (event) => {
|
|
35
|
+
// This will stop child ripples from propagating.
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
}, ref: ref }, otherProps), void 0));
|
|
38
|
+
};
|
|
39
|
+
export default MenuItemSecondaryAction;
|