@tap-payments/os-micro-frontend-shared 0.1.286-test.3 → 0.1.287-test.1

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.
@@ -9,6 +9,7 @@ import { InputStyled, TotalAmountWrapper, Error } from './style';
9
9
  import { Loading } from './Loading';
10
10
  const isSafari = isSafariBrowser();
11
11
  function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMissing, isDisabled, isLoading, onResetAllItems, onAddFirstItem, }) {
12
+ var _a;
12
13
  const [editMode, setEditMode] = useState(false);
13
14
  const [amount, setAmount] = useState();
14
15
  const { isConfirmed } = useConfirmDialog();
@@ -43,6 +44,7 @@ function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMiss
43
44
  onAddFirstItem(Number(numberToString(Number(e.target.value), selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals)));
44
45
  };
45
46
  const isEditable = totalGrossAmount === 0 || (items.length === 1 && totalGrossAmount === items[0].total);
47
+ const currencyCode = ((_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english) || '';
46
48
  if (isLoading) {
47
49
  return _jsx(Loading, {});
48
50
  }
@@ -50,9 +52,9 @@ function TotalAmount({ totalGrossAmount, items, selectedCurrency, isAmountIsMiss
50
52
  if (isSafari && isNaN(Number(evt.key)) && evt.key !== 'Backspace' && evt.key !== '.') {
51
53
  evt.preventDefault();
52
54
  }
53
- }, autoFocus: true })) : (_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, amount: totalGrossAmount || 0, selectedCurrency: selectedCurrency, onClick: () => {
55
+ }, autoFocus: true })) : (_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, amount: totalGrossAmount || 0, currencyCode: currencyCode, onClick: () => {
54
56
  setEditMode(true);
55
- } })) })) : (_jsxs(TotalAmountWrapper, { children: [_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, selectedCurrency: selectedCurrency, amount: totalGrossAmount || 0, onClick: () => {
57
+ } })) })) : (_jsxs(TotalAmountWrapper, { children: [_jsx(DisplayAmount, { sx: { fontSize: '36px', textAlign: 'center' }, currencyCode: currencyCode, amount: totalGrossAmount || 0, onClick: () => {
56
58
  if (isEditable)
57
59
  setEditMode(true);
58
60
  } }), totalGrossAmount > 0 && _jsx(Box, { component: "img", src: removeAllItem, alt: "r", onClick: removeAllItems })] })), isAmountIsMissing && (_jsxs(Error, { children: [_jsx(Box, { component: "img", src: unknownIcon }), _jsx(Box, { children: t('enterAmount') })] }))] })));
@@ -9,6 +9,6 @@ interface AmountInputI extends BoxProps {
9
9
  placeholder?: string;
10
10
  selectedCurrency: Currency;
11
11
  }
12
- declare function AmountInput({ amount, setAmount, placeholder, maxAmount, isError, selectedCurrency, ...props }: AmountInputI): import("react/jsx-runtime").JSX.Element;
12
+ declare function AmountInput({ amount, setAmount, maxAmount, isError, selectedCurrency, ...props }: AmountInputI): import("react/jsx-runtime").JSX.Element;
13
13
  declare const _default: import("react").MemoExoticComponent<typeof AmountInput>;
14
14
  export default _default;
@@ -16,7 +16,8 @@ import { DisplayAmount } from '../index.js';
16
16
  import { Wrapper, InputStyled } from './style';
17
17
  const isSafari = isSafariBrowser();
18
18
  function AmountInput(_a) {
19
- var { amount, setAmount, placeholder, maxAmount, isError, selectedCurrency } = _a, props = __rest(_a, ["amount", "setAmount", "placeholder", "maxAmount", "isError", "selectedCurrency"]);
19
+ var _b;
20
+ var { amount, setAmount, maxAmount, isError, selectedCurrency } = _a, props = __rest(_a, ["amount", "setAmount", "maxAmount", "isError", "selectedCurrency"]);
20
21
  const [editMode, setEditMode] = useState(false);
21
22
  const [value, setValue] = useState(amount || '');
22
23
  const currencyPlaceholder = useMemo(() => getAmountPlaceholder(selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals), [selectedCurrency]);
@@ -36,7 +37,7 @@ function AmountInput(_a) {
36
37
  evt.preventDefault();
37
38
  }
38
39
  };
