@tap-payments/os-micro-frontend-shared 0.1.206 → 0.1.208-test.12

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,10 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { PopperProps } from '@mui/material/Popper';
3
- import { SxProps, Theme } from '@mui/material';
3
+ import { BoxProps, SxProps, Theme } from '@mui/material';
4
4
  interface MenuProps extends PopperProps {
5
5
  children: ReactNode;
6
6
  popperSx?: SxProps<Theme>;
7
+ dropdownProps?: BoxProps;
7
8
  }
8
- declare function Menu({ open, anchorEl, children, sx, placement, popperSx, ...props }: MenuProps): import("react/jsx-runtime").JSX.Element;
9
- declare const _default: import("react").MemoExoticComponent<typeof Menu>;
9
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<MenuProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
10
10
  export default _default;
@@ -9,17 +9,21 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { memo, Children, useMemo } from 'react';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { memo, Children, useMemo, forwardRef, useCallback } from 'react';
14
14
  import Popper from '@mui/material/Popper';
15
15
  import { useScrollWithShadow } from '../Widget/useScrollWithShadow';
16
- import { listShadowBg } from '../../constants/index.js';
17
- import { StyledDropdown, ShadowBackground } from './style';
18
- function Menu(_a) {
19
- var { open, anchorEl, children, sx, placement, popperSx } = _a, props = __rest(_a, ["open", "anchorEl", "children", "sx", "placement", "popperSx"]);
16
+ import { StyledDropdown } from './style';
17
+ const Menu = forwardRef((_a, ref) => {
18
+ var { open, anchorEl, children, sx, placement, popperSx, dropdownProps } = _a, props = __rest(_a, ["open", "anchorEl", "children", "sx", "placement", "popperSx", "dropdownProps"]);
20
19
  const { onScrollHandler, showShadow } = useScrollWithShadow();
20
+ const _b = dropdownProps || {}, { onScroll } = _b, restDropdownProps = __rest(_b, ["onScroll"]);
21
21
  const childrenCount = useMemo(() => Children.count(children), [children]);
22
22
  const shouldShowShadow = childrenCount > 12 && showShadow;
23
- 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
- }
23
+ const handleScroll = useCallback((e) => {
24
+ onScrollHandler(e);
25
+ onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
26
+ }, [onScrollHandler, onScroll]);
27
+ return (_jsx(Popper, Object.assign({ ref: ref, open: open, anchorEl: anchorEl, placement: placement || 'bottom-start', sx: popperSx }, props, { children: _jsx(StyledDropdown, Object.assign({ showShadow: shouldShowShadow, onScroll: handleScroll, className: "MuiPopper-dropdown", sx: sx }, restDropdownProps, { children: children })) }), "menu"));
28
+ });
25
29
  export default memo(Menu);
@@ -1,9 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const StyledDropdown: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
4
- }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
5
- export declare const ShadowBackground: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
6
- ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
4
  }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
8
- src: string;
5
+ showShadow?: boolean | undefined;
9
6
  }, {}, {}>;
@@ -1,6 +1,6 @@
1
1
  import Box from '@mui/material/Box';
2
2
  import { styled } from '@mui/material/styles';
