@tap-payments/os-micro-frontend-shared 0.1.259 → 0.1.261

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,13 @@
1
+ import { SxProps } from '@mui/material';
2
+ interface CountryFilterProps {
3
+ onCountriesChange: (countries: string[]) => void;
4
+ sx?: SxProps;
5
+ selectedCountries?: string[];
6
+ countriesOptions: {
7
+ label: string;
8
+ value: string;
9
+ icon: string;
10
+ }[];
11
+ }
12
+ export default function CountryFilter({ onCountriesChange, sx, selectedCountries, countriesOptions }: CountryFilterProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState } from 'react';
3
+ import Box from '@mui/material/Box';
4
+ import { ClickAwayListener } from '@mui/material';
5
+ import { Menu, MenuItem } from '../index.js';
6
+ import { rightArrow } from '../../constants/index.js';
7
+ export default function CountryFilter({ onCountriesChange, sx, selectedCountries, countriesOptions }) {
8
+ const [anchorEl, setAnchorEl] = useState(null);
9
+ const containerRef = useRef(null);
10
+ const open = Boolean(anchorEl);
11
+ const onOpen = () => {
12
+ if (!open) {
13
+ setAnchorEl(containerRef.current);
14
+ return;
15
+ }
16
+ onClose();
17
+ };
18
+ const onClose = () => {
19
+ setAnchorEl(null);
20
+ };
21
+ const checkIsSelected = (countryCode) => { var _a; return (_a = selectedCountries === null || selectedCountries === void 0 ? void 0 : selectedCountries.includes(countryCode)) !== null && _a !== void 0 ? _a : false; };
22
+ const onClickCountry = (countryCodes) => {
23
+ onCountriesChange(countryCodes);
24
+ };
25
+ const handleCheckboxChange = (value) => {
26
+ const newCountries = (selectedCountries === null || selectedCountries === void 0 ? void 0 : selectedCountries.includes(value)) ? selectedCountries === null || selectedCountries === void 0 ? void 0 : selectedCountries.filter((c) => c !== value) : [...(selectedCountries !== null && selectedCountries !== void 0 ? selectedCountries : []), value];
27
+ onClickCountry(newCountries);
28
+ onCountriesChange(newCountries);
29
+ };
30
+ const isAllCountriesSelected = useMemo(() => {
31
+ return (selectedCountries === null || selectedCountries === void 0 ? void 0 : selectedCountries.length) === countriesOptions.length;
32
+ }, [selectedCountries, countriesOptions]);
33
+ return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onClose }, { children: _jsxs(Box, Object.assign({ ref: containerRef, sx: sx }, { children: [_jsx(Box, { children: _jsxs(MenuItem, Object.assign({ onMouseEnter: (e) => {
34
+ e.stopPropagation();
35
+ onOpen();
36
+ }, sx: {
37
+ display: 'flex',
38
+ alignItems: 'center',
39
+ paddingInline: '16px',
40
+ gap: '4px',
41
+ borderBlock: '1px solid #F2F2F2',
42
+ '&:hover': {
43
+ backgroundColor: '#fff',
44
+ boxShadow: '0px 0px 16px 0px #00000021',
45
+ },
46
+ }, hideCheckbox: true }, { children: [_jsx("span", { children: "Country" }), _jsx(Box, { component: "img", src: rightArrow, width: 16, height: 12, sx: { marginLeft: 'auto' } })] })) }), _jsxs(Menu, Object.assign({ open: open, anchorEl: anchorEl, sx: { marginTop: '8px', marginBottom: '8px', maxHeight: '190px', overflow: 'auto' }, placement: "right-start", popperSx: {
47
+ zIndex: 99999,
48
+ } }, { children: [_jsx(MenuItem, Object.assign({ sx: {
49
+ color: (theme) => theme.palette.info.dark,
50
+ backgroundColor: '#F4F4F4',
51
+ fontWeight: 600,
52
+ paddingInline: '16px',
53
+ }, onClick: (e) => {
54
+ e.stopPropagation();
55
+ if (isAllCountriesSelected) {
56
+ onClickCountry([]);
57
+ onCountriesChange([]);
58
+ }
59
+ else {
60
+ onClickCountry(countriesOptions.map(({ value }) => value));
61
+ onCountriesChange(countriesOptions.map(({ value }) => value));
62
+ }
63
+ }, isSelected: isAllCountriesSelected }, { children: isAllCountriesSelected ? 'Unselect All' : 'Select All' })), countriesOptions.map(({ value, label, icon }) => (_jsxs(MenuItem, Object.assign({ sx: {
64
+ gap: '0px',
65
+ paddingInline: '16px',
66
+ '&:hover': {
67
+ backgroundColor: '#fff',
68
+ boxShadow: '0px 0px 16px 0px #00000021',
69
+ },
70
+ }, isSelected: checkIsSelected(value), onClick: () => handleCheckboxChange(value) }, { children: [_jsx(Box, { component: "img", src: icon, width: 16, height: 12, sx: { marginRight: '4px', borderRadius: '2px' } }), label] }), value)))] }))] })) })));
71
+ }
@@ -0,0 +1,2 @@
1
+ import CountryFilter from './CountryFilter';
2
+ export default CountryFilter;
@@ -0,0 +1,2 @@
1
+ import CountryFilter from './CountryFilter';
2
+ export default CountryFilter;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const FilterButton: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").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").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
5
+ isActive?: boolean | undefined;
6
+ }, {}, {}>;
@@ -0,0 +1,7 @@
1
+ import { Box, styled } from '@mui/material';
2
+ export const FilterButton = styled(Box, { shouldForwardProp: (props) => props !== 'isActive' })(({ theme, isActive }) => (Object.assign({ borderRadius: '4px', border: `1px solid ${theme.palette.divider}`, height: 32, width: 30, display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', backgroundColor: theme.palette.common.white, ':hover': {
3
+ opacity: 0.7,
4
+ } }, (isActive && {
5
+ boxShadow: `0px 0px 4px 0px ${theme.palette.info.dark}80`,
6
+ border: `1px solid ${theme.palette.info.dark}`,
7
+ }))));
@@ -0,0 +1,9 @@
1
+ import { Country } from '../../types/index.js';
2
+ export default function PhoneFilter({ onPhoneChange, onCountryChange, selectedPhone, selectedCountry, countriesOptions, isCountriesLoading, }: {
3
+ onPhoneChange: (phone: string) => void;
4
+ onCountryChange: (countryId: string) => void;
5
+ selectedPhone?: string;
6
+ selectedCountry?: Country;
7
+ countriesOptions: Country[];
8
+ isCountriesLoading: boolean;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { PhoneInputBase } from '../index.js';
3
+ export default function PhoneFilter({ onPhoneChange, onCountryChange, selectedPhone, selectedCountry, countriesOptions, isCountriesLoading, }) {
4
+ return (_jsx(PhoneInputBase, { "data-testid": `ColumnFilterInputs_PhoneInput`, phoneValue: selectedPhone, onPhoneChange: (val) => {
5
+ onPhoneChange(val);
6
+ }, countryValue: selectedCountry, onCountryChange: (c) => {
7
+ onCountryChange(c === null || c === void 0 ? void 0 : c.countryId);
8
+ }, countries: countriesOptions || [], isCountriesLoading: isCountriesLoading || false, hasError: false, disabled: isCountriesLoading, placeholder: 'User Mobile', sx: {
9
+ '&.MuiInputBase-root': {
10
+ paddingLeft: '0px !important',
11
+ },
12
+ } }));
13
+ }
@@ -0,0 +1,2 @@
1
+ import PhoneFilter from './PhoneFilter';
2
+ export default PhoneFilter;
@@ -0,0 +1,2 @@
1
+ import PhoneFilter from './PhoneFilter';
2
+ export default PhoneFilter;
@@ -128,3 +128,5 @@ export * from './VAT';
128
128
  export * from './Discount';
129
129
  export * from './MerchantLogo';
130
130
  export * from './FilterDropdown';
131
+ export { default as PhoneFilter } from './PhoneFilter';
132
+ export { default as CountryFilter } from './CountryFilter';
@@ -128,3 +128,5 @@ export * from './VAT';
128
128
  export * from './Discount';
129
129
  export * from './MerchantLogo';
130
130
  export * from './FilterDropdown';
131
+ export { default as PhoneFilter } from './PhoneFilter';
132
+ export { default as CountryFilter } from './CountryFilter';
@@ -843,6 +843,17 @@ export declare const APP_CODES: {
843
843
  };
844
844
  };
845
845
  };
