@tap-payments/os-micro-frontend-shared 0.1.260 → 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 = {}));
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.260",
4
+ "version": "0.1.261",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",