@tap-payments/os-micro-frontend-shared 0.1.296 → 0.1.298

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,10 @@
1
+ interface PartnersFilterProps {
2
+ options: {
3
+ label: string;
4
+ value: string;
5
+ }[];
6
+ selectedFilters?: Record<string, boolean | undefined>;
7
+ onChange: (filters: Record<string, boolean | undefined>) => void;
8
+ }
9
+ export default function PartnersFilter({ options, selectedFilters, onChange }: Readonly<PartnersFilterProps>): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from 'react';
3
+ import { Popper } from '@mui/material';
4
+ import Box from '@mui/material/Box';
5
+ import { MenuItem, RadioGroup } from '../index.js';
6
+ import { rightArrow } from '../../constants/index.js';
7
+ import { StatusValue } from '../../types/index.js';
8
+ export default function PartnersFilter({ options, selectedFilters, onChange }) {
9
+ const [childAnchorEl, setChildAnchorEl] = useState(null);
10
+ const [hoveredStatus, setHoveredStatus] = useState(null);
11
+ const onChildLeave = useCallback(() => {
12
+ setChildAnchorEl(null);
13
+ setHoveredStatus(null);
14
+ }, []);
15
+ const getSelectedValue = (value) => {
16
+ return value === StatusValue.ALL ? undefined : value === StatusValue.ENABLED;
17
+ };
18
+ const onClickStatus = (value) => {
19
+ if (hoveredStatus) {
20
+ onChange({ [hoveredStatus]: getSelectedValue(value) });
21
+ }
22
+ };
23
+ const radioSelectedValue = useMemo(() => {
24
+ const value = selectedFilters === null || selectedFilters === void 0 ? void 0 : selectedFilters[hoveredStatus || ''];
25
+ return value === undefined ? StatusValue.ALL : value ? StatusValue.ENABLED : StatusValue.DISABLED;
26
+ }, [selectedFilters, hoveredStatus]);
27
+ return (_jsxs(_Fragment, { children: [options.map(({ label, value }, index) => (_jsxs(MenuItem, Object.assign({ onMouseOver: (e) => {
28
+ setChildAnchorEl(e.currentTarget);
29
+ setHoveredStatus(value);
30
+ }, sx: Object.assign({ minHeight: '35px', padding: '8px 16px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', '&:hover': { backgroundColor: '#fff', boxShadow: '0px 0px 16px 0px #00000021' } }, (index === options.length - 1 && {
31
+ borderBottom: '1px solid #F2F2F2',
32
+ })), hideCheckbox: true }, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: '4px' } }, { children: label })), _jsx(Box, { component: "img", src: rightArrow, width: 16, height: 12, sx: { marginLeft: 'auto' } })] }), value))), _jsx(Popper, Object.assign({ open: Boolean(childAnchorEl), anchorEl: childAnchorEl, placement: "right-start", onMouseLeave: onChildLeave }, { children: _jsx(Box, Object.assign({ sx: {
33
+ backgroundColor: '#fff',
34
+ borderEndEndRadius: '8px',
35
+ border: '1px solid #F2F2F2',
36
+ } }, { children: _jsx(RadioGroup, { options: [
37
+ {
38
+ value: StatusValue.ALL,
39
+ label: 'All',
40
+ },
41
+ {
42
+ value: StatusValue.ENABLED,
43
+ label: 'Available',
44
+ },
45
+ {
46
+ value: StatusValue.DISABLED,
47
+ label: 'Not Available',
48
+ },
49
+ ], value: radioSelectedValue, onOptionChange: onClickStatus }) })) }))] }));
50
+ }
@@ -0,0 +1 @@
1
+ export { default as PartnersFilter } from './PartnersFilter';
@@ -0,0 +1 @@
1
+ export { default as PartnersFilter } from './PartnersFilter';
@@ -0,0 +1,11 @@
1
+ import { OptionsListItem } from '../../types/index.js';
2
+ interface SalesChannelFilterProps {
3
+ onSalesChannelChange: (salesChannels: OptionsListItem[] | undefined) => void;
4
+ onSearchChange: (searchValue: string) => void;
5
+ filteredOptions: OptionsListItem[];
6
+ isLoading: boolean;
7
+ initialSalesChannels?: OptionsListItem[];
8
+ initialSalesChannelsSearch?: string;
9
+ }
10
+ export default function SalesChannelFilter({ onSalesChannelChange, onSearchChange, filteredOptions, isLoading, initialSalesChannels, initialSalesChannelsSearch, }: Readonly<SalesChannelFilterProps>): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import Box from '@mui/material/Box';
4
+ import { MenuItem, Skeleton } from '../index.js';
5
+ import { FilterWrapper, ListWrapper, SearchIconWrapper } from './style';
6
+ import { InputStyled } from '../SelectWithSearch';
7
+ import { closeXIcon, searchIcon } from '../../constants/index.js';
8
+ export default function SalesChannelFilter({ onSalesChannelChange, onSearchChange, filteredOptions, isLoading, initialSalesChannels, initialSalesChannelsSearch, }) {
9
+ const salesChannels = useMemo(() => {
10
+ return initialSalesChannels || [];
11
+ }, [initialSalesChannels]);
12
+ const [searchValue, setSearchValue] = useState(initialSalesChannelsSearch || '');
13
+ const checkIsSelected = (salesChannelId) => salesChannels.some((channel) => channel.id === salesChannelId);
14
+ const isAllSelected = useMemo(() => {
15
+ return (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.length) === filteredOptions.length && (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) > 0;
16
+ }, [salesChannels, filteredOptions]);
17
+ const isOnlyBlankSelected = useMemo(() => {
18
+ return (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.some((channel) => channel.id === 'blank')) && (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.length) === 1;
19
+ }, [salesChannels]);
20
+ const isSearchDisabled = useMemo(() => {
21
+ return (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.length) === 0 || isOnlyBlankSelected;
22
+ }, [isOnlyBlankSelected, salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.length]);
23
+ return (_jsxs(FilterWrapper, { children: [_jsx(InputStyled, { placeholder: 'Search', endAdornment: !isSearchDisabled && (_jsx(SearchIconWrapper, Object.assign({ sx: Object.assign({}, (searchValue && { backgroundColor: '#F2F2F2' })) }, { children: _jsx(Box, { component: "img", src: searchValue ? closeXIcon : searchIcon, alt: "search", onClick: () => {
24
+ setSearchValue('');
25
+ onSearchChange('');
26
+ }, sx: Object.assign({}, (searchValue && {
27
+ backgroundColor: '#F2F2F2',
28
+ borderRadius: '4px',
29
+ width: '8px',
30
+ height: '8px',
31
+ })) }) }))), disabled: isSearchDisabled, onChange: (e) => {
32
+ setSearchValue(e.target.value);
33
+ onSearchChange(e.target.value);
34
+ }, value: searchValue, disableUnderline: true, sx: Object.assign({ cursor: 'default', width: '100%', border: '1px solid #F2F2F2', backgroundColor: isSearchDisabled ? '#F8F8F8' : '#fff' }, (searchValue && { cursor: 'pointer' })) }), _jsx(ListWrapper, { children: isLoading ? (Array.from({ length: 9 }).map((_, index) => _jsx(Skeleton, { variant: "rectangular", width: "100%", height: 24 }, index))) : (_jsxs(_Fragment, { children: [_jsx(MenuItem, Object.assign({ sx: {
35
+ backgroundColor: '#F8F8F8',
36
+ fontWeight: 600,
37
+ padding: '4px 8px',
38
+ color: '#1F88D0',
39
+ gap: '0px',
40
+ }, isSelected: isAllSelected, isIndeterminate: !isAllSelected && ((salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.length) || 0) > 0, onClick: (e) => {
41
+ e.stopPropagation();
42
+ onSalesChannelChange(isAllSelected ? [] : filteredOptions);
43
+ } }, { children: isAllSelected ? 'Deselect All' : 'Select All' })), filteredOptions.map((channel) => {
44
+ var _a;
45
+ return (_jsx(MenuItem, Object.assign({ isSelected: checkIsSelected(channel.id), onClick: (e) => {
46
+ e.stopPropagation();
47
+ const isSelected = checkIsSelected(channel.id);
48
+ const newSalesChannels = isSelected ? salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.filter((c) => c.id !== channel.id) : [...(salesChannels !== null && salesChannels !== void 0 ? salesChannels : []), channel];
49
+ onSalesChannelChange(newSalesChannels);
50
+ }, sx: {
51
+ padding: '4px 8px',
52
+ gap: '0px',
53
+ fontWeight: 400,
54
+ } }, { children: (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.en }), channel.id));
55
+ })] })) })] }));
56
+ }
@@ -0,0 +1 @@
1
+ export { default as SalesChannelFilter } from './SalesChannelFilter';
@@ -0,0 +1 @@
1
+ export { default as SalesChannelFilter } from './SalesChannelFilter';
@@ -0,0 +1,15 @@
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
+ }, {}, {}>;
7
+ export declare const ListWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
8
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
9
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
10
+ export declare const FilterWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
11
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
12
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
13
+ export declare const SearchIconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
14
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
15
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -0,0 +1,29 @@
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
+ }))));
8
+ export const ListWrapper = styled(Box)(({ theme }) => ({
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ borderRadius: '8px',
12
+ border: `1px solid ${theme.palette.divider}`,
13
+ backgroundColor: theme.palette.common.white,
14
+ maxHeight: '232px',
15
+ overflow: 'auto',
16
+ }));
17
+ export const FilterWrapper = styled(Box)(() => ({
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ gap: '8px',
21
+ }));
22
+ export const SearchIconWrapper = styled(Box)(() => ({
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ width: '13px',
27
+ height: '13px',
28
+ borderRadius: '50%',
29
+ }));
@@ -1,6 +1,5 @@
1
1
  import { CustomColumnFilterProps } from '../VirtualTables';