846
+ appSettings: {
847
+ code: string;
848
+ functions: {
849
+ view: {
850
+ code: string;
851
+ };
852
+ update: {
853
+ code: string;
854
+ };
855
+ };
856
+ };
846
857
  };
847
858
  };
848
859
  order: {
@@ -320,6 +320,10 @@ export const APP_CODES = {
320
320
  code: 'BRAND',
321
321
  functions: { view: { code: 'VIEW' }, update: { code: 'UPDATE' } },
322
322
  },
323
+ appSettings: {
324
+ code: 'APP_SETTINGS',
325
+ functions: { view: { code: 'VIEW' }, update: { code: 'UPDATE' } },
326
+ },
323
327
  },
324
328
  },
325
329
  order: {
@@ -2,5 +2,6 @@ export declare enum ACCOUNT_SECTION {
2
2
  BRAND = "brand",
3
3
  ENTITY = "entity",
4
4
  USERS = "users",
5
- USER_ROLES = "userRoles"
5
+ USER_ROLES = "userRoles",
6
+ APP_SETTINGS = "appSettings"
6
7
  }
@@ -4,4 +4,5 @@ export var ACCOUNT_SECTION;
4
4
  ACCOUNT_SECTION["ENTITY"] = "entity";
5
5
  ACCOUNT_SECTION["USERS"] = "users";
6
6
  ACCOUNT_SECTION["USER_ROLES"] = "userRoles";
7
+ ACCOUNT_SECTION["APP_SETTINGS"] = "appSettings";
7
8
  })(ACCOUNT_SECTION || (ACCOUNT_SECTION = {}));
