@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
|
-
|
|
26
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
package/package.json
CHANGED