1 | import { __rest } from "tslib";
|
2 | import * as React from 'react';
|
3 | import styles from '@patternfly/react-styles/css/components/Menu/menu';
|
4 | import { css } from '@patternfly/react-styles';
|
5 | import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
|
6 | import { MenuContext, MenuItemContext } from './MenuContext';
|
7 | const MenuItemActionBase = (_a) => {
|
8 | 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"]);
|
9 | return (React.createElement(MenuContext.Consumer, null, ({ onActionClick }) => (React.createElement(MenuItemContext.Consumer, null, ({ itemId, isDisabled: isDisabledContext }) => {
|
10 | const onClickButton = (event) => {
|
11 |
|
12 | onClick && onClick(event);
|
13 |
|
14 | onActionClick && onActionClick(event, itemId, actionId);
|
15 | };
|
16 | return (React.createElement("button", Object.assign({ className: css(styles.menuItemAction, isFavorited !== null && styles.modifiers.favorite, isFavorited && styles.modifiers.favorited, className), "aria-label": ariaLabel, onClick: onClickButton }, ((isDisabled === true || isDisabledContext === true) && { disabled: true }), { ref: innerRef, tabIndex: -1 }, props),
|
17 | React.createElement("span", { className: css(styles.menuItemActionIcon) }, icon === 'favorites' || isFavorited !== null ? React.createElement(StarIcon, { "aria-hidden": true }) : icon)));
|
18 | }))));
|
19 | };
|
20 | export const MenuItemAction = React.forwardRef((props, ref) => (React.createElement(MenuItemActionBase, Object.assign({}, props, { innerRef: ref }))));
|
21 | MenuItemAction.displayName = 'MenuItemAction';
|
22 |
|
\ | No newline at end of file |