2
- import { StatusValue } from './type';
3
- import { ColumnFilterValues } from '../../types/index.js';
2
+ import { ColumnFilterValues, StatusValue } from '../../types/index.js';
4
3
  interface StatusFilterProps extends CustomColumnFilterProps {
5
4
  options: {
6
5
  icon: string;
@@ -6,8 +6,8 @@ import { Menu, MenuItem, RadioGroup } from '../index.js';
6
6
  import { FilterCancelButton, FilterFooter, FilterOkayButton, FilterTitle } from '../Filters';
7
7
  import { rightArrow } from '../../constants/index.js';
8
8
  import { ClickAwayListener, Popper } from '@mui/material';
9
- import { StatusValue } from './type';
10
9
  import { getInitialStatuses } from './utils';
10
+ import { StatusValue } from '../../types/index.js';
11
11
  export default function StatusFilter({ anchorEl, options, apiKey = 'statuses', initialStatuses, onCloseDropdown, onClear, onConfirm, }) {
12
12
  const open = Boolean(anchorEl);
13
13
  const { t } = useTranslation();
@@ -1,4 +1,4 @@
1
- import { StatusValue } from './type';
1
+ import { StatusValue } from '../../types/index.js';
2
2
  export declare const getInitialStatuses: (statuses?: Record<string, StatusValue>, options?: {
3
3
  value: string;
4
4
  }[]) => Record<string, StatusValue>;
@@ -1,4 +1,4 @@
1
- import { StatusValue } from './type';
1
+ import { StatusValue } from '../../types/index.js';
2
2
  export const getInitialStatuses = (statuses, options) => {
3
3
  const rawStatuses = (statuses || {});
4
4
  const mappedStatuses = {};
@@ -148,3 +148,5 @@ export * from './PaymentSourceFilter';
148
148
  export * from './DateFilter';
149
149
  export * from './CurrencyFilter';
150
150
  export * from './AmountConversionFilter';
151
+ export * from './PartnersFilter';
152
+ export * from './SalesChannelFilter';
@@ -148,3 +148,5 @@ export * from './PaymentSourceFilter';
148
148
  export * from './DateFilter';
149
149
  export * from './CurrencyFilter';
150
150
  export * from './AmountConversionFilter';
151
+ export * from './PartnersFilter';
152
+ export * from './SalesChannelFilter';
@@ -28,3 +28,5 @@ export * from './appEvents';
28
28
  export * from './common';
29
29
  export * from './discount';
30
30
  export * from './receipt';
31
+ export * from './filter';
32
+ export * from './utilities';
@@ -28,3 +28,5 @@ export * from './appEvents';
28
28
  export * from './common';
29
29
  export * from './discount';
30
30
  export * from './receipt';
31
+ export * from './filter';
32
+ export * from './utilities';
@@ -0,0 +1,24 @@
1
+ export type OptionsListItem = {
2
+ id: string;
3
+ logo?: string;
4
+ code?: string;
5
+ name: {
6
+ ar: string;
7
+ en: string;
8
+ };
9
+ currency_code?: string[];
10
+ country_code?: string[];
11
+ range?: {
12
+ from: number;
13
+ to: number;
14
+ };
15
+ sub?: {
16
+ id: string;
17
+ logo: string;
18
+ code: string;
19
+ name: {
20
+ ar: string;
21
+ en: string;
22
+ };
23
+ }[];
24
+ };
@@ -0,0 +1 @@
1
+ export {};
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.296",
4
+ "version": "0.1.298",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",