39
- return (_jsx(Wrapper, Object.assign({ sx: props.sx }, { children: editMode ? (_jsx(InputStyled, { placeholder: currencyPlaceholder, value: value, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, isError: isError, inputProps: { step: '0.01' }, hideArrows: true, autoFocus: true })) : (_jsx(DisplayAmount, { selectedCurrency: selectedCurrency, amount: amount, onClick: () => {
40
+ return (_jsx(Wrapper, Object.assign({ sx: props.sx }, { children: editMode ? (_jsx(InputStyled, { placeholder: currencyPlaceholder, value: value, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, isError: isError, inputProps: { step: '0.01' }, hideArrows: true, autoFocus: true })) : (_jsx(DisplayAmount, { currencyCode: (_b = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _b === void 0 ? void 0 : _b.english, amount: amount, onClick: () => {
40
41
  setEditMode(true);
41
42
  } })) })));
42
43
  }
@@ -20,9 +20,10 @@ function TotalDiscount({ selectedCurrency, totalGrossAmount, totalDiscount, onCh
20
20
  onChangeTotalDiscount(Object.assign(Object.assign({}, newDiscount), { value: getDiscountValue(totalGrossAmount, newDiscount) }));
21
21
  };
22
22
  const getLabel = () => {
23
+ var _a;
23
24
  if (totalDiscount.value === 0)
24
25
  return t('noDiscount');
25
- return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '2px' } }, { children: [_jsx("span", { children: "-" }), _jsx(DisplayAmount, { amount: totalDiscount.value, selectedCurrency: selectedCurrency })] })));
26
+ return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '2px' } }, { children: [_jsx("span", { children: "-" }), _jsx(DisplayAmount, { amount: totalDiscount.value, currencyCode: (_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english })] })));
26
27
  };
27
28
  return (_jsxs(LabelWrapper, Object.assign({ isOpen: isOpen, isDisabled: isDisabled, onClick: toggleDropdown, ref: discountButtonRef, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [_jsx("img", { src: discountIcon, alt: "p" }), _jsx(Label, Object.assign({ isDisabled: isDisabled }, { children: getLabel() })), _jsx(Box, { component: "img", src: isOpen ? activeActionIcon : actionsIcon, alt: "a" }), isOpen && _jsx(CustomBackdrop, { onClick: toggleDropdown }), _jsx(Popper, Object.assign({ open: Boolean(isOpen), anchorEl: discountButtonRef.current, placement: "bottom-start" }, { children: _jsx(DiscountDropdown, { sx: { position: 'absolute', top: 8, left: 0, display: isOpen ? 'block' : 'none' }, selectedCurrency: selectedCurrency, discount: totalDiscount, setDiscount: handleDiscount, setIsOpen: setIsOpen, maxDiscount: Number(totalGrossAmount) }) }))] })));
28
29
  }
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@mui/material/Box';
3
- import { Currency } from '../../types/index.js';
4
3
  interface DisplayAmountI extends BoxProps {
5
4
  amount: number;
6
- selectedCurrency: Currency;
5
+ currencyCode: string;
7
6
  }
8
- declare function DisplayAmount({ amount, selectedCurrency, ...props }: DisplayAmountI): import("react/jsx-runtime").JSX.Element;
7
+ declare function DisplayAmount({ amount, currencyCode, ...props }: DisplayAmountI): import("react/jsx-runtime").JSX.Element;
9
8
  declare const _default: import("react").MemoExoticComponent<typeof DisplayAmount>;
