@tap-payments/os-micro-frontend-shared 0.0.273-test.1 → 0.0.273-test.10
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/VirtualTable/SheetView/SheetViewVirtualTable.js +1 -1
- package/build/components/VirtualTable/SheetView/{SheetViewTableHeader.d.ts → components/SheetViewTableHeader/SheetViewTableHeader.d.ts} +1 -1
- package/build/components/VirtualTable/SheetView/{SheetViewTableHeader.js → components/SheetViewTableHeader/SheetViewTableHeader.js} +13 -6
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/index.d.ts +2 -0
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/index.js +2 -0
- package/build/components/VirtualTable/SheetView/index.d.ts +1 -1
- package/build/components/VirtualTable/SheetView/index.js +1 -1
- package/build/components/VirtualTable/SheetView/style.js +1 -0
- package/build/components/VirtualTable/VirtualTable.js +1 -1
- package/build/components/VirtualTable/components/ColumnFilter/ColumnFilter.d.ts +2 -2
- package/build/components/VirtualTable/components/ColumnFilter/ColumnFilter.js +11 -10
- package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.d.ts +2 -1
- package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.js +4 -4
- package/build/components/VirtualTable/components/ColumnFilter/List/List.d.ts +2 -2
- package/build/components/VirtualTable/components/ColumnFilter/List/List.js +4 -4
- package/build/components/VirtualTable/components/ColumnFilter/type.d.ts +7 -0
- package/build/components/VirtualTable/components/ColumnFilter/type.js +1 -0
- package/build/components/VirtualTable/components/TableHeader/TableHeader.d.ts +14 -0
- package/build/components/VirtualTable/components/TableHeader/TableHeader.js +10 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/ColumnSort.d.ts +9 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/ColumnSort.js +46 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/index.d.ts +2 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/index.js +2 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/style.d.ts +3 -0
- package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/style.js +10 -0
- package/build/components/VirtualTable/components/TableHeader/components/TableCell/TableCell.d.ts +9 -0
- package/build/components/VirtualTable/components/TableHeader/components/TableCell/TableCell.js +12 -0
- package/build/components/VirtualTable/components/TableHeader/components/TableCell/index.d.ts +2 -0
- package/build/components/VirtualTable/components/TableHeader/components/TableCell/index.js +2 -0
- package/build/components/VirtualTable/components/TableHeader/components/index.d.ts +2 -0
- package/build/components/VirtualTable/components/TableHeader/components/index.js +2 -0
- package/build/components/VirtualTable/components/TableHeader/constant.d.ts +5 -0
- package/build/components/VirtualTable/components/TableHeader/constant.js +6 -0
- package/build/components/VirtualTable/components/TableHeader/index.d.ts +2 -0
- package/build/components/VirtualTable/components/TableHeader/index.js +2 -0
- package/build/components/VirtualTable/components/TableHeader/style.d.ts +12 -0
- package/build/components/VirtualTable/components/TableHeader/style.js +22 -0
- package/build/components/VirtualTable/components/TableNoData.d.ts +1 -1
- package/build/components/VirtualTable/components/TableNoData.js +22 -3
- package/build/components/VirtualTable/components/index.d.ts +0 -1
- package/build/components/VirtualTable/components/index.js +0 -1
- package/build/components/VirtualTable/style.js +1 -1
- package/build/components/index.d.ts +1 -1
- package/build/components/index.js +1 -1
- package/package.json +2 -2
- package/build/components/VirtualTable/components/TableError.d.ts +0 -11
- package/build/components/VirtualTable/components/TableError.js +0 -23
- package/build/components/VirtualTable/components/TableHeader.d.ts +0 -27
- package/build/components/VirtualTable/components/TableHeader.js +0 -87
|
@@ -22,7 +22,7 @@ import { SheetViewTableNoData } from './components';
|
|
|
22
22
|
import ListItemWrapper from '../components/virtualScroll/ListItemWrapper';
|
|
23
23
|
import { StyledBox, StyledTableBox, StyledVirtualList, TableContainer, TableWrapper } from '../style';
|
|
24
24
|
import { SheetViewVirtualTableWrapper, PinnedStartColumnWrapper, PinnedEndColumnWrapper, MainTableWrapper, UnpinnedTableHeaderWrapper } from './style';
|
|
25
|
-
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
25
|
+
import SheetViewTableHeader from './components/SheetViewTableHeader/SheetViewTableHeader';
|
|
26
26
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
27
27
|
import { usePinnedColumns } from './hooks/usePinnedColumns';
|
|
28
28
|
import { useSynchronizedScroll } from './hooks/useSynchronizedScroll';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type TableHeadProps } from '@mui/material';
|
|
3
|
-
import type { IColumnProps, IVirtualTable } from '
|
|
3
|
+
import type { IColumnProps, IVirtualTable } from '../../../../../types/index.js';
|
|
4
4
|
interface SheetViewTableHeaderProps {
|
|
5
5
|
columns: IColumnProps[];
|
|
6
6
|
headerProps?: TableHeadProps;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useState } from 'react';
|
|
3
3
|
import { Box, useTheme } from '@mui/material';
|
|
4
|
-
import Dropdown from '
|
|
5
|
-
import { columnIcon, pinIcon, sortAzIcon, sortZaIcon, unpinIcon } from '
|
|
6
|
-
import ColumnFilter from '
|
|
7
|
-
import { StyledCell } from '
|
|
8
|
-
import { ActionIcon, ColumnIcon, PinIconContainer, StyledHeader, StyledMUITableRow, HeaderText } from '
|
|
4
|
+
import Dropdown from '../../../../DropdownMenu';
|
|
5
|
+
import { columnIcon, pinIcon, sortAzIcon, sortZaIcon, unpinIcon } from '../../../../../constants/index.js';
|
|
6
|
+
import ColumnFilter from '../../../components/ColumnFilter';
|
|
7
|
+
import { StyledCell } from '../../../style';
|
|
8
|
+
import { ActionIcon, ColumnIcon, PinIconContainer, StyledHeader, StyledMUITableRow, HeaderText } from '../../style';
|
|
9
9
|
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
10
10
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
|
+
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
11
12
|
const open = Boolean(anchorEl);
|
|
12
13
|
const theme = useTheme();
|
|
13
14
|
const handleClick = (event) => {
|
|
15
|
+
event.stopPropagation();
|
|
14
16
|
setAnchorEl(event.currentTarget);
|
|
15
17
|
};
|
|
16
18
|
const handleClose = () => {
|
|
@@ -45,7 +47,12 @@ function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort
|
|
|
45
47
|
const isPinned = pinnedColumns.includes(id);
|
|
46
48
|
const isDefaultPinned = !!column.isDefaultPinned;
|
|
47
49
|
const isSelected = selectedColumn === id;
|
|
48
|
-
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) =>
|
|
50
|
+
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => {
|
|
51
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event);
|
|
52
|
+
setColumnFilterEl(event.currentTarget);
|
|
53
|
+
}, sx: Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: isSelected ? '2px solid #1F88D0' : '1px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', height: isSelected ? '100%' : 'auto', minHeight: isSelected ? '28px' : 'auto' }, headerStyle) }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && (_jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl, onClose: (event) => {
|
|
54
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event);
|
|
55
|
+
} }))), sortable && (_jsx(Box, Object.assign({ sx: { diplay: 'flex', alignItems: 'center' } }, { children: _jsx(ColumnIcon, { onClick: sortable ? handleClick : undefined, src: columnIcon, alt: "column-icon", "data-id": id }) }))), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
49
56
|
event.stopPropagation();
|
|
50
57
|
handlePinClick(id);
|
|
51
58
|
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] }), `${id}-${colIndex}`));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as SheetViewVirtualTable } from './SheetViewVirtualTable';
|
|
2
|
-
export { default as SheetViewTableHeader } from './SheetViewTableHeader';
|
|
2
|
+
export { default as SheetViewTableHeader } from './components/SheetViewTableHeader/SheetViewTableHeader';
|
|
3
3
|
export * from './style';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as SheetViewVirtualTable } from './SheetViewVirtualTable';
|
|
2
|
-
export { default as SheetViewTableHeader } from './SheetViewTableHeader';
|
|
2
|
+
export { default as SheetViewTableHeader } from './components/SheetViewTableHeader/SheetViewTableHeader';
|
|
3
3
|
export * from './style';
|
|
@@ -17,7 +17,7 @@ import { TABLE_ROW_HEIGHT, TABLE_THRESHOLD, TABLE_LIST_OVER_SCAN, SHEET_VIEW_TAB
|
|
|
17
17
|
import { useDelayToSetValue } from '../../hooks/index.js';
|
|
18
18
|
import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../utils/index.js';
|
|
19
19
|
import TableFooter from './components/TableFooter/TableFooter';
|
|
20
|
-
import TableHeader from './components/TableHeader';
|
|
20
|
+
import TableHeader from './components/TableHeader/TableHeader';
|
|
21
21
|
import TableLastItem from './components/TableLastItem';
|
|
22
22
|
import TableNoData from './components/TableNoData';
|
|
23
23
|
import ListItemWrapper from './components/virtualScroll/ListItemWrapper';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
declare function ColumnFilter(filter:
|
|
2
|
+
import { ColumnFilterProps } from './type';
|
|
3
|
+
declare function ColumnFilter(filter: ColumnFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof ColumnFilter>;
|
|
5
5
|
export default _default;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
|
-
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
5
4
|
import Popper from '@mui/material/Popper';
|
|
6
5
|
import { closeIcon, columnIcon, whiteFilterIcon } from '../../../../constants/index.js';
|
|
7
6
|
import Inputs from './Inputs';
|
|
@@ -9,12 +8,14 @@ import List from './List';
|
|
|
9
8
|
import { FilterWrapper } from './style';
|
|
10
9
|
import CustomBackdrop from '../../../CustomBackdrop';
|
|
11
10
|
function ColumnFilter(filter) {
|
|
12
|
-
const
|
|
11
|
+
const { anchorEl, setAnchorEl, onClose } = filter;
|
|
13
12
|
const openDropdown = (event) => {
|
|
14
13
|
setAnchorEl(event.currentTarget);
|
|
15
14
|
};
|
|
16
|
-
const onCloseDropdown = () => {
|
|
15
|
+
const onCloseDropdown = (event) => {
|
|
16
|
+
event.stopPropagation();
|
|
17
17
|
setAnchorEl(null);
|
|
18
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
18
19
|
};
|
|
19
20
|
const filterData = useMemo(() => { var _a; return ((_a = filter === null || filter === void 0 ? void 0 : filter.options) === null || _a === void 0 ? void 0 : _a.reduce((acc, { apiKey }) => { var _a; return (Object.assign(Object.assign({}, acc), { [apiKey]: (_a = filter === null || filter === void 0 ? void 0 : filter.data) === null || _a === void 0 ? void 0 : _a[apiKey] })); }, {})) || {}; }, [filter]);
|
|
20
21
|
const listFilterData = useMemo(() => {
|
|
@@ -50,10 +51,10 @@ function ColumnFilter(filter) {
|
|
|
50
51
|
}
|
|
51
52
|
return null;
|
|
52
53
|
}, [open, filter, anchorEl, setAnchorEl]);
|
|
53
|
-
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
return (_jsxs(_Fragment, { children: [showClearIcon ? (_jsxs(FilterWrapper, { children: [_jsx(Box, { component: "img", "data-testid": "ColumnFilter_whiteFilterIcon", src: whiteFilterIcon, alt: "filter-icon", sx: { marginInlineEnd: '2px', height: 6 }, onClick: openDropdown }), _jsx(Box, { component: "img", "data-testid": "ColumnFilter_closeIcon", src: closeIcon, alt: "close-icon", onClick: () => {
|
|
55
|
+
filter.onClear(filterApiKeys);
|
|
56
|
+
} })] })) : (_jsx(Box, { component: "img", "data-testid": "ColumnFilter_columnIcon", src: columnIcon, alt: "column-icon", sx: { cursor: 'pointer', marginTop: '2px' }, onClick: openDropdown })), open && _jsx(CustomBackdrop, { onClick: onCloseDropdown }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start", sx: {
|
|
57
|
+
zIndex: 9999,
|
|
58
|
+
} }, { children: renderFilter }))] }));
|
|
58
59
|
}
|
|
59
60
|
export default memo(ColumnFilter);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
1
2
|
import type { IColumnFilter, IColumnFilterInputs } from '../../../../../types/index.js';
|
|
2
3
|
interface InputsI {
|
|
3
|
-
onCloseDropdown: () => void;
|
|
4
|
+
onCloseDropdown: (e: MouseEvent<HTMLElement>) => void;
|
|
4
5
|
filter: IColumnFilter & IColumnFilterInputs;
|
|
5
6
|
}
|
|
6
7
|
declare function Inputs({ onCloseDropdown, filter: { options, onConfirm, data, isOnlyOneFilter, onColumnFilterClearClick, wrapperSx } }: InputsI): import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,12 +13,12 @@ function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOn
|
|
|
13
13
|
setValues((options || []).reduce((acc, { apiKey }) => { var _a; return (Object.assign(Object.assign({}, acc), { [apiKey]: (_a = data === null || data === void 0 ? void 0 : data[apiKey]) !== null && _a !== void 0 ? _a : '' })); }, {}));
|
|
14
14
|
}, []);
|
|
15
15
|
const { t } = useTranslation();
|
|
16
|
-
const onClickOkay = () => {
|
|
16
|
+
const onClickOkay = (e) => {
|
|
17
17
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(values);
|
|
18
|
-
onCloseDropdown();
|
|
18
|
+
onCloseDropdown(e);
|
|
19
19
|
};
|
|
20
|
-
const onClickCancel = () => {
|
|
21
|
-
onCloseDropdown();
|
|
20
|
+
const onClickCancel = (e) => {
|
|
21
|
+
onCloseDropdown(e);
|
|
22
22
|
};
|
|
23
23
|
const onClickClear = () => {
|
|
24
24
|
onColumnFilterClearClick === null || onColumnFilterClearClick === void 0 ? void 0 : onColumnFilterClearClick();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { MouseEvent } from 'react';
|
|
2
2
|
import type { IColumnFilter, IColumnFilterList } from '../../../../../types/index.js';
|
|
3
3
|
interface ListI {
|
|
4
|
-
onCloseDropdown: () => void;
|
|
4
|
+
onCloseDropdown: (e: MouseEvent<HTMLElement>) => void;
|
|
5
5
|
filter: IColumnFilter & IColumnFilterList;
|
|
6
6
|
styles?: React.CSSProperties;
|
|
7
7
|
}
|
|
@@ -25,10 +25,10 @@ function List({ onCloseDropdown, filter, styles }) {
|
|
|
25
25
|
if (filter.options)
|
|
26
26
|
setItemsList(renderItems(filter.options));
|
|
27
27
|
}, [filter === null || filter === void 0 ? void 0 : filter.data]);
|
|
28
|
-
const onClickCancel = () => {
|
|
29
|
-
onCloseDropdown();
|
|
28
|
+
const onClickCancel = (e) => {
|
|
29
|
+
onCloseDropdown(e);
|
|
30
30
|
};
|
|
31
|
-
const onClickOkay = () => {
|
|
31
|
+
const onClickOkay = (e) => {
|
|
32
32
|
var _a;
|
|
33
33
|
const selectedValues = values.reduce((acc, { options, apiKey: parentKey, isSelected: isParentSelected }) => {
|
|
34
34
|
if (options) {
|
|
@@ -45,7 +45,7 @@ function List({ onCloseDropdown, filter, styles }) {
|
|
|
45
45
|
const selectedValueSet = new Set(selectedValues);
|
|
46
46
|
if (Object.keys(values).length)
|
|
47
47
|
(_a = filter === null || filter === void 0 ? void 0 : filter.onConfirm) === null || _a === void 0 ? void 0 : _a.call(filter, { [filter.apiKey]: [...selectedValueSet] });
|
|
48
|
-
onCloseDropdown();
|
|
48
|
+
onCloseDropdown(e);
|
|
49
49
|
};
|
|
50
50
|
const onUpdateMenuItems = (latestMenuItems) => {
|
|
51
51
|
const resetItems = (items) => items.map(({ name, selected, menuItems, label }) => (Object.assign(Object.assign(Object.assign({}, (label && { placeholder: label })), { apiKey: name, isSelected: selected }), ((menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) && { options: resetItems(menuItems) }))));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
import { IColumnFilter } from '../../../../types/index.js';
|
|
3
|
+
export type ColumnFilterProps = IColumnFilter & {
|
|
4
|
+
anchorEl: HTMLElement | null;
|
|
5
|
+
setAnchorEl: (el: HTMLElement | null) => void;
|
|
6
|
+
onClose?: (e: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type TableHeadProps } from '@mui/material/TableHead';
|
|
3
|
+
import type { IColumnProps, IVirtualTable } from '../../../../types/index.js';
|
|
4
|
+
export interface TableHeaderProps {
|
|
5
|
+
columns: IColumnProps[];
|
|
6
|
+
headerProps?: TableHeadProps;
|
|
7
|
+
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
8
|
+
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
9
|
+
showBackDrop: boolean;
|
|
10
|
+
isSheetView?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const _default: import("react").MemoExoticComponent<typeof TableHeader>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { TableCell } from './components';
|
|
4
|
+
import { StyledHeader, StyledMUITableRow } from './style';
|
|
5
|
+
function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }) {
|
|
6
|
+
return (_jsx(StyledHeader, Object.assign({ component: "nav", "data-testid": "VirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { sx: Object.assign({ width: '100%', minWidth: 'auto', overflowX: 'scroll' }, headerProps === null || headerProps === void 0 ? void 0 : headerProps.sx) }, { children: _jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "VirtualTable_TableHeader_StyledMUITableRow", isSheetView: isSheetView }, { children: columns.map((column, colIndex) => {
|
|
7
|
+
return (_jsx(TableCell, { column: column, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, isSheetView: isSheetView }, `${column.id}-${colIndex}`));
|
|
8
|
+
}) })) })));
|
|
9
|
+
}
|
|
10
|
+
export default memo(TableHeader);
|
package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/ColumnSort.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IColumnProps } from '../../../../../../types/index.js';
|
|
3
|
+
import { TableHeaderProps } from '../../TableHeader';
|
|
4
|
+
interface ColumnSortProps extends Pick<TableHeaderProps, 'onColumnSort' | 'columnsSorting'> {
|
|
5
|
+
columnId: IColumnProps['id'];
|
|
6
|
+
}
|
|
7
|
+
declare function ColumnSort({ onColumnSort, columnsSorting, columnId }: ColumnSortProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const _default: import("react").MemoExoticComponent<typeof ColumnSort>;
|
|
9
|
+
export default _default;
|
package/build/components/VirtualTable/components/TableHeader/components/ColumnSort/ColumnSort.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Dropdown from '../../../../../DropdownMenu';
|
|
5
|
+
import { columnIcon, sortAzIcon, sortZaIcon } from '../../../../../../constants/index.js';
|
|
6
|
+
import { ActionIcon, ColumnIcon } from './style';
|
|
7
|
+
function ColumnSort({ onColumnSort, columnsSorting, columnId }) {
|
|
8
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
9
|
+
const open = Boolean(anchorEl);
|
|
10
|
+
const handleClick = (event) => {
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
setAnchorEl(event.currentTarget);
|
|
13
|
+
};
|
|
14
|
+
const handleClose = () => {
|
|
15
|
+
setAnchorEl(null);
|
|
16
|
+
};
|
|
17
|
+
const handleSortingOption = (columnId, order) => {
|
|
18
|
+
if (columnId) {
|
|
19
|
+
onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
|
|
20
|
+
[columnId]: order,
|
|
21
|
+
});
|
|
22
|
+
handleClose();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: _jsx(ColumnIcon, { onClick: handleClick, src: columnIcon, alt: "column-icon", "data-id": columnId }) })), _jsx(Dropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: [
|
|
26
|
+
{
|
|
27
|
+
label: 'Sort A-Z',
|
|
28
|
+
name: 'asc',
|
|
29
|
+
icon: _jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }),
|
|
30
|
+
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc',
|
|
31
|
+
onClick: () => {
|
|
32
|
+
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc');
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'Sort Z-A',
|
|
37
|
+
name: 'desc',
|
|
38
|
+
icon: _jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }),
|
|
39
|
+
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc',
|
|
40
|
+
onClick: () => {
|
|
41
|
+
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
] })] }));
|
|
45
|
+
}
|
|
46
|
+
export default memo(ColumnSort);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ActionIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
3
|
+
export declare const ColumnIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
package/build/components/VirtualTable/components/TableHeader/components/TableCell/TableCell.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../../../types/index.js';
|
|
2
|
+
import { TableHeaderProps } from '../../TableHeader';
|
|
3
|
+
interface TableCellProps extends Pick<TableHeaderProps, 'onColumnSort' | 'isSheetView' | 'columnsSorting'> {
|
|
4
|
+
column: IColumnProps;
|
|
5
|
+
isFirst: boolean;
|
|
6
|
+
isLast: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function TableCell({ column: { header, id, align, headerStyle, sortable, filter, width, order }, isFirst, isLast, isSheetView, onColumnSort, columnsSorting, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
package/build/components/VirtualTable/components/TableHeader/components/TableCell/TableCell.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import ColumnFilter from '../../../ColumnFilter';
|
|
5
|
+
import { StyledCell } from '../../../../style';
|
|
6
|
+
import ColumnSort from '../ColumnSort/ColumnSort';
|
|
7
|
+
export function TableCell({ column: { header, id, align, headerStyle, sortable, filter, width, order }, isFirst, isLast, isSheetView, onColumnSort, columnsSorting, }) {
|
|
8
|
+
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
9
|
+
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": id, "data-column-width": width, "data-column-width-used": width, "data-column-align": align, "data-column-order": order, "data-column-header": typeof header === 'string' ? header : 'component', "data-column-sortable": !!sortable, "data-column-filterable": !!filter, isFirst: isFirst, isLast: isLast, onClick: (event) => {
|
|
10
|
+
setColumnFilterEl(event.currentTarget);
|
|
11
|
+
}, sx: (theme) => (Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: width, textAlign: align, overflow: 'unset', fontWeight: 600 }, headerStyle)), isSheetView: isSheetView }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && _jsx(ColumnSort, { onColumnSort: onColumnSort, columnsSorting: columnsSorting, columnId: id })] })));
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledHeader: import("@emotion/styled").StyledComponent<import("@mui/material/TableHead").TableHeadOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & {
|
|
3
|
+
ref?: ((instance: HTMLTableSectionElement | null) => void) | import("react").RefObject<HTMLTableSectionElement> | null | undefined;
|
|
4
|
+
}, "className" | "style" | "classes" | "children" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
5
|
+
showBackDrop: boolean;
|
|
6
|
+
}, {}, {}>;
|
|
7
|
+
export declare const StyledMUITableRow: import("@emotion/styled").StyledComponent<import("@mui/material/TableRow").TableRowOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> & {
|
|
8
|
+
ref?: ((instance: HTMLTableRowElement | null) => void) | import("react").RefObject<HTMLTableRowElement> | null | undefined;
|
|
9
|
+
}, "className" | "style" | "classes" | "children" | "sx" | "hover" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
10
|
+
isSheetView?: boolean | undefined;
|
|
11
|
+
component: string;
|
|
12
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
import TableHead from '@mui/material/TableHead';
|
|
3
|
+
import MUITableRow from '@mui/material/TableRow';
|
|
4
|
+
export const StyledHeader = styled(TableHead, {
|
|
5
|
+
shouldForwardProp: (prop) => prop !== 'showBackDrop',
|
|
6
|
+
})(({ showBackDrop, theme }) => ({
|
|
7
|
+
width: '100%',
|
|
8
|
+
minWidth: 'fit-content',
|
|
9
|
+
flex: '0 0 auto',
|
|
10
|
+
boxShadow: showBackDrop ? theme.shadows[23] : 'none',
|
|
11
|
+
backgroundColor: theme.palette.background.default,
|
|
12
|
+
zIndex: 1,
|
|
13
|
+
}));
|
|
14
|
+
export const StyledMUITableRow = styled(MUITableRow, {
|
|
15
|
+
shouldForwardProp: (prop) => prop !== 'isSheetView',
|
|
16
|
+
})(({ theme, isSheetView }) => (Object.assign({ display: 'flex', justifyContent: 'flex-start', width: '100%', minWidth: 'fit-content', paddingInline: '32px', paddingBlock: '16px' }, (isSheetView && {
|
|
17
|
+
height: '28px',
|
|
18
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
19
|
+
backgroundColor: theme.palette.primary.light,
|
|
20
|
+
paddingInline: 0,
|
|
21
|
+
paddingBlock: 0,
|
|
22
|
+
}))));
|
|
@@ -10,7 +10,7 @@ interface TableNoDataProps {
|
|
|
10
10
|
triggerDataRefetch: () => Promise<unknown>;
|
|
11
11
|
footerProps: IVirtualTable['footerProps'];
|
|
12
12
|
}
|
|
13
|
-
declare function TableNoData({ error, tableEmpty, isTimeoutError, tableError, tableLoading, orderedColumns, triggerDataRefetch, footerProps, }: TableNoDataProps):
|
|
13
|
+
declare function TableNoData({ error, tableEmpty, isTimeoutError, tableError, tableLoading, orderedColumns, triggerDataRefetch, footerProps, }: TableNoDataProps): JSX.Element;
|
|
14
14
|
declare namespace TableNoData {
|
|
15
15
|
var displayName: string;
|
|
16
16
|
}
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
import { backendErrorHandler } from '../../../utils/index.js';
|
|
4
|
+
import EmptyList from './EmptyList/EmptyList';
|
|
5
|
+
import ErrorList from './ErrorList/ErrorList';
|
|
3
6
|
import TableLoading from './TableLoading';
|
|
4
7
|
import { StyledSolidBackground } from '../style';
|
|
5
|
-
import TableError from './TableError';
|
|
6
8
|
function TableNoData({ error, tableEmpty, isTimeoutError, tableError, tableLoading, orderedColumns, triggerDataRefetch, footerProps, }) {
|
|
9
|
+
let content;
|
|
7
10
|
if (tableLoading) {
|
|
8
|
-
|
|
11
|
+
content = (_jsx(StyledSolidBackground, Object.assign({ "data-testid": "VirtualTable_SolidBackground" }, { children: _jsx(TableLoading, { "data-testid": "VirtualTable_TableLoading", columns: orderedColumns, isLoading: true }) })));
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
else if (isTimeoutError) {
|
|
14
|
+
content = (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_timeoutError", shouldMinimizeWidth: true, heading: "timeOut", message: "yourRequestOutPleaseTryAgain", triggerDataRefetch: triggerDataRefetch, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode }));
|
|
15
|
+
}
|
|
16
|
+
else if (tableError) {
|
|
17
|
+
const axiosErr = error;
|
|
18
|
+
const { formatted } = backendErrorHandler({ error: axiosErr, fallbackMessage: 'connectionErrorMsg' });
|
|
19
|
+
content = (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_tableError", heading: "somethingWentWrong", message: formatted, triggerDataRefetch: triggerDataRefetch, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode }));
|
|
20
|
+
}
|
|
21
|
+
else if (tableEmpty) {
|
|
22
|
+
const axiosErr = error;
|
|
23
|
+
const { formatted } = backendErrorHandler({ error: axiosErr, fallbackMessage: 'tryAdjustingTheDateOrFilters' });
|
|
24
|
+
content = _jsx(EmptyList, { sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, heading: "nothingFound", message: formatted });
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
content = (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_tableError", heading: "somethingWentWrong", message: "connectionErrorMsg", triggerDataRefetch: triggerDataRefetch, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode }));
|
|
28
|
+
}
|
|
29
|
+
return content;
|
|
11
30
|
}
|
|
12
31
|
TableNoData.displayName = 'TableNoData';
|
|
13
32
|
export default memo(TableNoData);
|
|
@@ -3,7 +3,6 @@ export * from './EmptyList';
|
|
|
3
3
|
export * from './ErrorList';
|
|
4
4
|
export * from './TableFooter';
|
|
5
5
|
export { default as TableFooter } from './TableFooter';
|
|
6
|
-
export { default as TableError } from './TableError';
|
|
7
6
|
export * from './virtualScroll';
|
|
8
7
|
export * from './RowErrorState';
|
|
9
8
|
export { default as TableHeader } from './TableHeader';
|
|
@@ -3,7 +3,6 @@ export * from './EmptyList';
|
|
|
3
3
|
export * from './ErrorList';
|
|
4
4
|
export * from './TableFooter';
|
|
5
5
|
export { default as TableFooter } from './TableFooter';
|
|
6
|
-
export { default as TableError } from './TableError';
|
|
7
6
|
export * from './virtualScroll';
|
|
8
7
|
export * from './RowErrorState';
|
|
9
8
|
export { default as TableHeader } from './TableHeader';
|
|
@@ -29,7 +29,7 @@ export const StyledSolidBackground = styled(Box)(({ theme }) => ({
|
|
|
29
29
|
backgroundColor: theme.palette.background.default,
|
|
30
30
|
}));
|
|
31
31
|
export const StyledCell = styled(TableCell, {
|
|
32
|
-
shouldForwardProp: (prop) => !['isLast', 'isFirst', 'isSheetView'].includes(prop),
|
|
32
|
+
shouldForwardProp: (prop) => !['isLast', 'isFirst', 'isSheetView', 'isSelected'].includes(prop),
|
|
33
33
|
})(({ theme, isLast, isFirst, isSheetView, isSelected }) => (Object.assign(Object.assign({ paddingBlock: '0', paddingInline: '0.3875rem !important', paddingLeft: isFirst ? '0 !important' : '0.3875rem !important', paddingRight: isLast ? '0 !important' : '0.3875rem !important', color: isSheetView ? theme.palette.text.primary : theme.palette.grey[700], fontSize: isSheetView ? theme.typography.subtitle1.fontSize : theme.typography.caption.fontSize, height: '100%', fontWeight: isSheetView ? 400 : theme.typography.fontWeightRegular, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', display: 'flex', alignItems: 'center' }, (isSheetView && {
|
|
34
34
|
borderRight: isLast ? 'none' : `1px solid ${theme.palette.divider}`,
|
|
35
35
|
paddingInline: '8px !important',
|
|
@@ -12,7 +12,7 @@ export { default as Checkbox } from './Checkbox';
|
|
|
12
12
|
export { default as Dialog, DialogToolbar } from './Dialog';
|
|
13
13
|
export { default as Tooltip } from './Tooltip';
|
|
14
14
|
export * from './RFH';
|
|
15
|
-
export { default as VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter,
|
|
15
|
+
export { default as VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, } from './VirtualTable';
|
|
16
16
|
export { default as SheetViewVirtualTable } from './VirtualTable/SheetView/SheetViewVirtualTable';
|
|
17
17
|
export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
|
|
18
18
|
export { default as TapLogo } from './TapLogo';
|
|
@@ -12,7 +12,7 @@ export { default as Checkbox } from './Checkbox';
|
|
|
12
12
|
export { default as Dialog, DialogToolbar } from './Dialog';
|
|
13
13
|
export { default as Tooltip } from './Tooltip';
|
|
14
14
|
export * from './RFH';
|
|
15
|
-
export { default as VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter,
|
|
15
|
+
export { default as VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, } from './VirtualTable';
|
|
16
16
|
export { default as SheetViewVirtualTable } from './VirtualTable/SheetView/SheetViewVirtualTable';
|
|
17
17
|
export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
|
|
18
18
|
export { default as TapLogo } from './TapLogo';
|
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.0.273-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.0.273-test.10",
|
|
5
|
+
"testVersion": 10,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export type TableErrorProps = {
|
|
3
|
-
isTimeoutError?: boolean;
|
|
4
|
-
tableError?: boolean;
|
|
5
|
-
sandboxMode?: boolean;
|
|
6
|
-
tableEmpty?: boolean;
|
|
7
|
-
error: Error | null;
|
|
8
|
-
triggerDataRefetch: () => Promise<unknown>;
|
|
9
|
-
};
|
|
10
|
-
declare const _default: import("react").MemoExoticComponent<(props: TableErrorProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
-
export default _default;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
import ErrorList from './ErrorList';
|
|
4
|
-
import { backendErrorHandler } from '../../../utils/index.js';
|
|
5
|
-
import EmptyList from './EmptyList';
|
|
6
|
-
const TableError = (props) => {
|
|
7
|
-
const { isTimeoutError, tableError, triggerDataRefetch, sandboxMode, tableEmpty, error } = props;
|
|
8
|
-
if (isTimeoutError) {
|
|
9
|
-
return (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_timeoutError", shouldMinimizeWidth: true, heading: "timeOut", message: "yourRequestOutPleaseTryAgain", triggerDataRefetch: triggerDataRefetch, sandboxMode: sandboxMode }));
|
|
10
|
-
}
|
|
11
|
-
if (tableError) {
|
|
12
|
-
const axiosErr = error;
|
|
13
|
-
const { formatted } = backendErrorHandler({ error: axiosErr, fallbackMessage: 'connectionErrorMsg' });
|
|
14
|
-
return (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_tableError", heading: "somethingWentWrong", message: formatted, triggerDataRefetch: triggerDataRefetch, sandboxMode: sandboxMode }));
|
|
15
|
-
}
|
|
16
|
-
if (tableEmpty) {
|
|
17
|
-
const axiosErr = error;
|
|
18
|
-
const { formatted } = backendErrorHandler({ error: axiosErr, fallbackMessage: 'tryAdjustingTheDateOrFilters' });
|
|
19
|
-
return _jsx(EmptyList, { sandboxMode: sandboxMode, heading: "nothingFound", message: formatted });
|
|
20
|
-
}
|
|
21
|
-
return (_jsx(ErrorList, { "data-testid": "VirtualTable_ErrorList_tableError", heading: "somethingWentWrong", message: "connectionErrorMsg", triggerDataRefetch: triggerDataRefetch, sandboxMode: sandboxMode }));
|
|
22
|
-
};
|
|
23
|
-
export default memo(TableError);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { type TableHeadProps } from '@mui/material';
|
|
3
|
-
import type { IColumnProps, IVirtualTable } from '../../../types/index.js';
|
|
4
|
-
export declare const actionsIcons: {
|
|
5
|
-
flag: string;
|
|
6
|
-
dispute: string;
|
|
7
|
-
refund: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const ActionIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
10
|
-
export declare const ColumnIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
11
|
-
interface StyledHeaderProps {
|
|
12
|
-
showBackDrop: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const StyledHeader: import("@emotion/styled").StyledComponent<import("@mui/material").TableHeadOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & {
|
|
15
|
-
ref?: ((instance: HTMLTableSectionElement | null) => void) | import("react").RefObject<HTMLTableSectionElement> | null | undefined;
|
|
16
|
-
}, "className" | "style" | "classes" | "children" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & StyledHeaderProps, {}, {}>;
|
|
17
|
-
interface TableHeaderProps {
|
|
18
|
-
columns: IColumnProps[];
|
|
19
|
-
headerProps?: TableHeadProps;
|
|
20
|
-
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
21
|
-
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
22
|
-
showBackDrop: boolean;
|
|
23
|
-
isSheetView?: boolean;
|
|
24
|
-
}
|
|
25
|
-
declare function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
declare const _default: import("react").MemoExoticComponent<typeof TableHeader>;
|
|
27
|
-
export default _default;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useState } from 'react';
|
|
3
|
-
import { Box, styled, useTheme } from '@mui/material';
|
|
4
|
-
import TableHead from '@mui/material/TableHead';
|
|
5
|
-
import MUITableRow from '@mui/material/TableRow';
|
|
6
|
-
import Dropdown from '../../DropdownMenu';
|
|
7
|
-
import { columnIcon, disputeIcon, flagIcon, refundInitiatedIcon, sortAzIcon, sortZaIcon } from '../../../constants/index.js';
|
|
8
|
-
import ColumnFilter from './ColumnFilter';
|
|
9
|
-
import { StyledCell } from '../style';
|
|
10
|
-
export const actionsIcons = {
|
|
11
|
-
flag: flagIcon,
|
|
12
|
-
dispute: disputeIcon,
|
|
13
|
-
refund: refundInitiatedIcon,
|
|
14
|
-
};
|
|
15
|
-
export const ActionIcon = styled('img')(() => ({
|
|
16
|
-
width: '13.3px',
|
|
17
|
-
height: '13.3px',
|
|
18
|
-
}));
|
|
19
|
-
export const ColumnIcon = styled('img')(() => ({
|
|
20
|
-
width: '8px',
|
|
21
|
-
height: '6.4px',
|
|
22
|
-
cursor: 'pointer',
|
|
23
|
-
}));
|
|
24
|
-
export const StyledHeader = styled(TableHead, {
|
|
25
|
-
shouldForwardProp: (prop) => prop !== 'showBackDrop',
|
|
26
|
-
})(({ showBackDrop, theme }) => ({
|
|
27
|
-
width: '100%',
|
|
28
|
-
minWidth: 'fit-content',
|
|
29
|
-
flex: '0 0 auto',
|
|
30
|
-
boxShadow: showBackDrop ? theme.shadows[23] : 'none',
|
|
31
|
-
backgroundColor: theme.palette.background.default,
|
|
32
|
-
zIndex: 1,
|
|
33
|
-
}));
|
|
34
|
-
const StyledMUITableRow = styled(MUITableRow, {
|
|
35
|
-
shouldForwardProp: (prop) => prop !== 'isSheetView',
|
|
36
|
-
})(({ theme, isSheetView }) => (Object.assign({ display: 'flex', justifyContent: 'flex-start', width: '100%', minWidth: 'fit-content', paddingInline: '32px', paddingBlock: '16px' }, (isSheetView && {
|
|
37
|
-
height: '28px',
|
|
38
|
-
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
39
|
-
backgroundColor: theme.palette.primary.light,
|
|
40
|
-
paddingInline: 0,
|
|
41
|
-
paddingBlock: 0,
|
|
42
|
-
}))));
|
|
43
|
-
function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }) {
|
|
44
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
45
|
-
const open = Boolean(anchorEl);
|
|
46
|
-
const theme = useTheme();
|
|
47
|
-
const handleClick = (event) => {
|
|
48
|
-
setAnchorEl(event.currentTarget);
|
|
49
|
-
};
|
|
50
|
-
const handleClose = () => {
|
|
51
|
-
setAnchorEl(null);
|
|
52
|
-
};
|
|
53
|
-
const handleSortingOption = (columnId, order) => {
|
|
54
|
-
if (columnId) {
|
|
55
|
-
onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
|
|
56
|
-
[columnId]: order,
|
|
57
|
-
});
|
|
58
|
-
handleClose();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
return (_jsxs(StyledHeader, Object.assign({ component: "nav", "data-testid": "VirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { sx: Object.assign({ width: '100%', minWidth: 'auto', overflowX: 'scroll' }, headerProps === null || headerProps === void 0 ? void 0 : headerProps.sx) }, { children: [_jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "VirtualTable_TableHeader_StyledMUITableRow", isSheetView: isSheetView }, { children: columns.map((column, colIndex) => {
|
|
62
|
-
const { header, id, align, headerStyle, sortable, filter } = column;
|
|
63
|
-
const isFirst = id === columns[0].id;
|
|
64
|
-
const isLast = id === columns[columns.length - 1].id;
|
|
65
|
-
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: isFirst, isLast: isLast, sx: Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', fontWeight: 600 }, headerStyle), isSheetView: isSheetView }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter)), sortable && _jsx(ColumnIcon, { onClick: sortable ? handleClick : undefined, src: columnIcon, alt: "column-icon", "data-id": id })] }), `${id}-${colIndex}`));
|
|
66
|
-
}) })), _jsx(Dropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: [
|
|
67
|
-
{
|
|
68
|
-
label: 'Sort A-Z',
|
|
69
|
-
name: 'asc',
|
|
70
|
-
icon: _jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }),
|
|
71
|
-
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc',
|
|
72
|
-
onClick: () => {
|
|
73
|
-
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc');
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: 'Sort Z-A',
|
|
78
|
-
name: 'desc',
|
|
79
|
-
icon: _jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }),
|
|
80
|
-
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc',
|
|
81
|
-
onClick: () => {
|
|
82
|
-
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc');
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
] })] })));
|
|
86
|
-
}
|
|
87
|
-
export default memo(TableHeader);
|