@tap-payments/os-micro-frontend-shared 0.1.347 → 0.1.348

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 { useState } from 'react';
13
+ import { useCallback, useMemo, useState } from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { AnimatePresence, motion } from 'framer-motion';
16
16
  import { copyText as copyTextHandler, isArabic } from '../../utils/index.js';
@@ -22,10 +22,8 @@ const StatusChip = (_a) => {
22
22
  const [showCopy, setShowCopy] = useState(false);
23
23
  const { t } = useTranslation();
24
24
  const isSelected = props.isSelected;
25
- if (!children) {
26
- return (_jsx(ChipStyled, Object.assign({}, emptyStatusChipColors, props, { isSelected: false, sx: (theme) => ({ borderColor: theme.palette.divider, width: fullWidth ? '100%' : 'auto' }) }, { children: unknownText ? t(unknownText) : t('unknown') })));
27
- }
28
- const handleCopy = (e) => {
25
+ const isCopyActive = isSelected && copyText;
26
+ const handleCopy = useCallback((e) => {
29
27
  e.stopPropagation();
30
28
  if (copyText) {
31
29
  setShowCopy(true);
@@ -37,16 +35,24 @@ const StatusChip = (_a) => {
37
35
  clearTimeout(timer);
38
36
  };
39
37
  }
40
- };
41
- const isCopyActive = isSelected && copyText;
42
- return (_jsxs(motion.div, Object.assign({ style: Object.assign(Object.assign({ position: 'relative' }, containerStyles), (fullWidth && { width: '100%', minWidth: 0 })), animate: { zIndex: isSelected ? 3 : 0 } }, { children: [_jsx(ChipStyled, Object.assign({}, props, { sx: { visibility: 'hidden', pointerEvents: 'none', width: fullWidth ? '100%' : 'auto' } }, { children: _jsx(Wrapper, { children: children }) })), _jsx(motion.div, Object.assign({ style: { position: 'absolute', top: 0, zIndex: isSelected ? 3 : 0, width: fullWidth ? '100%' : 'auto' }, animate: {
43
- left: isCopyActive && expandDirection === 'left' ? -12 : 0,
44
- }, transition: { delay: isSelected ? 0 : 0.3, duration: 0.2 } }, { children: _jsx(ChipStyled, Object.assign({}, props, { isSelected: isSelected, sx: { width: fullWidth ? '100%' : 'auto' } }, chipStyles, { children: _jsxs(motion.div, Object.assign({ layout: "size", style: Object.assign({ display: 'flex', gap: '4px' }, (fullWidth && { maxWidth: '100%', width: '100%' })), animate: {
45
- paddingRight: isCopyActive ? 12 : 0,
46
- }, transition: { delay: isSelected ? 0 : 0.3, duration: 0.2 } }, { children: [_jsx(Wrapper, Object.assign({ "data-is-arabic": typeof children === 'string' && isArabic(children) }, { children: children })), _jsx(AnimatePresence, { children: isCopyActive && (_jsx(CopyWrapper, { children: _jsx(motion.img, { initial: { opacity: 0, x: -5 }, animate: { opacity: 1, x: 0 }, exit: { opacity: 0, x: -2 }, transition: { duration: 0.1 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : copyIcon, style: {
47
- height: 12,
48
- width: 12,
49
- objectFit: 'contain',
50
- } }) })) })] })) })) }))] })));
38
+ }, [copyText]);
39
+ const copyButton = useMemo(() => (_jsx(CopyWrapper, Object.assign({ sx: Object.assign(Object.assign({}, (expandDirection === 'right' && { right: '8px' })), (expandDirection === 'left' && { left: '8px' })) }, { children: _jsx(motion.img, { initial: { opacity: 0, x: -5 }, animate: { opacity: 1, x: 0 }, exit: { opacity: 0, x: -2 }, transition: { duration: 0.1 }, onClick: handleCopy, src: showCopy ? greenCheckIcon : copyIcon, style: {
40
+ height: 12,
41
+ width: 12,
42
+ objectFit: 'contain',
43
+ } }) }))), [showCopy, handleCopy, expandDirection]);
44
+ const isExpandedRightActive = isCopyActive && expandDirection === 'right';
45
+ const isExpandedLeftActive = isCopyActive && expandDirection === 'left';
46
+ if (!children) {
47
+ return (_jsx(ChipStyled, Object.assign({}, emptyStatusChipColors, props, { isSelected: false, sx: (theme) => ({ borderColor: theme.palette.divider, width: fullWidth ? '100%' : 'auto' }) }, { children: unknownText ? t(unknownText) : t('unknown') })));
48
+ }
49
+ return (_jsxs(motion.div, Object.assign({ style: Object.assign(Object.assign({ position: 'relative' }, containerStyles), (fullWidth && { width: '100%', minWidth: 0 })), animate: { zIndex: isSelected ? 3 : 0 } }, { children: [_jsx(ChipStyled, Object.assign({}, props, { sx: { visibility: 'hidden', pointerEvents: 'none', width: fullWidth ? '100%' : 'auto' } }, { children: _jsx(Wrapper, { children: children }) })), _jsx(motion.div, Object.assign({ style: {
50
+ position: 'absolute',
51
+ top: 0,
52
+ zIndex: isSelected ? 3 : 0,
53
+ width: fullWidth ? '100%' : 'auto',
54
+ left: expandDirection === 'right' ? 0 : 'unset',
55
+ right: expandDirection === 'left' ? 0 : 'unset',
56
+ }, transition: { delay: isSelected ? 0 : 0.3, duration: 0.2 } }, { children: _jsx(ChipStyled, Object.assign({}, props, { isSelected: isSelected, sx: { width: fullWidth ? '100%' : 'auto' } }, chipStyles, { children: _jsxs(motion.div, Object.assign({ layout: "size", style: Object.assign({ display: 'flex', gap: '4px' }, (fullWidth && { maxWidth: '100%', width: '100%' })), animate: Object.assign(Object.assign({}, (isExpandedRightActive && { paddingRight: 12 })), (isExpandedLeftActive && { paddingLeft: 12 })), transition: { delay: isSelected ? 0 : 0.3, duration: 0.2 } }, { children: [_jsx(AnimatePresence, { children: isExpandedLeftActive && copyButton }), _jsx(Wrapper, Object.assign({ "data-is-arabic": typeof children === 'string' && isArabic(children) }, { children: children })), _jsx(AnimatePresence, { children: isExpandedRightActive && copyButton })] })) })) }))] })));
51
57
  };
52
58
  export default StatusChip;
@@ -27,7 +27,6 @@ export const Wrapper = styled(Box)(() => ({
27
27
  }));
28
28
  export const CopyWrapper = styled(Box)(() => ({
29
29
  position: 'absolute',
30
- right: '8px',
31
30
  top: 0,
32
31
  height: '100%',
33
32
  width: '12px',
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.347",
4
+ "version": "0.1.348",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",