UNPKG

2.48 kBJavaScriptView Raw
1import { __rest } from "tslib";
2import * as React from 'react';
3import { css } from '@patternfly/react-styles';
4import styles from '@patternfly/react-styles/css/components/AppLauncher/app-launcher';
5import { DropdownItem } from '../Dropdown';
6import { ApplicationLauncherContent } from './ApplicationLauncherContent';
7import { ApplicationLauncherContext } from './ApplicationLauncherContext';
8import { ApplicationLauncherItemContext } from './ApplicationLauncherItemContext';
9import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
10import { getUniqueId } from '../../helpers/util';
11export const ApplicationLauncherItem = (_a) => {
12 var { className = '', id, children, icon = null, isExternal = false, href, tooltip = null, tooltipProps = null, component = 'a', isFavorite = null, ariaIsFavoriteLabel = 'starred', ariaIsNotFavoriteLabel = 'not starred', customChild, enterTriggersArrowDown = false } = _a, props = __rest(_a, ["className", "id", "children", "icon", "isExternal", "href", "tooltip", "tooltipProps", "component", "isFavorite", "ariaIsFavoriteLabel", "ariaIsNotFavoriteLabel", "customChild", "enterTriggersArrowDown"]);
13 return (React.createElement(ApplicationLauncherItemContext.Provider, { value: { isExternal, icon } },
14 React.createElement(ApplicationLauncherContext.Consumer, null, ({ onFavorite }) => (React.createElement(DropdownItem, Object.assign({ id: id, component: component, href: href || null, className: css(isExternal && styles.modifiers.external, isFavorite !== null && styles.modifiers.link, className), listItemClassName: css(onFavorite && styles.appLauncherMenuWrapper, isFavorite && styles.modifiers.favorite), tooltip: tooltip, tooltipProps: tooltipProps }, (enterTriggersArrowDown === true && { enterTriggersArrowDown }), (customChild && { customChild }), (isFavorite !== null && {
15 additionalChild: (React.createElement("button", { className: css(styles.appLauncherMenuItem, styles.modifiers.action), "aria-label": isFavorite ? ariaIsFavoriteLabel : ariaIsNotFavoriteLabel, onClick: () => {
16 onFavorite((id || getUniqueId('app-launcher-option')).replace('favorite-', ''), isFavorite);
17 } },
18 React.createElement(StarIcon, null)))
19 }), props), children && React.createElement(ApplicationLauncherContent, null, children))))));
20};
21ApplicationLauncherItem.displayName = 'ApplicationLauncherItem';
22//# sourceMappingURL=ApplicationLauncherItem.js.map
\No newline at end of file