@tap-payments/os-micro-frontend-shared 0.1.289 → 0.1.290

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.
@@ -0,0 +1,16 @@
1
+ import { CalenderMode, Timezone } from '../../types/index.js';
2
+ export interface DateFilterProps {
3
+ title?: string;
4
+ onConfirm: (dateRange: [Date, Date] | undefined) => void;
5
+ onClear: () => void;
6
+ dateRange?: [Date, Date];
7
+ onDateRangeChange: (dateRange?: [Date, Date]) => void;
8
+ calendarMode: CalenderMode;
9
+ onCalendarModeChange: (calenderMode: CalenderMode) => void;
10
+ timezone: Timezone | null;
11
+ onTimezoneChange: (timezone: Timezone) => void;
12
+ browserTimezone: string;
13
+ defaultCountryTimezone: Timezone;
14
+ timezoneCountriesCodes: string[];
15
+ }
16
+ export default function DateFilter({ title, dateRange, onDateRangeChange, calendarMode, onCalendarModeChange, timezone, browserTimezone, defaultCountryTimezone, onTimezoneChange, timezoneCountriesCodes, onConfirm, onClear, }: Readonly<DateFilterProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useState } from 'react';
3
+ import dayjs from 'dayjs';
4
+ import Box from '@mui/material/Box';
5
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
6
+ import { calenderIcon, closeIcon, columnIcon, whiteFilterIcon } from '../../constants/index.js';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { Dropdown, Item, Filter, OkayButton, CancelButton, Footer, TitleStyled, FilterHeader, FilterWrapper, SelectedDate } from './style';
9
+ import { Icon, RangeCalender } from '../index.js';
10
+ import { getDefaultDateRange } from '../../utils/index.js';
11
+ export default function DateFilter({ title = 'Date', dateRange, onDateRangeChange, calendarMode, onCalendarModeChange, timezone, browserTimezone, defaultCountryTimezone, onTimezoneChange, timezoneCountriesCodes = [], onConfirm, onClear, }) {
12
+ const { t } = useTranslation();
13
+ const [anchorEl, setAnchorEl] = useState(null);
14
+ const open = Boolean(anchorEl);
15
+ const onOpen = (e) => setAnchorEl(e.currentTarget);
16
+ const onClose = () => setAnchorEl(null);
17
+ const onCancel = () => onClose();
18
+ const handleOkButtonClick = () => {
19
+ onClose();
20
+ onConfirm(dateRange);
21
+ };
22
+ const handleCalendarModeSwitch = useCallback((newMode) => onCalendarModeChange(newMode), [onCalendarModeChange]);
23
+ const getSelectedDateLabel = (dates) => {
24
+ if (!dates)
25
+ return '';
26
+ const [start, end] = dates;
27
+ const startLabel = dayjs(start).format('MMM D');
28
+ const endLabel = dayjs(end).format('MMM D');
29
+ return startLabel === endLabel ? startLabel : `${startLabel} - ${endLabel}`;
30
+ };
31
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onClose }, { children: _jsxs(Box, { children: [_jsxs(Box, Object.assign({ sx: { cursor: 'pointer', display: 'flex', alignItems: 'center', gap: '4px' }, onClick: onOpen }, { children: [title, dateRange ? (_jsxs(FilterWrapper, { children: [_jsx(Box, { component: "img", src: whiteFilterIcon, alt: "filter-icon", sx: { marginInlineEnd: '2px', height: 6 }, onClick: onOpen }), _jsx(Box, { component: "img", src: closeIcon, alt: "close-icon", onClick: onClear })] })) : (_jsx(Box, { component: "img", src: columnIcon, alt: "column-icon", sx: { cursor: 'pointer', marginTop: '2px' } }))] })), _jsxs(Dropdown, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start" }, { children: [_jsxs(Filter, { children: [_jsx(FilterHeader, { children: _jsx(TitleStyled, Object.assign({ component: "span" }, { children: t('filterBy') })) }), _jsx(Item, { children: _jsx(RangeCalender, { defaultDate: dateRange || getDefaultDateRange(0), onDateChange: onDateRangeChange, maxDateRange: 365, mode: calendarMode, onCalendarModeSwitch: handleCalendarModeSwitch, browserTimezone: browserTimezone, defaultCountryTimezone: defaultCountryTimezone, timezone: timezone, onChangeTimezone: onTimezoneChange, timezoneCountriesCodes: timezoneCountriesCodes, mainSx: { width: '100%' }, popperProps: { placement: 'right-start' }, renderCalendarButton: (isOpen, openCal) => (_jsxs(SelectedDate, Object.assign({ open: isOpen, onClick: openCal }, { children: [_jsx("span", { children: getSelectedDateLabel(dateRange) || 'Date' }), _jsx(Icon, { src: calenderIcon, alt: "selected", sx: { width: 16, height: 16 } })] }))) }, getSelectedDateLabel(dateRange)) }), dateRange && (_jsx(TitleStyled, Object.assign({ component: "span", sx: { color: '#1F88D0', padding: '4px 24px' }, onClick: () => onDateRangeChange(undefined) }, { children: "Clear" })))] }), _jsxs(Footer, { children: [_jsx(CancelButton, Object.assign({ onClick: onCancel }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ onClick: handleOkButtonClick }, { children: t('okay') }))] })] }))] }) })));
32
+ }
@@ -0,0 +1 @@
1
+ export { default as DateFilter, type DateFilterProps } from './DateFilter';
@@ -0,0 +1 @@
1
+ export { default as DateFilter } from './DateFilter';
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ export declare const Content: 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
+ 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 Label: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
6
+ ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
7
+ }, "width" | "minHeight" | "height" | "bottom" | "left" | "right" | "top" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "visibility" | "whiteSpace" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "classes" | "align" | "className" | "style" | "children" | "gutterBottom" | "noWrap" | "paragraph" | "sx" | "variant" | "variantMapping"> & {
8
+ component?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
9
+ } & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
10
+ export declare const Dropdown: import("@emotion/styled").StyledComponent<Omit<import("../Menu/Menu").MenuProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
11
+ export declare const Item: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
12
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
13
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
14
+ export declare const Footer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
15
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
16
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
17
+ export declare const OkayButton: import("@emotion/styled").StyledComponent<import("../Button/Button").ButtonI & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
18
+ export declare const CancelButton: import("@emotion/styled").StyledComponent<import("../Button/Button").ButtonI & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
19
+ export declare const Filter: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
20
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
21
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
22
+ export declare const TitleStyled: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
23
+ ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
24
+ }, "width" | "minHeight" | "height" | "bottom" | "left" | "right" | "top" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "visibility" | "whiteSpace" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "classes" | "align" | "className" | "style" | "children" | "gutterBottom" | "noWrap" | "paragraph" | "sx" | "variant" | "variantMapping"> & {
25
+ component?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
26
+ } & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
27
+ export declare const FilterHeader: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
28
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
29
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
30
+ export declare const SelectedDate: import("@emotion/styled").StyledComponent<import("../Button/Button").ButtonI & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
31
+ open: boolean;
32
+ }, {}, {}>;
33
+ export declare const FilterWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
34
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
35
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
@@ -0,0 +1,100 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@mui/material/styles';
3
+ import { Button, Menu, Text } from '../index.js';
4
+ export const Content = styled(Box)(() => ({
5
+ paddingBlock: '8px',
6
+ display: 'flex',
7
+ gap: '12px',
8
+ flexDirection: 'column',
9
+ }));
10
+ export const Label = styled(Text)(() => ({
11
+ fontSize: '11px',
12
+ }));
13
+ export const Dropdown = styled(Menu)(() => ({
14
+ marginTop: '8px',
15
+ marginBottom: '8px',
16
+ }));
17
+ export const Item = styled(Box)(() => ({
18
+ display: 'flex',
19
+ alignItems: 'center',
20
+ gap: '4px',
21
+ width: '100%',
22
+ paddingInline: '16px',
23
+ }));
24
+ export const Footer = styled(Box)(({ theme }) => ({
25
+ padding: '8px 16px',
26
+ display: 'flex',
27
+ gap: '8px',
28
+ justifyContent: 'flex-end',
29
+ position: 'sticky',
30
+ bottom: 0,
31
+ backgroundColor: 'white',
32
+ zIndex: 99999,
33
+ borderTop: `1px solid ${theme.palette.divider}`,
34
+ }));
35
+ export const OkayButton = styled(Button)(({ theme }) => ({
36
+ textTransform: 'capitalize',
37
+ minWidth: 'auto',
38
+ width: 70,
39
+ borderRadius: '4px',
40
+ border: `1px solid ${theme.palette.info.dark}`,
41
+ backgroundColor: theme.palette.info.dark,
42
+ fontWeight: 700,
43
+ fontSize: '11px',
44
+ color: theme.palette.common.white,
45
+ '&:hover': {
46
+ backgroundColor: theme.palette.info.dark,
47
+ },
48
+ '&.Mui-disabled': {
49
+ color: '#fff !important',
50
+ opacity: 0.5,
51
+ },
52
+ }));
53
+ export const CancelButton = styled(Button)(({ theme }) => ({
54
+ textTransform: 'capitalize',
55
+ minWidth: 'auto',
56
+ width: 70,
57
+ borderRadius: '4px',
58
+ border: `1px solid ${theme.palette.divider}`,
59
+ backgroundColor: theme.palette.common.white,
60
+ fontWeight: 500,
61
+ fontSize: '11px',
62
+ color: theme.palette.text.primary,
63
+ '&:hover': {
64
+ background: 'transparent',
65
+ },
66
+ }));
67
+ export const Filter = styled(Box)(() => ({
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ gap: '8px',
71
+ marginBottom: '8px',
72
+ }));
73
+ export const TitleStyled = styled(Label)(() => ({
74
+ fontSize: '11px',
75
+ fontWeight: 500,
76
+ color: '#8D8D94',
77
+ padding: '8px 16px',
78
+ }));
79
+ export const FilterHeader = styled(Box)(({ theme }) => ({
80
+ borderBlock: `1px solid ${theme.palette.divider}`,
81
+ display: 'flex',
82
+ justifyContent: 'space-between',
83
+ alignItems: 'center',
84
+ gap: '2px',
85
+ width: '100%',
86
+ }));
87
+ export const SelectedDate = styled(Button, { shouldForwardProp: (props) => props !== 'open' })(({ open, theme }) => (Object.assign({ color: theme.palette.text.primary, fontSize: '11px', fontWeight: 500, padding: theme.spacing(1), borderRadius: '4px', border: '1px solid', borderColor: theme.palette.divider, background: theme.palette.common.white, textTransform: 'none', width: '100%', height: 32, justifyContent: 'space-between', gap: '4px' }, (open && { border: '1px solid', borderColor: theme.palette.info.dark, boxShadow: theme.shadows[7] }))));
88
+ export const FilterWrapper = styled(Box)(({ theme }) => ({
89
+ background: theme.palette.grey[700],
90
+ width: 27,
91
+ height: 14,
92
+ display: 'inline-flex',
93
+ alignItems: 'center',
94
+ marginInlineStart: '4px',
95
+ borderRadius: '10px',
96
+ padding: '2px 6px',
97
+ img: {
98
+ cursor: 'pointer',
99
+ },
100
+ }));
@@ -144,3 +144,4 @@ export * from './StatusFilter';
144
144
  export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
+ export * from './DateFilter';
@@ -144,3 +144,4 @@ export * from './StatusFilter';
144
144
  export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
+ export * from './DateFilter';
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.289",
4
+ "version": "0.1.290",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",