3
- export const StyledDropdown = styled(Box)(({ theme }) => ({
3
+ export const StyledDropdown = styled(Box, { shouldForwardProp: (prop) => prop !== 'showShadow' })(({ theme, showShadow }) => ({
4
4
  borderRadius: theme.spacing(0.5),
5
5
  background: theme.palette.background.default,
6
6
  width: 'max-content',
@@ -13,13 +13,11 @@ export const StyledDropdown = styled(Box)(({ theme }) => ({
13
13
  '.menu-item + .menu-item': {
14
14
  borderTop: `1px solid ${theme.palette.divider}`,
15
15
  },
16
- }));
17
- export const ShadowBackground = styled(Box)(() => ({
18
- width: '100%',
19
- height: '34px',
20
- objectFit: 'cover',
21
- position: 'fixed',
22
- bottom: 0,
23
- pointerEvents: 'none',
24
- zIndex: 999999,
16
+ '&::after': Object.assign({ content: '""', width: '100%', height: '34px', position: 'fixed', bottom: 0, pointerEvents: 'none', zIndex: 999999, background: 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 100%)', transition: theme.transitions.create('opacity', { duration: 250 }) }, (showShadow
17
+ ? {
18
+ opacity: 1,
19
+ }
20
+ : {
21
+ opacity: 0,
22
+ })),
25
23
  }));
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { StatusChipWithCopy } from '../../../index.js';
2
+ import { StatusChip, StatusChipWithCopy } from '../../../index.js';
3
3
  import { Box, Popover } from '@mui/material';
4
- import { useEffect, useRef, useState } from 'react';
4
+ import { useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { StyledSheetContainer } from './style';
6
6
  function SalesChannelCellSheet({ channels, selectionProps = {} }) {
7
7
  const channelWrapperRef = useRef(null);
@@ -13,12 +13,24 @@ function SalesChannelCellSheet({ channels, selectionProps = {} }) {
13
13
  setHasOverflow(channelWrapperRef.current.scrollHeight > 20);
14
14
  }
15
15
  }, [channels]);
16
- return (_jsxs(StyledSheetContainer, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: hasOverflow ? '8px' : '4px', maxWidth: '367px' }, ref: channelWrapperRef }, { children: channels === null || channels === void 0 ? void 0 : channels.filter((s) => !!s.address).map((channel, index) => {
16
+ const filteredChannels = useMemo(() => (channels || []).filter((s) => !!s.address), [channels]);
17
+ return (_jsxs(StyledSheetContainer, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: hasOverflow ? '8px' : '4px' }, ref: channelWrapperRef }, { children: filteredChannels.map((channel, index) => {
17
18
  var _a, _b;
18
- return (_jsxs(StatusChipWithCopy, Object.assign({ copyText: `${(_a = channel.name) === null || _a === void 0 ? void 0 : _a.en}: ${channel.address}`, chipIndex: index + 1, selectionProps: selectionProps }, { children: [(_b = channel.name) === null || _b === void 0 ? void 0 : _b.en, ": ", channel.address] }), channel.id));
19
+ return (_jsxs(StatusChipWithCopy, Object.assign({ copyText: `${(_a = channel.name) === null || _a === void 0 ? void 0 : _a.en}: ${channel.address}`, chipIndex: index + 1, selectionProps: selectionProps, maxWidth: "367px", sx: {
20
+ overflow: 'hidden',
21
+ textOverflow: 'ellipsis',
22
+ whiteSpace: 'nowrap',
23
+ maxWidth: '367px',
24
+ '& div': {
25
+ overflow: 'hidden',
26
+ textOverflow: 'ellipsis',
27
+ whiteSpace: 'nowrap',
28
+ maxWidth: '367px',
29
+ },
30
+ } }, { children: [(_b = channel.name) === null || _b === void 0 ? void 0 : _b.en, ": ", channel.address] }), channel.id));
19
31
  }) })), hasOverflow && (_jsx(Box, Object.assign({ onClick: (e) => {
20
32
  setAnchorEl(e.currentTarget.parentElement);
21
- }, sx: { height: '18px' } }, { children: _jsx(StatusChipWithCopy, Object.assign({ minWidth: "25", sx: { borderRadius: '24px', overflow: 'hidden' }, copyText: "...", chipIndex: (channels === null || channels === void 0 ? void 0 : channels.length) + 1, selectionProps: selectionProps }, { children: "..." })) }))), _jsx(Popover, Object.assign({ open: open, anchorEl: anchorEl, sx: { minWidth: anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.clientWidth }, onClose: () => {
33
+ }, sx: { height: '18px' } }, { children: _jsx(StatusChip, Object.assign({ minWidth: "25", sx: { borderRadius: '24px', overflow: 'hidden' }, copyText: "..." }, { children: "..." })) }))), _jsx(Popover, Object.assign({ open: open, anchorEl: anchorEl, sx: { minWidth: anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.clientWidth }, onClose: () => {
22
34
  setAnchorEl(null);
23
35
  }, anchorOrigin: {
24
36
  vertical: 'top',
@@ -34,7 +46,7 @@ function SalesChannelCellSheet({ channels, selectionProps = {} }) {
34
46
  marginTop: '22px',
35
47
  },
36
48
  },
37
- } }, { children: _jsx(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '4px', padding: '4px' } }, { children: channels === null || channels === void 0 ? void 0 : channels.filter((s) => !!s.address).map((channel, index) => {
49
+ } }, { children: _jsx(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '4px', padding: '4px' } }, { children: filteredChannels.map((channel, index) => {
38
50
  var _a, _b;
39
51
  return (_jsxs(StatusChipWithCopy, Object.assign({ copyText: `${(_a = channel.name) === null || _a === void 0 ? void 0 : _a.en}: ${channel.address}`, chipIndex: index + 1, selectionProps: selectionProps }, { children: [(_b = channel.name) === null || _b === void 0 ? void 0 : _b.en, ": ", channel.address] }), channel.id));
40
52
  }) })) }))] }));
@@ -54,7 +54,7 @@ export const salesChannelAnimation = (index, xDelta, isLastChannel) => ({
54
54
  export const StyledSheetContainer = styled(Box)(() => ({
55
55
  display: 'flex',
56
56
  gap: '4px',
57
- maxWidth: '424px',
57
+ maxWidth: '440px',
58
58
  justifyContent: 'space-between',
59
59
  height: '18px',
60
60
  }));
@@ -1,14 +1,14 @@
1
- import { useState } from 'react';
1
+ import { useCallback, useState } from 'react';
2
2
  export function useScrollWithShadow() {
3
3
  const [scrollTop, setScrollTop] = useState(0);
4
4
  const [scrollHeight, setScrollHeight] = useState(0);
5
5
  const [clientHeight, setClientHeight] = useState(0);
6
- const onScrollHandler = (event) => {
6
+ const onScrollHandler = useCallback((event) => {
7
7
  const target = event.target;
8
8
  setScrollTop(target.scrollTop);
9
9
  setScrollHeight(target.scrollHeight);
10
10
  setClientHeight(target.clientHeight);
11
- };
11
+ }, []);
12
12
  const showShadow = scrollTop === 0 || clientHeight < scrollHeight - scrollTop - 1;
13
13
  return { onScrollHandler, showShadow };
14
14
  }
@@ -67,7 +67,7 @@ export declare const merchantsTableCellWidth: {
67
67
  readonly individual_phone_number: {
68
68
  readonly default: "180px";
69
69
  readonly text: "180px";
70
- readonly sheet: "180px";
70
+ readonly sheet: "190px";
71
71
  };
72
72
  readonly entity_legal_name: {
73
73
  readonly default: "180px";
@@ -67,7 +67,7 @@ export const merchantsTableCellWidth = {
67
67
  individual_phone_number: {
68
68
  default: '180px',
69
69
  text: '180px',
70
- sheet: '180px',
70
+ sheet: '190px',
71
71
  },
72
72
  entity_legal_name: {
73
73
  default: '180px',
package/package.json CHANGED
@@ -1,8 +1,8 @@
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.206",
5
- "testVersion": 8,
4
+ "version": "0.1.208-test.12",
5
+ "testVersion": 12,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -163,4 +163,4 @@
163
163
  "publishConfig": {
164
164
  "registry": "https://registry.npmjs.org/"
165
165
  }
166
- }
166
+ }