@tap-payments/os-micro-frontend-shared 0.1.386-test.1 → 0.1.386-test.5
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.
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +2 -3
- package/build/components/RightLeftExpandingCenterChip/style.d.ts +4 -2
- package/build/components/RightLeftExpandingCenterChip/style.js +3 -2
- package/build/components/TableCells/CustomCells/DueDateCell/DueDateCell.d.ts +1 -1
- package/build/components/TableCells/CustomCells/DueDateCell/DueDateCell.js +6 -3
- package/build/components/TableCells/CustomCells/DueDateCell/useDueDate.js +4 -3
- package/build/components/TableCells/CustomCells/DueDateCell/utils.d.ts +3 -2
- package/build/components/TableCells/CustomCells/DueDateCell/utils.js +8 -18
- package/package.json +2 -2
|
@@ -10,9 +10,8 @@ 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 Box from '@mui/material/Box';
|
|
14
13
|
import { AnimatePresence } from 'framer-motion';
|
|
15
|
-
import { CenterIconWrapper, ExpandedSection, PeekContainer, CenterChip, LeftPeekChip, RightPeekChip, LeftExpandIcon, RightExpandIcon, ExpandChip, CenterShiftWrapper, CenterContent, ExpandableContainer, ExpandableInner,
|
|
14
|
+
import { CenterIconWrapper, ExpandedSection, PeekContainer, CenterChip, LeftPeekChip, RightPeekChip, LeftExpandIcon, RightExpandIcon, ExpandChip, CenterShiftWrapper, CenterContent, ExpandableContainer, ExpandableInner, ChipsContainer, CHIP_GAP, HoverBridge, } from './style';
|
|
16
15
|
import { useRightLeftExpandingCenterChip, DEFAULT_CHIP_MIN_WIDTH } from './useRightLeftExpandingCenterChip';
|
|
17
16
|
/**
|
|
18
17
|
* Component: RightLeftExpandingCenterChip
|
|
@@ -49,7 +48,7 @@ import { useRightLeftExpandingCenterChip, DEFAULT_CHIP_MIN_WIDTH } from './useRi
|
|
|
49
48
|
function RightLeftExpandingCenterChip(_a) {
|
|
50
49
|
var { leftIcons = [], rightIcons = [], centerIcon, expandableCenterRight, expandableCenterLeft, expandedZIndex = 1000 } = _a, props = __rest(_a, ["leftIcons", "rightIcons", "centerIcon", "expandableCenterRight", "expandableCenterLeft", "expandedZIndex"]);
|
|
51
50
|
const { isHovering, handleMouseEnter, handleMouseLeave, centerWrapRef, centerContentRef, centerChipRef, anchors, leftChipRefs, rightChipRefs, leftOffsets, rightOffsets, expandableRightInnerRef, expandableLeftInnerRef, expandedRightMV, expandedLeftMV, shiftX, rightShift, leftShift, leftHoverWidth, rightHoverWidth, } = useRightLeftExpandingCenterChip({ leftIcons, rightIcons, centerIcon, expandableCenterRight, expandableCenterLeft });
|
|
52
|
-
return (_jsx(
|
|
51
|
+
return (_jsx(ChipsContainer, Object.assign({}, props, { "data-testid": "RightLeftExpandingCenterChipBox" }, { children: _jsx(CenterShiftWrapper, Object.assign({ "data-testid": "CenterShiftWrapper", initial: false, style: { x: shiftX } }, { children: _jsxs(CenterIconWrapper, Object.assign({ "data-testid": "CenterIconWrapper", ref: centerWrapRef, onMouseLeave: handleMouseLeave }, { children: [_jsxs(PeekContainer, Object.assign({ "data-testid": "PeekContainer" }, { children: [_jsx(AnimatePresence, Object.assign({ initial: false }, { children: leftIcons.length > 0 && (_jsx(LeftPeekChip, { "data-testid": "LeftPeekChip", initial: { opacity: 0, scale: 0.95, x: -4 }, animate: isHovering ? { opacity: 0, scale: 0.9, x: -6 } : { opacity: 1, scale: 1, x: -5 }, exit: { opacity: 0, scale: 0.95, x: -4 }, transition: { duration: 0.18, ease: 'easeOut' } }, "left-peek")) })), _jsx(CenterChip, Object.assign({ "data-testid": "CenterChip", ref: centerChipRef, onMouseEnter: handleMouseEnter, style: {
|
|
53
52
|
borderRadius: (() => {
|
|
54
53
|
const hasLeftExpanded = expandableCenterLeft && isHovering;
|
|
55
54
|
const hasRightExpanded = expandableCenterRight && isHovering;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
2
|
+
import { type Theme } from '@mui/material/styles';
|
|
3
3
|
export declare const CHIP_GAP = 3;
|
|
4
4
|
export declare const CenterIconWrapper: import("@emotion/styled").StyledComponent<{
|
|
5
5
|
hidden?: boolean | undefined;
|
|
@@ -3412,4 +3412,6 @@ export declare const ExpandChip: import("@emotion/styled").StyledComponent<{
|
|
|
3412
3412
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
3413
3413
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
3414
3414
|
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
3415
|
-
export declare const
|
|
3415
|
+
export declare const ChipsContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3416
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
3417
|
+
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
1
2
|
import { styled } from '@mui/material/styles';
|
|
2
3
|
import { motion } from 'framer-motion';
|
|
3
4
|
// Shared spacing between chips
|
|
@@ -118,7 +119,7 @@ export const RightPeekChip = styled(motion.div)(({ theme }) => (Object.assign(Ob
|
|
|
118
119
|
// Chip for expanded icons (left/right lists)
|
|
119
120
|
export const ExpandChip = styled(motion.div)(({ theme }) => (Object.assign(Object.assign({}, baseChipStyles(theme)), { minWidth: 24, flex: '0 0 auto', display: 'inline-flex' })));
|
|
120
121
|
// Styles applied to the containing TableCell
|
|
121
|
-
export const
|
|
122
|
+
export const ChipsContainer = styled(Box)(() => ({
|
|
122
123
|
position: 'relative',
|
|
123
124
|
overflow: 'visible',
|
|
124
125
|
zIndex: 101,
|
|
@@ -126,4 +127,4 @@ export const tableCellSx = {
|
|
|
126
127
|
alignItems: 'center',
|
|
127
128
|
justifyContent: 'center',
|
|
128
129
|
minHeight: '20px',
|
|
129
|
-
};
|
|
130
|
+
}));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DueCellProps } from './type';
|
|
2
|
-
declare function DueDateCell({ dueDate, expiryDate, ...props }: DueCellProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function DueDateCell({ dueDate, expiryDate, ...props }: DueCellProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default DueDateCell;
|
|
@@ -18,8 +18,11 @@ import { useDueDate } from './useDueDate';
|
|
|
18
18
|
function DueDateCell(_a) {
|
|
19
19
|
var { dueDate, expiryDate } = _a, props = __rest(_a, ["dueDate", "expiryDate"]);
|
|
20
20
|
const { dueMeta, expiryMeta } = useDueDate(dueDate, expiryDate);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (!dueMeta && !expiryMeta)
|
|
22
|
+
return null;
|
|
23
|
+
const renderIcon = (meta) => (_jsx(Tooltip, Object.assign({ title: meta.label }, { children: _jsx(DateIcon, { src: meta.icon, alt: "icon" }) })));
|
|
24
|
+
const centerIcon = dueMeta ? renderIcon(dueMeta) : expiryMeta ? renderIcon(expiryMeta) : null;
|
|
25
|
+
const rightIcons = expiryMeta && dueMeta && dueDate ? [renderIcon(expiryMeta)] : [];
|
|
26
|
+
return (_jsx(TableCell, Object.assign({}, props, { sx: { position: 'relative', overflow: 'visible' } }, { children: _jsx(RightLeftExpandingCenterChip, { sx: { justifyContent: 'flex-start' }, centerIcon: centerIcon, rightIcons: rightIcons }) })));
|
|
24
27
|
}
|
|
25
28
|
export default DueDateCell;
|
|
@@ -4,16 +4,17 @@ import { useTheme } from '@mui/material/styles';
|
|
|
4
4
|
import { isValidDate, buildDueMeta, buildExpiryMeta } from './utils';
|
|
5
5
|
export function useDueDate(dueDate, expiryDate) {
|
|
6
6
|
const theme = useTheme();
|
|
7
|
-
const now = dayjs();
|
|
8
7
|
const dueMeta = useMemo(() => {
|
|
9
8
|
if (!isValidDate(dueDate))
|
|
10
9
|
return null;
|
|
10
|
+
const now = dayjs();
|
|
11
11
|
return buildDueMeta(dayjs(dueDate), now, theme);
|
|
12
|
-
}, [dueDate,
|
|
12
|
+
}, [dueDate, theme]);
|
|
13
13
|
const expiryMeta = useMemo(() => {
|
|
14
14
|
if (!isValidDate(expiryDate))
|
|
15
15
|
return null;
|
|
16
|
+
const now = dayjs();
|
|
16
17
|
return buildExpiryMeta(dayjs(expiryDate), now);
|
|
17
|
-
}, [expiryDate
|
|
18
|
+
}, [expiryDate]);
|
|
18
19
|
return { dueMeta, expiryMeta };
|
|
19
20
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { Theme } from '@mui/material/styles';
|
|
2
3
|
import { DateInput } from './type';
|
|
3
4
|
export declare function formatDate(date?: number): string;
|
|
4
|
-
export declare function buildDueMeta(due: Dayjs, now: Dayjs, theme:
|
|
5
|
+
export declare function buildDueMeta(due: Dayjs, now: Dayjs, theme: Theme): {
|
|
5
6
|
icon: string;
|
|
6
|
-
color:
|
|
7
|
+
color: string;
|
|
7
8
|
label: string;
|
|
8
9
|
};
|
|
9
10
|
export declare function buildExpiryMeta(expiry: Dayjs, now: Dayjs): {
|
|
@@ -33,36 +33,26 @@ export function buildDueMeta(due, now, theme) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
export function buildExpiryMeta(expiry, now) {
|
|
36
|
+
const expiryTimestamp = expiry.valueOf();
|
|
36
37
|
if (expiry.isBefore(now)) {
|
|
37
38
|
return {
|
|
38
39
|
icon: expiredIcon,
|
|
39
40
|
isExpired: true,
|
|
40
|
-
label: `Expired on ${formatDate(
|
|
41
|
+
label: `Expired on ${formatDate(expiryTimestamp)}`,
|
|
41
42
|
};
|
|
42
43
|
}
|
|
44
|
+
const baseMeta = {
|
|
45
|
+
icon: timerBlueIcon,
|
|
46
|
+
isExpired: false,
|
|
47
|
+
};
|
|
43
48
|
const units = ['day', 'hour', 'minute', 'second'];
|
|
44
49
|
for (const unit of units) {
|
|
45
50
|
const diff = expiry.diff(now, unit);
|
|
46
51
|
if (diff >= 1) {
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
icon: timerBlueIcon,
|
|
50
|
-
isExpired: false,
|
|
51
|
-
label: formatDate(expiry.valueOf()),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
icon: timerBlueIcon,
|
|
56
|
-
isExpired: false,
|
|
57
|
-
label: `${diff} ${unit}${diff > 1 ? 's' : ''} left`,
|
|
58
|
-
};
|
|
52
|
+
return Object.assign(Object.assign({}, baseMeta), { label: `${diff} ${unit}${diff > 1 ? 's' : ''} left` });
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
|
-
return {
|
|
62
|
-
icon: timerBlueIcon,
|
|
63
|
-
isExpired: false,
|
|
64
|
-
label: 'Less than a second left',
|
|
65
|
-
};
|
|
55
|
+
return Object.assign(Object.assign({}, baseMeta), { label: 'Less than a second left' });
|
|
66
56
|
}
|
|
67
57
|
export function isValidDate(input) {
|
|
68
58
|
return Boolean(input && dayjs(input).isValid());
|
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.386-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.386-test.5",
|
|
5
|
+
"testVersion": 5,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|