| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx } from "react/jsx-runtime"; |
| 3 |
import { forwardRef } from 'react'; |
| 4 |
import styles from '@patternfly/react-styles/css/components/Menu/menu.mjs'; |
| 5 |
import { css } from '@patternfly/react-styles'; |
| 6 |
import { MenuContext, MenuItemContext } from './MenuContext'; |
| 7 |
import { Button } from '../Button'; |
| 8 |
const MenuItemActionBase = (_a) => { |
| 9 |
var { className, icon, onClick, 'aria-label': ariaLabel, isFavorited = null, isDisabled, actionId, innerRef } = _a, props = __rest(_a, ["className", "icon", "onClick", 'aria-label', "isFavorited", "isDisabled", "actionId", "innerRef"]); |
| 10 |
return (_jsx(MenuContext.Consumer, { children: ({ onActionClick }) => (_jsx(MenuItemContext.Consumer, { children: ({ itemId, isDisabled: isDisabledContext }) => { |
| 11 |
const onClickButton = (event) => { |
| 12 |
// event specified on the MenuItemAction |
| 13 |
onClick && onClick(event); |
| 14 |
// event specified on the Menu |
| 15 |
onActionClick && onActionClick(event, itemId, actionId); |
| 16 |
}; |
| 17 |
return (_jsx("div", Object.assign({ className: css(styles.menuItemAction, isFavorited !== null && 'pf-m-favorite', isFavorited && styles.modifiers.favorited, className) }, props, { children: _jsx(Button, { "aria-label": ariaLabel, onClick: onClickButton, ref: innerRef, role: "menuitem", variant: "plain", isFavorite: isFavorited !== null, isFavorited: isFavorited !== null && isFavorited !== void 0 ? isFavorited : false, tabIndex: -1, isDisabled: isDisabled || isDisabledContext, icon: isFavorited === null ? icon : undefined }) }))); |
| 18 |
} })) })); |
| 19 |
}; |
| 20 |
export const MenuItemAction = forwardRef((props, ref) => (_jsx(MenuItemActionBase, Object.assign({}, props, { innerRef: ref })))); |
| 21 |
MenuItemAction.displayName = 'MenuItemAction'; |
| 22 |
//# sourceMappingURL=MenuItemAction.js.map |