@tap-payments/os-micro-frontend-shared 0.1.425 → 0.1.426

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.
@@ -1,3 +1,3 @@
1
1
  import type { AppServicesActionMenuProps } from './types';
2
- export declare function AppServicesActionMenu({ anchorEl, open, onClose, items, onSelectService }: AppServicesActionMenuProps): import("react/jsx-runtime").JSX.Element | null;
2
+ export declare function AppServicesActionMenu({ anchorEl, open, onClose, items, onSelectService, showViewApi, onViewApiClick, }: AppServicesActionMenuProps): import("react/jsx-runtime").JSX.Element | null;
3
3
  export default AppServicesActionMenu;
@@ -1,22 +1,25 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import Popper from '@mui/material/Popper';
5
5
  import { ClickAwayListener } from '@mui/material';
6
- import { rightArrow } from '../../constants/index.js';
6
+ import { rightArrow, jsonBlackIcon } from '../../constants/index.js';
7
7
  import CustomBackdrop from '../CustomBackdrop';
8
8
  import { App, AppDetails, AppName, AppList, AppIcon } from './style';
9
9
  import ServicesSubmenu from './ServicesSubmenu';
10
- export function AppServicesActionMenu({ anchorEl, open, onClose, items, onSelectService }) {
10
+ export function AppServicesActionMenu({ anchorEl, open, onClose, items, onSelectService, showViewApi = false, onViewApiClick, }) {
11
11
  const [childAnchorEl, setChildAnchorEl] = useState(null);
12
12
  const [hoveredItem, setHoveredItem] = useState(null);
13
+ const [hoveredViewApi, setHoveredViewApi] = useState(false);
13
14
  const onChildMouseOver = useCallback((event, item) => {
14
15
  setChildAnchorEl(event.currentTarget);
15
16
  setHoveredItem(item);
17
+ setHoveredViewApi(false);
16
18
  }, []);
17
19
  const onChildLeave = useCallback(() => {
18
20
  setChildAnchorEl(null);
19
21
  setHoveredItem(null);
22
+ setHoveredViewApi(false);
20
23
  }, []);
21
24
  const handleClose = useCallback(() => {
22
25
  onClose();
@@ -26,8 +29,16 @@ export function AppServicesActionMenu({ anchorEl, open, onClose, items, onSelect
26
29
  onSelectService(appCode, serviceCode);
27
30
  handleClose();
28
31
  }, [onSelectService, handleClose]);
32
+ const handleViewApiClick = useCallback((e) => {
33
+ e.stopPropagation();
34
+ onViewApiClick === null || onViewApiClick === void 0 ? void 0 : onViewApiClick();
35
+ handleClose();
36
+ }, [onViewApiClick, handleClose]);
29
37
  if (!open)
30
38
  return null;
31
- return (_jsx(ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: _jsxs(Box, { children: [_jsx(CustomBackdrop, { onClick: handleClose }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end", sx: { zIndex: 2000 } }, { children: _jsx(AppList, { children: items.length === 0 ? (_jsx(App, Object.assign({ sx: { cursor: 'default', '&:hover': { boxShadow: 'none' } } }, { children: _jsx(AppDetails, { children: _jsx(AppName, Object.assign({ sx: { fontSize: 11, color: 'text.secondary' } }, { children: "No actions available" })) }) }))) : (items.map((item) => (_jsxs(App, Object.assign({ onMouseOver: (e) => onChildMouseOver(e, item), open: (hoveredItem === null || hoveredItem === void 0 ? void 0 : hoveredItem.appCode) === item.appCode }, { children: [_jsxs(AppDetails, { children: [_jsx(AppIcon, { children: _jsx("img", { src: item.appIconUrl, alt: "app", width: 16, height: 16 }) }), _jsx(AppName, { children: item.appName })] }), _jsx(AppDetails, { children: _jsx("img", { src: rightArrow, alt: "icon", className: "arrow-icon" }) })] }), item.appCode)))) }) })), items.length > 0 && (_jsx(ServicesSubmenu, { item: hoveredItem, anchorEl: childAnchorEl, onMouseLeave: onChildLeave, onSelectService: handleSelectService }))] }) })));
39
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: _jsxs(Box, { children: [_jsx(CustomBackdrop, { onClick: handleClose }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end", sx: { zIndex: 2000 } }, { children: _jsx(AppList, { children: items.length === 0 && !showViewApi ? (_jsx(App, Object.assign({ sx: { cursor: 'default', '&:hover': { boxShadow: 'none' } } }, { children: _jsx(AppDetails, { children: _jsx(AppName, Object.assign({ sx: { fontSize: 11, color: 'text.secondary' } }, { children: "No actions available" })) }) }))) : (_jsxs(_Fragment, { children: [items.map((item) => (_jsxs(App, Object.assign({ onMouseOver: (e) => onChildMouseOver(e, item), open: (hoveredItem === null || hoveredItem === void 0 ? void 0 : hoveredItem.appCode) === item.appCode }, { children: [_jsxs(AppDetails, { children: [_jsx(AppIcon, { children: _jsx("img", { src: item.appIconUrl, alt: "app", width: 16, height: 16 }) }), _jsx(AppName, { children: item.appName })] }), _jsx(AppDetails, { children: _jsx("img", { src: rightArrow, alt: "icon", className: "arrow-icon" }) })] }), item.appCode))), showViewApi && onViewApiClick && (_jsx(App, Object.assign({ onClick: handleViewApiClick, open: hoveredViewApi, onMouseOver: () => {
40
+ setHoveredItem(null);
41
+ setHoveredViewApi(true);
42
+ }, onMouseLeave: () => setHoveredViewApi(false) }, { children: _jsxs(AppDetails, { children: [_jsx(AppIcon, { children: _jsx("img", { src: jsonBlackIcon, alt: "app", width: 16, height: 16 }) }), _jsx(AppName, { children: "View API" })] }) })))] })) }) })), items.length > 0 && (_jsx(ServicesSubmenu, { item: hoveredItem, anchorEl: childAnchorEl, onMouseLeave: onChildLeave, onSelectService: handleSelectService }))] }) })));
32
43
  }
33
44
  export default AppServicesActionMenu;
@@ -14,4 +14,6 @@ export interface AppServicesActionMenuProps {
14
14
  onClose: () => void;
15
15
  items: AppServicesActionMenuItem[];
16
16
  onSelectService: (appCode: string, serviceCode: string) => void;
17
+ showViewApi?: boolean;
18
+ onViewApiClick?: () => void;
17
19
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.425",
4
+ "version": "0.1.426",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",