@tap-payments/os-micro-frontend-shared 0.1.287 → 0.1.289
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.
- package/build/components/Amount/TotalAmount/TotalAmount.js +4 -2
- package/build/components/AmountInput/AmountInput.d.ts +1 -1
- package/build/components/AmountInput/AmountInput.js +3 -2
- package/build/components/Discount/TotalDiscount/TotalDiscount.js +2 -1
- package/build/components/DisplayAmount/DisplayAmount.d.ts +2 -3
- package/build/components/DisplayAmount/DisplayAmount.js +2 -3
- package/build/components/VAT/TotalVAT/TotalVAT.js +4 -2
- package/build/components/VirtualTables/VirtualTable/VirtualTable.d.ts +1 -1
- package/build/components/VirtualTables/VirtualTable/VirtualTable.js +2 -2
- package/build/components/VirtualTables/components/TableFooter/TableFooter.d.ts +1 -1
- package/build/components/VirtualTables/components/TableFooter/TableFooter.js +2 -11
- package/build/types/table.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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' },
|
|
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,
|
|
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
|
|
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
|
-
|
|
5
|
+
currencyCode: string;
|
|
7
6
|
}
|
|
8
|
-
declare function DisplayAmount({ amount,
|
|
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
|
|
18
|
-
|
|
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);
|
|
@@ -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, {
|
|
27
|
-
return (_jsxs(Box, Object.assign({ sx: { display: 'flex', gap: '4px' } }, { children: [_jsxs("span", { children: [t('inclusive'), " "] }), _jsx(DisplayAmount, { amount: totalVat.value,
|
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IVirtualTable } from '../../../types/index.js';
|
|
3
|
-
declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, footerComponent, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof VirtualTable>;
|
|
5
5
|
export default _default;
|
|
@@ -34,7 +34,7 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
|
|
|
34
34
|
areAllRowsLoaded,
|
|
35
35
|
isSheetView,
|
|
36
36
|
}));
|
|
37
|
-
function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, }) {
|
|
37
|
+
function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, footerComponent, }) {
|
|
38
38
|
var _a;
|
|
39
39
|
const theme = useTheme();
|
|
40
40
|
const onPointerDown = (e) => {
|
|
@@ -107,6 +107,6 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
|
|
|
107
107
|
// rows height + header height
|
|
108
108
|
, {
|
|
109
109
|
// rows height + header height
|
|
110
|
-
height: (itemsCount + 1) * tableRowHeight, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, "data-testid": "VirtualTable_TableLastItem" }))] }), _jsx(TableFooter, Object.assign({ "data-testid": "VirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
|
|
110
|
+
height: (itemsCount + 1) * tableRowHeight, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, "data-testid": "VirtualTable_TableLastItem" }))] }), footerProps && (_jsx(TableFooter, Object.assign({ "data-testid": "VirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))), footerComponent] }));
|
|
111
111
|
}
|
|
112
112
|
export default memo(VirtualTable);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableFooterProps } from '../../../../types/index.js';
|
|
3
|
-
declare function TableFooter({ totalCount, showBackDrop, showSeparator, sandboxMode, maximized,
|
|
3
|
+
declare function TableFooter({ totalCount, showBackDrop, showSeparator, sandboxMode, maximized, ...other }: Readonly<TableFooterProps>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: React.MemoExoticComponent<typeof TableFooter>;
|
|
5
5
|
export default _default;
|
|
@@ -15,17 +15,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
15
15
|
import { formatNumber } from '../../../../utils/index.js';
|
|
16
16
|
import { StyledFooter, Label, Title, ValueWrapper, EngravingLine } from './style';
|
|
17
17
|
function TableFooter(_a) {
|
|
18
|
-
var { totalCount, showBackDrop = false, showSeparator, sandboxMode, maximized
|
|
18
|
+
var { totalCount, showBackDrop = false, showSeparator, sandboxMode, maximized } = _a, other = __rest(_a, ["totalCount", "showBackDrop", "showSeparator", "sandboxMode", "maximized"]);
|
|
19
19
|
const { t } = useTranslation();
|
|
20
|
-
|
|
21
|
-
// const max = 50000
|
|
22
|
-
// const average = 30000
|
|
23
|
-
// const sum = 100000
|
|
24
|
-
// const currency = 'SAR'
|
|
25
|
-
// const { integerAmount: minIntegerAmount, decimalAmount: minDecimalAmount } = formatAmount(min)
|
|
26
|
-
// const { integerAmount: maxIntegerAmount, decimalAmount: maxDecimalAmount } = formatAmount(max)
|
|
27
|
-
// const { integerAmount: averageIntegerAmount, decimalAmount: averageDecimalAmount } = formatAmount(average)
|
|
28
|
-
// const { integerAmount: sumIntegerAmount, decimalAmount: sumDecimalAmount } = formatAmount(sum)
|
|
29
|
-
return (_jsxs(StyledFooter, Object.assign({ component: "footer", "data-testid": "TableFooter", maximized: maximized !== null && maximized !== void 0 ? maximized : false, sandboxMode: sandboxMode, showBackDrop: showBackDrop, areTotalRowsNotFillingHeight: !!showSeparator }, other, { children: [showSeparator && _jsx(EngravingLine, {}), totalCount || totalCount === 0 ? (_jsxs(Label, Object.assign({ sx: { gap: '6px', cursor: 'text' } }, { children: [_jsx(Title, { children: t('count') }), _jsx(ValueWrapper, { children: formatNumber(totalCount || 0) })] }))) : null, children] })));
|
|
20
|
+
return (_jsxs(StyledFooter, Object.assign({ component: "footer", "data-testid": "TableFooter", maximized: maximized !== null && maximized !== void 0 ? maximized : false, sandboxMode: sandboxMode, showBackDrop: showBackDrop, areTotalRowsNotFillingHeight: !!showSeparator }, other, { children: [showSeparator && _jsx(EngravingLine, {}), totalCount || totalCount === 0 ? (_jsxs(Label, Object.assign({ sx: { gap: '6px', cursor: 'text' } }, { children: [_jsx(Title, { children: t('count') }), _jsx(ValueWrapper, { children: formatNumber(totalCount || 0) })] }))) : null] })));
|
|
30
21
|
}
|
|
31
22
|
export default React.memo(TableFooter);
|
package/build/types/table.d.ts
CHANGED
|
@@ -46,7 +46,6 @@ export interface TableFooterProps extends BoxProps {
|
|
|
46
46
|
showSeparator?: boolean;
|
|
47
47
|
sandboxMode?: boolean;
|
|
48
48
|
maximized?: boolean;
|
|
49
|
-
children?: React.ReactNode;
|
|
50
49
|
}
|
|
51
50
|
export interface TableChipProps {
|
|
52
51
|
onChipClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
|
|
@@ -140,6 +139,7 @@ export interface IVirtualTable<R = any> {
|
|
|
140
139
|
onStartDrag?: DragControls['start'];
|
|
141
140
|
isSheetView?: boolean;
|
|
142
141
|
isMinimized?: boolean;
|
|
142
|
+
footerComponent?: React.ReactNode;
|
|
143
143
|
}
|
|
144
144
|
export type ColumnFilterValues = Record<string, boolean | string | string[] | Record<string, boolean> | Record<string, string> | {
|
|
145
145
|
phone: string;
|
package/package.json
CHANGED