@@ -76,6 +76,19 @@ export type NavigateFunction = (params: {
76
76
  sandboxMode?: boolean;
77
77
  state?: any;
78
78
  }) => void;
79
+ export interface PreviewStorageData {
80
+ id: string;
81
+ img: string;
82
+ timestamp: number;
83
+ }
84
+ export interface PreviewData {
85
+ id: string;
86
+ img: string;
87
+ isGenerating: boolean;
88
+ serviceCode?: string;
89
+ appCode: string;
90
+ isMinimized: boolean;
91
+ }
79
92
  export type MFWidgetBaseProps = {
80
93
  windowId: string;
81
94
  i18n?: i18n;
@@ -1,4 +1,4 @@
1
- import { AppDetails, Segment, TableMode, Timezone } from '../types/index.js';
1
+ import { AppDetails, PreviewData, Segment, TableMode, Timezone } from '../types/index.js';
2
2
  import { SheetViewColumnsData } from './columnResizeStorage';
3
3
  export declare function setSecretKey(): void;
4
4
  export declare function getSecretKey(): string | null;
@@ -32,4 +32,7 @@ export declare const getGlobalTableModeStorage: () => TableMode;
32
32
  export declare const removeGlobalTableModeStorage: () => void;
33
33
  export declare const setSheetViewColumnsStorage: (data: SheetViewColumnsData) => void;
34
34
  export declare const getSheetViewColumnsStorage: () => SheetViewColumnsData;
35
+ export declare const setPreviewStorage: (previews: PreviewData[]) => void;
36
+ export declare const getPreviewStorage: () => Map<string, string>;
37
+ export declare const removePreviewStorage: () => void;
35
38
  export declare const clearTapOsLocalStorage: () => void;
@@ -12,6 +12,7 @@ const CALENDER_TIMEZONE = 'tap-dashboard-calender-timezone';
12
12
  const CALENDER_TIMEZONE_HISTORY = 'tap-dashboard-calender-timezone-history';
13
13
  const GLOBAL_TABLE_MODE_KEY = 'tap-dashboard-global-table-mode';
14
14
  const SHEETVIEW_COLUMNS_KEY = 'sheetview_columns';
15
+ const PREVIEW_STORAGE_KEY = 'dock-preview-windows';
15
16
  export function setSecretKey() {
16
17
  localStorage.setItem(SECRET_KEY_LOCAL_STORAGE, TEST_SECRET_KEY);
17
18
  }
@@ -169,6 +170,45 @@ export const removeGlobalTableModeStorage = () => {
169
170
  };
170
171
  export const setSheetViewColumnsStorage = (data) => localStorage.setItem(SHEETVIEW_COLUMNS_KEY, JSON.stringify(data));
171
172
  export const getSheetViewColumnsStorage = () => JSON.parse(localStorage.getItem(SHEETVIEW_COLUMNS_KEY) || '{}');
173
+ export const setPreviewStorage = (previews) => {
174
+ try {
175
+ const data = previews
176
+ .filter((p) => p.img)
177
+ .map((p) => ({
178
+ id: p.id,
179
+ img: p.img,
180
+ timestamp: Date.now(),
181
+ }));
182
+ localStorage.setItem(PREVIEW_STORAGE_KEY, JSON.stringify(data));
183
+ }
184
+ catch (error) {
185
+ console.warn('Failed to save preview cache:', error);
186
+ }
187
+ };
188
+ export const getPreviewStorage = () => {
189
+ try {
190
+ const cached = localStorage.getItem(PREVIEW_STORAGE_KEY);
191
+ if (!cached)
192
+ return new Map();
193
+ const data = JSON.parse(cached);
194
+ const previewMap = new Map();
195
+ data.forEach((item) => {
196
+ previewMap.set(item.id, item.img);
197
+ });
198
+ return previewMap;
199
+ }
200
+ catch (error) {
201
+ return new Map();
202
+ }
203
+ };
204
+ export const removePreviewStorage = () => {
205
+ try {
206
+ localStorage.removeItem(PREVIEW_STORAGE_KEY);
207
+ }
208
+ catch (error) {
209
+ console.warn('Failed to remove preview storage:', error);
210
+ }
211
+ };
172
212
  export const clearTapOsLocalStorage = () => {
173
213
  removeSecretKey();
174
214
  removeConnectMetaData();
@@ -180,4 +220,5 @@ export const clearTapOsLocalStorage = () => {
180
220
  removeCalenderTimezone();
181
221
  removeCalenderTimezoneHistory();
182
222
  removeGlobalTableModeStorage();
223
+ removePreviewStorage();
183
224
  };
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.259",
4
+ "version": "0.1.261",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",