10
9
  export default _default;
@@ -14,9 +14,8 @@ import { memo } from 'react';
14
14
  import { formatAmountWithCurrency } from '../../utils/index.js';
15
15
  import { DecimalSpan, CurrencySpan } from './style';
16
16
  function DisplayAmount(_a) {
17
- var _b;
18
- var { amount, selectedCurrency } = _a, props = __rest(_a, ["amount", "selectedCurrency"]);
19
- const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, (_b = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _b === void 0 ? void 0 : _b.english);
17
+ var { amount, currencyCode } = _a, props = __rest(_a, ["amount", "currencyCode"]);
18
+ const { integerAmount, decimalAmount } = formatAmountWithCurrency(amount, currencyCode);
20
19
  return (_jsxs(CurrencySpan, Object.assign({}, props, { children: [_jsx("span", { children: integerAmount }), _jsx("span", { children: "." }), _jsx(DecimalSpan, { children: decimalAmount })] })));
21
20
  }
22
21
  export default memo(DisplayAmount);
@@ -1,5 +1,6 @@
1
1
  import { CustomColumnFilterProps } from '../VirtualTables';
2
- import { ColumnFilterValues, StatusValue } from '../../types/index.js';
2
+ import { StatusValue } from './type';
3
+ import { ColumnFilterValues } from '../../types/index.js';
3
4
  interface StatusFilterProps extends CustomColumnFilterProps {
4
5
  options: {
5
6
  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';
9
10
  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 '../../types/index.js';
1
+ import { StatusValue } from './type';
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 '../../types/index.js';
1
+ import { StatusValue } from './type';
2
2
  export const getInitialStatuses = (statuses, options) => {
3
3
  const rawStatuses = (statuses || {});
4
4
  const mappedStatuses = {};
@@ -9,6 +9,7 @@ import { Label, LabelWrapper } from './style';
9
9
  import { getVatValue } from '../utils';
10
10
  import VATDropdown from '../VATDropdown';
11
11
  function TotalVAT({ totalGrossAmount, totalVat, selectedCurrency, onChangeTotalVat, isDisabled }) {
12
+ var _a;
12
13
  const [isOpen, setIsOpen] = useState(false);
13
14
  const vatButtonRef = useRef();
14
15
  const { t } = useTranslation();
@@ -19,12 +20,13 @@ function TotalVAT({ totalGrossAmount, totalVat, selectedCurrency, onChangeTotalV
19
20
  const modifyTotalVAT = (newVat) => {
20
21
  onChangeTotalVat(Object.assign(Object.assign({}, newVat), { value: getVatValue(totalGrossAmount, newVat) }));
21
22
  };
23
+ const currencyCode = ((_a = selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.code) === null || _a === void 0 ? void 0 : _a.english) || '';
22
24
  const getLabel = () => {
23
25
  if (totalVat.percentage === 0)
24
26
  return t('noVat');
25
27
  if (!totalVat.isInclusive)
26
- return _jsx(DisplayAmount, { selectedCurrency: selectedCurrency, amount: totalVat.value });
27
- return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '4px' } }, { children: [_jsxs("span", { children: [t('inclusive'), " "] }), _jsx(DisplayAmount, { amount: totalVat.value, selectedCurrency: selectedCurrency })] })));
28
+ return _jsx(DisplayAmount, { currencyCode: currencyCode, amount: totalVat.value });
29
+ return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '4px' } }, { children: [_jsxs("span", { children: [t('inclusive'), " "] }), _jsx(DisplayAmount, { amount: totalVat.value, currencyCode: currencyCode })] })));
28
30
  };
