@tap-payments/os-micro-frontend-shared 0.1.180 → 0.1.181

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.
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { memo, Children } from 'react';
13
+ import { memo, Children, isValidElement, useMemo } from 'react';
14
14
  import Popper from '@mui/material/Popper';
15
15
  import { useScrollWithShadow } from '../Widget/useScrollWithShadow';
16
16
  import { listShadowBg } from '../../constants/index.js';
@@ -18,8 +18,9 @@ import { StyledDropdown, ShadowBackground } from './style';
18
18
  function Menu(_a) {
19
19
  var { open, anchorEl, children, sx, placement, popperSx } = _a, props = __rest(_a, ["open", "anchorEl", "children", "sx", "placement", "popperSx"]);
20
20
  const { onScrollHandler, showShadow } = useScrollWithShadow();
21
- const childrenCount = Children.count(children);
22
- const shouldShowShadow = childrenCount > 11 && showShadow;
21
+ // Count only children with className "menu-item"
22
+ const menuItemCount = useMemo(() => Children.toArray(children).filter((child) => { var _a, _b; return isValidElement(child) && ((_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.includes('menu-item')); }).length, [children]);
23
+ const shouldShowShadow = menuItemCount > 12 && showShadow;
23
24
  return (_jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: placement || 'bottom-start', sx: popperSx }, props, { children: _jsxs(StyledDropdown, Object.assign({ onScroll: onScrollHandler, className: "MuiPopper-dropdown", sx: sx }, { children: [children, shouldShowShadow && _jsx(ShadowBackground, { component: "img", src: listShadowBg })] })) }), "menu"));
24
25
  }
25
26
  export default memo(Menu);
@@ -6,6 +6,6 @@ interface MenuItemProps extends BoxProps {
6
6
  isIndeterminate?: boolean;
7
7
  hideCheckbox?: boolean;
8
8
  }
9
- declare function MenuItem({ isSelected, isDisabled, isIndeterminate, hideCheckbox, onClick, children, ...props }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
9
+ declare function MenuItem({ isSelected, isDisabled, isIndeterminate, hideCheckbox, onClick, children, className, ...props }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
10
10
  declare const _default: import("react").MemoExoticComponent<typeof MenuItem>;
11
11
  export default _default;
@@ -13,7 +13,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { memo } from 'react';
14
14
  import { CheckboxStyled, MenuItemStyled } from './style';
15
15
  function MenuItem(_a) {
16
- var { isSelected, isDisabled, isIndeterminate, hideCheckbox, onClick, children } = _a, props = __rest(_a, ["isSelected", "isDisabled", "isIndeterminate", "hideCheckbox", "onClick", "children"]);
17
- return (_jsxs(MenuItemStyled, Object.assign({ className: isDisabled ? 'disabled menu-item' : 'menu-item', onClick: onClick, disabled: isDisabled }, props, { children: [!hideCheckbox && _jsx(CheckboxStyled, { size: "small", checked: isSelected, indeterminate: isIndeterminate, disabled: isDisabled }), children] })));
16
+ var { isSelected, isDisabled, isIndeterminate, hideCheckbox, onClick, children, className } = _a, props = __rest(_a, ["isSelected", "isDisabled", "isIndeterminate", "hideCheckbox", "onClick", "children", "className"]);
17
+ const baseClassName = isDisabled ? 'disabled menu-item' : 'menu-item';
18
+ const combinedClassName = className ? `${baseClassName} ${className}` : baseClassName;
19
+ return (_jsxs(MenuItemStyled, Object.assign({ className: combinedClassName, onClick: onClick, disabled: isDisabled }, props, { children: [!hideCheckbox && _jsx(CheckboxStyled, { size: "small", checked: isSelected, indeterminate: isIndeterminate, disabled: isDisabled }), children] })));
18
20
  }
19
21
  export default memo(MenuItem);
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.180",
4
+ "version": "0.1.181",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",