29
31
  return (_jsxs(LabelWrapper, Object.assign({ isDisabled: isDisabled, isOpen: isOpen, onClick: toggleDropdown, ref: vatButtonRef, sx: Object.assign({}, (isDisabled && { pointerEvents: 'none', opacity: 0.7 })) }, { children: [_jsx("img", { src: taxIcon, alt: "p" }), _jsx(Label, Object.assign({ isDisabled: isDisabled }, { children: getLabel() })), _jsx(Box, { component: "img", src: isOpen ? activeActionIcon : actionsIcon, alt: "a" }), isOpen && _jsx(CustomBackdrop, { onClick: toggleDropdown }), _jsx(Popper, Object.assign({ open: Boolean(isOpen), anchorEl: vatButtonRef.current, placement: "bottom-start" }, { children: _jsx(VATDropdown, { setIsOpen: setIsOpen, vat: totalVat, setVat: modifyTotalVAT, sx: { position: 'absolute', top: 8, left: 0, display: isOpen ? 'block' : 'none' } }) }))] })));
30
32
  }
@@ -144,4 +144,3 @@ export * from './StatusFilter';
144
144
  export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
- export * from './PartnersFilter';
@@ -144,4 +144,3 @@ export * from './StatusFilter';
144
144
  export { default as TableReports } from './TableReports';
145
145
  export * from './TableReports';
146
146
  export * from './PaymentSourceFilter';
147
- export * from './PartnersFilter';
@@ -110,17 +110,17 @@ export declare const merchantsTableCellWidth: {
110
110
  readonly sheet: "180px";
111
111
  };
112
112
  readonly psp: {
113
- readonly default: "70px";
113
+ readonly default: "77px";
114
114
  readonly text: "180px";
115
115
  readonly sheet: "180px";
116
116
  };
117
117
  readonly status: {
118
- readonly default: "65px";
118
+ readonly default: "86px";
119
119
  readonly text: "100px";
120
120
  readonly sheet: "172px";
121
121
  };
122
122
  readonly partners: {
123
- readonly default: "88px";
123
+ readonly default: "97px";
124
124
  readonly text: "100px";
125
125
  readonly sheet: "100px";
126
126
  };
@@ -140,7 +140,7 @@ export declare const merchantsTableCellWidth: {
140
140
  readonly sheet: "180px";
141
141
  };
142
142
  readonly channels: {
143
- readonly default: "94px";
143
+ readonly default: "102px";
144
144
  readonly text: "120px";
145
145
  readonly sheet: "440px";
146
146
  };
@@ -110,17 +110,17 @@ export const merchantsTableCellWidth = {
110
110
  sheet: '180px',
111
111
  },
112
112
  psp: {
113
- default: '70px',
113
+ default: '77px',
114
114
  text: '180px',
115
115
  sheet: '180px',
116
116
  },
117
117
  status: {
118
- default: '65px',
118
+ default: '86px',
119
119
  text: '100px',
120
120
  sheet: '172px',
121
121
  },
122
122
  partners: {
123
- default: '88px',
123
+ default: '97px',
124
124
  text: '100px',
125
125
  sheet: '100px',
126
126
  },
@@ -140,7 +140,7 @@ export const merchantsTableCellWidth = {
140
140
  sheet: '180px',
141
141
  },
142
142
  channels: {
143
- default: '94px',
143
+ default: '102px',
144
144
  text: '120px',
145
145
  sheet: '440px',
146
146
  },
@@ -28,4 +28,3 @@ export * from './appEvents';
28
28
  export * from './common';
29
29
  export * from './discount';
30
30
  export * from './receipt';
31
- export * from './filter';
@@ -28,4 +28,3 @@ export * from './appEvents';
28
28
  export * from './common';
29
29
  export * from './discount';
30
30
  export * from './receipt';
31
- export * from './filter';
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.286-test.3",
5
- "testVersion": 3,
4
+ "version": "0.1.287-test.1",
5
+ "testVersion": 1,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -1,10 +0,0 @@
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 {};
@@ -1,50 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default as PartnersFilter } from './PartnersFilter';
@@ -1 +0,0 @@
1
- export { default as PartnersFilter } from './PartnersFilter';