@tap-payments/os-micro-frontend-shared 0.0.276 → 0.0.278-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.
- package/LICENSE +21 -21
- package/README.md +12 -12
- package/build/components/CustomBackdrop/CustomBackdrop.d.ts +1 -1
- package/build/components/CustomBackdrop/CustomBackdrop.js +2 -1
- package/build/components/CustomBackdrop/style.js +1 -1
- package/build/components/TableCells/CustomCells/DestinationCell/DestinationCell.js +22 -19
- package/build/components/VirtualTable/SheetView/SheetViewVirtualTable.js +3 -6
- package/build/components/VirtualTable/SheetView/{SheetViewTableHeader.d.ts → components/SheetViewTableHeader/SheetViewTableHeader.d.ts} +2 -2
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/SheetViewTableHeader.js +10 -0
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/TableCell.d.ts +13 -0
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/TableCell.js +38 -0
- 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/components/SheetViewTableHeader/type.d.ts +16 -0
- package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/type.js +1 -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.d.ts +17 -20
- package/build/components/VirtualTable/SheetView/style.js +5 -3
- package/build/components/VirtualTable/components/ColumnFilter/ColumnFilter.d.ts +2 -2
- package/build/components/VirtualTable/components/ColumnFilter/ColumnFilter.js +9 -13
- 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/ColumnSort/ColumnSort.d.ts +10 -0
- package/build/components/VirtualTable/components/ColumnSort/ColumnSort.js +36 -0
- package/build/components/VirtualTable/components/ColumnSort/index.d.ts +2 -0
- package/build/components/VirtualTable/components/ColumnSort/index.js +2 -0
- package/build/components/VirtualTable/components/ColumnSort/style.d.ts +3 -0
- package/build/components/VirtualTable/components/ColumnSort/style.js +10 -0
- package/build/components/VirtualTable/components/TableFooter/style.js +2 -2
- package/build/components/VirtualTable/components/TableHeader/TableHeader.d.ts +5 -0
- package/build/components/VirtualTable/components/TableHeader/TableHeader.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 +1 -0
- package/build/components/VirtualTable/components/TableHeader/components/index.js +1 -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 +3 -0
- package/build/components/VirtualTable/components/TableHeader/index.js +3 -0
- package/build/components/VirtualTable/components/TableHeader/style.d.ts +12 -0
- package/build/components/VirtualTable/components/TableHeader/style.js +23 -0
- package/build/components/VirtualTable/components/TableHeader/type.d.ts +10 -0
- package/build/components/VirtualTable/components/TableHeader/type.js +1 -0
- package/build/components/VirtualTable/style.js +1 -1
- package/build/constants/table/cell/chargeTableCellWidth.d.ts +1 -1
- package/build/constants/table/cell/chargeTableCellWidth.js +1 -1
- package/package.json +3 -3
- package/build/components/VirtualTable/SheetView/SheetViewTableHeader.js +0 -73
- package/build/components/VirtualTable/components/TableHeader.d.ts +0 -27
- package/build/components/VirtualTable/components/TableHeader.js +0 -87
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Tap Payments
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tap Payments
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# os-micro-frontend-shared
|
|
2
|
-
|
|
3
|
-
## Publishing Workflow
|
|
4
|
-
|
|
5
|
-
1. Update version in package.json
|
|
6
|
-
2. Commit changes
|
|
7
|
-
3. Create and push a tag:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm version patch # or minor, major
|
|
11
|
-
git push origin main --tags
|
|
12
|
-
```
|
|
1
|
+
# os-micro-frontend-shared
|
|
2
|
+
|
|
3
|
+
## Publishing Workflow
|
|
4
|
+
|
|
5
|
+
1. Update version in package.json
|
|
6
|
+
2. Commit changes
|
|
7
|
+
3. Create and push a tag:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm version patch # or minor, major
|
|
11
|
+
git push origin main --tags
|
|
12
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
declare function CustomBackdrop(props: BoxProps): import("react
|
|
3
|
+
declare function CustomBackdrop(props: BoxProps): import("react").ReactPortal;
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<typeof CustomBackdrop>;
|
|
5
5
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
3
4
|
import { CustomBackdropStyled } from './style';
|
|
4
5
|
function CustomBackdrop(props) {
|
|
5
|
-
return _jsx(CustomBackdropStyled, Object.assign({}, props));
|
|
6
|
+
return ReactDOM.createPortal(_jsx(CustomBackdropStyled, Object.assign({}, props)), document.body);
|
|
6
7
|
}
|
|
7
8
|
export default memo(CustomBackdrop);
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx,
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import Tooltip from '../../../Tooltip';
|
|
14
14
|
import { destinationSolidIcon } from '../../../../constants/index.js';
|
|
15
15
|
import { formatAmount } from '../../../../utils/index.js';
|
|
@@ -18,37 +18,40 @@ import TableCell from '../../TableCell';
|
|
|
18
18
|
import { TextLabel } from '../style';
|
|
19
19
|
import { CurrencyIcon, StatusGroupChips } from '../../../index.js';
|
|
20
20
|
function DestinationCell(_a) {
|
|
21
|
-
var _b, _c, _d, _e, _f
|
|
21
|
+
var _b, _c, _d, _e, _f;
|
|
22
22
|
var { destinationsCount, destinationsTooltip, isTextShown, destination, destinationsAmount, hidden, iconDirection, tableMode } = _a, props = __rest(_a, ["destinationsCount", "destinationsTooltip", "isTextShown", "destination", "destinationsAmount", "hidden", "iconDirection", "tableMode"]);
|
|
23
23
|
const destinations = (destination === null || destination === void 0 ? void 0 : destination.destination) || [];
|
|
24
24
|
const formattedAmount = formatAmount(destinationsAmount || 0);
|
|
25
25
|
const firstDestinationFormattedAmount = formatAmount(((_b = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _b === void 0 ? void 0 : _b.amount) || 0);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
];
|
|
26
|
+
const isSheetView = tableMode === 'sheet';
|
|
27
|
+
if (isSheetView) {
|
|
28
|
+
const sheetViewChips = destinations === null || destinations === void 0 ? void 0 : destinations.reduce((acc, dest) => {
|
|
29
|
+
const formattedDestAmount = formatAmount((dest === null || dest === void 0 ? void 0 : dest.amount) || 0);
|
|
30
|
+
return [
|
|
31
|
+
...acc,
|
|
32
|
+
{
|
|
33
|
+
key: 'id',
|
|
34
|
+
content: dest === null || dest === void 0 ? void 0 : dest.id,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: 'amount',
|
|
38
|
+
content: (_jsxs(_Fragment, { children: [_jsx(CurrencyIcon, { currency: dest === null || dest === void 0 ? void 0 : dest.currency }), _jsxs("span", { children: [formattedDestAmount.integerAmount, ".", formattedDestAmount.decimalAmount] })] })),
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
}, []);
|
|
42
42
|
return (_jsx(TableCell, Object.assign({ sx: {
|
|
43
43
|
width: 'fit-content',
|
|
44
44
|
overflow: 'visible',
|
|
45
45
|
} }, props, { children: _jsx(StatusGroupChips, { chips: sheetViewChips }) })));
|
|
46
46
|
}
|
|
47
|
+
if (!destinationsCount || hidden) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
47
50
|
const textView = (_jsx(TextLabel, Object.assign({ sx: {
|
|
48
51
|
textAlign: 'left',
|
|
49
52
|
justifyContent: 'flex-start',
|
|
50
53
|
height: 'auto',
|
|
51
|
-
} }, { children: destinationsCount > 1 ? (_jsxs("div", { children: ["Destination ", (
|
|
54
|
+
} }, { children: destinationsCount > 1 ? (_jsxs("div", { children: ["Destination ", (_c = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _c === void 0 ? void 0 : _c.id, " - ", _jsx(CurrencyIcon, { currency: (_d = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _d === void 0 ? void 0 : _d.currency }), ' ', firstDestinationFormattedAmount.integerAmount, ".", firstDestinationFormattedAmount.decimalAmount, " +", destinationsCount - 1] })) : (_jsxs("div", { children: ["Destination ", (_e = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _e === void 0 ? void 0 : _e.id, " - ", _jsx(CurrencyIcon, { currency: (_f = destinations === null || destinations === void 0 ? void 0 : destinations[0]) === null || _f === void 0 ? void 0 : _f.currency }), " ", formattedAmount.integerAmount, ".", formattedAmount.decimalAmount] })) })));
|
|
52
55
|
return (_jsx(TableCell, Object.assign({ sx: {
|
|
53
56
|
width: 'fit-content',
|
|
54
57
|
overflow: 'visible',
|
|
@@ -12,6 +12,7 @@ import { useMemo, memo, useState, useCallback } from 'react';
|
|
|
12
12
|
import { useTheme } from '@mui/material/styles';
|
|
13
13
|
import memoize from 'memoize-one';
|
|
14
14
|
import InfiniteLoader from 'react-window-infinite-loader';
|
|
15
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
15
16
|
import { TABLE_THRESHOLD, TABLE_LIST_OVER_SCAN, TABLE_ROW_HEIGHT } from '../../../constants/index.js';
|
|
16
17
|
import { useDelayToSetValue } from '../../../hooks/index.js';
|
|
17
18
|
import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../../utils/index.js';
|
|
@@ -22,8 +23,7 @@ import { SheetViewTableNoData } from './components';
|
|
|
22
23
|
import ListItemWrapper from '../components/virtualScroll/ListItemWrapper';
|
|
23
24
|
import { StyledBox, StyledTableBox, StyledVirtualList, TableContainer, TableWrapper } from '../style';
|
|
24
25
|
import { SheetViewVirtualTableWrapper, PinnedStartColumnWrapper, PinnedEndColumnWrapper, MainTableWrapper, UnpinnedTableHeaderWrapper } from './style';
|
|
25
|
-
import SheetViewTableHeader from './SheetViewTableHeader';
|
|
26
|
-
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
26
|
+
import SheetViewTableHeader from './components/SheetViewTableHeader';
|
|
27
27
|
import { usePinnedColumns } from './hooks/usePinnedColumns';
|
|
28
28
|
import { useSynchronizedScroll } from './hooks/useSynchronizedScroll';
|
|
29
29
|
const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, onCellClick) => ({
|
|
@@ -59,9 +59,6 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
59
59
|
}, []);
|
|
60
60
|
const handleColumnClick = useCallback((columnId, event) => {
|
|
61
61
|
event.stopPropagation();
|
|
62
|
-
if (event.target !== event.currentTarget) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
62
|
setSelectedColumn((prev) => (prev === columnId ? null : columnId));
|
|
66
63
|
setSelectedCell(null);
|
|
67
64
|
}, []);
|
|
@@ -99,7 +96,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
99
96
|
};
|
|
100
97
|
return (_jsx(InfiniteLoader, Object.assign({ isItemLoaded: (index) => index !== lastItemIndex, itemCount: tableItemsCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered }) => (_jsx(AutoSizer, { children: ({ height, width }) => (_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: fixedWidth || width, itemCount: tableItemsCount, itemSize: () => rowHeight, itemData: currentItemData, onItemsRendered: onItemsRendered, overscanCount: TABLE_LIST_OVER_SCAN, setBackdropVisibility: setShowBackdrop, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: handleScrollCallback, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: {
|
|
101
98
|
overflowX: isPinned ? 'hidden' : 'auto',
|
|
102
|
-
paddingBottom: '
|
|
99
|
+
paddingBottom: isPinned ? '25px' : '13px',
|
|
103
100
|
backgroundColor: isPinned ? 'transparent' : theme.palette.background.default,
|
|
104
101
|
} }, { children: ListItemWrapper }))) })) })));
|
|
105
102
|
}, [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type TableHeadProps } from '@mui/material';
|
|
3
|
-
import type { IColumnProps, IVirtualTable } from '
|
|
2
|
+
import { type TableHeadProps } from '@mui/material/TableHead';
|
|
3
|
+
import type { IColumnProps, IVirtualTable } from '../../../../../types/index.js';
|
|
4
4
|
interface SheetViewTableHeaderProps {
|
|
5
5
|
columns: IColumnProps[];
|
|
6
6
|
headerProps?: TableHeadProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { StyledHeader, StyledMUITableRow } from '../../style';
|
|
4
|
+
import TableCell from './TableCell';
|
|
5
|
+
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
6
|
+
return (_jsx(StyledHeader, Object.assign({ component: "nav", "data-testid": "SheetViewVirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { children: _jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "SheetViewVirtualTable_TableHeader_StyledMUITableRow" }, { 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, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === column.id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick }, `${column.id}-${colIndex}`));
|
|
8
|
+
}) })) })));
|
|
9
|
+
}
|
|
10
|
+
export default memo(SheetViewTableHeader);
|
package/build/components/VirtualTable/SheetView/components/SheetViewTableHeader/TableCell.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IColumnProps } from '../../../../../types/index.js';
|
|
3
|
+
import { SheetViewTableHeaderProps } from './type';
|
|
4
|
+
interface TableCellProps extends Pick<SheetViewTableHeaderProps, 'onColumnSort' | 'columnsSorting' | 'onColumnPin' | 'isPinnable' | 'lastColumnId' | 'onColumnClick' | 'pinnedColumns'> {
|
|
5
|
+
column: IColumnProps;
|
|
6
|
+
isFirst: boolean;
|
|
7
|
+
isLast: boolean;
|
|
8
|
+
isSelected: boolean;
|
|
9
|
+
isDefaultPinned: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order }, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const _default: import("react").MemoExoticComponent<typeof TableCell>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import { pinIcon, unpinIcon } from '../../../../../constants/index.js';
|
|
5
|
+
import ColumnFilter from '../../../components/ColumnFilter';
|
|
6
|
+
import { StyledCell } from '../../../style';
|
|
7
|
+
import { PinIconContainer, HeaderText } from '../../style';
|
|
8
|
+
import ColumnSort from '../../../../VirtualTable/components/ColumnSort';
|
|
9
|
+
function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order }, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }) {
|
|
10
|
+
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
11
|
+
const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
|
|
12
|
+
const isPinned = useMemo(() => checkIsPanned(id), [id, checkIsPanned]);
|
|
13
|
+
const handlePinClick = (columnId) => {
|
|
14
|
+
if (checkIsPanned(columnId)) {
|
|
15
|
+
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'unpin');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (columnId === lastColumnId) {
|
|
19
|
+
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'end');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'start');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_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, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => {
|
|
27
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event);
|
|
28
|
+
setColumnFilterEl(event.currentTarget);
|
|
29
|
+
}, sx: (theme) => (Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', 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) => {
|
|
30
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event);
|
|
31
|
+
} }))), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
32
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, e);
|
|
33
|
+
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
handlePinClick(id);
|
|
36
|
+
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })));
|
|
37
|
+
}
|
|
38
|
+
export default memo(TableCell);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableHeaderProps } from '../../../../VirtualTable/components/TableHeader/type';
|
|
3
|
+
import { IColumnProps, IVirtualTable } from '../../../../../types/index.js';
|
|
4
|
+
export interface SheetViewTableHeaderProps {
|
|
5
|
+
columns: IColumnProps[];
|
|
6
|
+
headerProps?: TableHeaderProps;
|
|
7
|
+
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
8
|
+
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
9
|
+
showBackDrop: boolean;
|
|
10
|
+
pinnedColumns?: string[];
|
|
11
|
+
onColumnPin?: (columnId: string, position: 'start' | 'end' | 'unpin') => void;
|
|
12
|
+
isPinnable?: boolean;
|
|
13
|
+
lastColumnId?: string | null;
|
|
14
|
+
selectedColumn?: string | null;
|
|
15
|
+
onColumnClick?: (columnId: string, event: React.MouseEvent) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const ActionIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").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").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
4
|
-
export declare const HeaderText: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
5
|
-
export declare const PinIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
-
|
|
7
|
-
showBackDrop: boolean;
|
|
8
|
-
}
|
|
9
|
-
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"> & {
|
|
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>, {}>;
|
|
4
|
+
export declare const HeaderText: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
5
|
+
export declare const PinIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
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"> & {
|
|
10
7
|
ref?: ((instance: HTMLTableSectionElement | null) => void) | import("react").RefObject<HTMLTableSectionElement> | null | undefined;
|
|
11
|
-
}, "className" | "style" | "classes" | "children" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> &
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const StyledMUITableRow: import("@emotion/styled").StyledComponent<import("@mui/material").TableRowOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> & {
|
|
8
|
+
}, "className" | "style" | "classes" | "children" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
9
|
+
showBackDrop: boolean;
|
|
10
|
+
}, {}, {}>;
|
|
11
|
+
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"> & {
|
|
16
12
|
ref?: ((instance: HTMLTableRowElement | null) => void) | import("react").RefObject<HTMLTableRowElement> | null | undefined;
|
|
17
|
-
}, "className" | "style" | "classes" | "children" | "sx" | "hover" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> &
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
13
|
+
}, "className" | "style" | "classes" | "children" | "sx" | "hover" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
14
|
+
component: string;
|
|
15
|
+
}, {}, {}>;
|
|
16
|
+
export declare const SheetViewVirtualTableWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
17
|
+
export declare const PinnedStartColumnWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, {}, {}>;
|
|
18
|
+
export declare const PinnedEndColumnWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, {}, {}>;
|
|
19
|
+
export declare const MainTableWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
22
20
|
hasPinnedStart: boolean;
|
|
23
21
|
hasPinnedEnd: boolean;
|
|
24
22
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
25
|
-
export declare const UnpinnedTableHeaderWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
26
|
-
export {};
|
|
23
|
+
export declare const UnpinnedTableHeaderWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
|
-
import
|
|
2
|
+
import TableHead from '@mui/material/TableHead';
|
|
3
3
|
import MUITableRow from '@mui/material/TableRow';
|
|
4
4
|
export const ActionIcon = styled('img')(() => ({
|
|
5
5
|
width: '13.3px',
|
|
@@ -9,6 +9,7 @@ export const ColumnIcon = styled('img')(() => ({
|
|
|
9
9
|
width: '8px',
|
|
10
10
|
height: '6.4px',
|
|
11
11
|
cursor: 'pointer',
|
|
12
|
+
marginTop: '2px',
|
|
12
13
|
}));
|
|
13
14
|
export const HeaderText = styled('span')(({ theme }) => ({
|
|
14
15
|
color: theme.palette.text.primary,
|
|
@@ -32,12 +33,13 @@ export const PinIconContainer = styled('div')(() => ({
|
|
|
32
33
|
export const StyledHeader = styled(TableHead, {
|
|
33
34
|
shouldForwardProp: (prop) => prop !== 'showBackDrop',
|
|
34
35
|
})(({ showBackDrop, theme }) => ({
|
|
35
|
-
width: '100%',
|
|
36
|
-
minWidth: 'fit-content',
|
|
37
36
|
flex: '0 0 auto',
|
|
38
37
|
boxShadow: showBackDrop ? theme.shadows[23] : 'none',
|
|
39
38
|
backgroundColor: theme.palette.background.default,
|
|
40
39
|
zIndex: 1,
|
|
40
|
+
width: '100%',
|
|
41
|
+
minWidth: 'auto',
|
|
42
|
+
overflowX: 'scroll',
|
|
41
43
|
}));
|
|
42
44
|
export const StyledMUITableRow = styled(MUITableRow)(({ theme }) => ({
|
|
43
45
|
display: 'flex',
|
|
@@ -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,11 @@ import List from './List';
|
|
|
9
8
|
import { FilterWrapper } from './style';
|
|
10
9
|
import CustomBackdrop from '../../../CustomBackdrop';
|
|
11
10
|
function ColumnFilter(filter) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
const onCloseDropdown = () => {
|
|
11
|
+
const { anchorEl, setAnchorEl, onClose } = filter;
|
|
12
|
+
const onCloseDropdown = (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
17
14
|
setAnchorEl(null);
|
|
15
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
18
16
|
};
|
|
19
17
|
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
18
|
const listFilterData = useMemo(() => {
|
|
@@ -50,10 +48,8 @@ function ColumnFilter(filter) {
|
|
|
50
48
|
}
|
|
51
49
|
return null;
|
|
52
50
|
}, [open, filter, anchorEl, setAnchorEl]);
|
|
53
|
-
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
zIndex: 9999,
|
|
57
|
-
} }, { children: renderFilter }))] })) })));
|
|
51
|
+
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 } }), _jsx(Box, { component: "img", "data-testid": "ColumnFilter_closeIcon", src: closeIcon, alt: "close-icon", onClick: () => {
|
|
52
|
+
filter.onClear(filterApiKeys);
|
|
53
|
+
} })] })) : (_jsx(Box, { component: "img", "data-testid": "ColumnFilter_columnIcon", src: columnIcon, alt: "column-icon", sx: { cursor: 'pointer', marginTop: '2px', userSelect: 'none' } })), open && _jsx(CustomBackdrop, { onClick: onCloseDropdown }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start" }, { children: renderFilter }))] }));
|
|
58
54
|
}
|
|
59
55
|
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,10 @@
|
|
|
1
|
+
import { type MouseEvent } from 'react';
|
|
2
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
3
|
+
import { TableHeaderProps } from '../TableHeader/type';
|
|
4
|
+
interface ColumnSortProps extends Pick<TableHeaderProps, 'onColumnSort' | 'columnsSorting'> {
|
|
5
|
+
columnId: IColumnProps['id'];
|
|
6
|
+
onClick?: (e: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function ColumnSort({ onColumnSort, columnsSorting, columnId, onClick }: ColumnSortProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const _default: import("react").MemoExoticComponent<typeof ColumnSort>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState } from 'react';
|
|
3
|
+
import CustomBackdrop from '../../../CustomBackdrop';
|
|
4
|
+
import Menu from '../../../Menu';
|
|
5
|
+
import MenuItem from '../../../MenuItem';
|
|
6
|
+
import Text from '../../../Text';
|
|
7
|
+
import { columnIcon, sortAzIcon, sortZaIcon } from '../../../../constants/index.js';
|
|
8
|
+
import { ActionIcon, ColumnIcon } from './style';
|
|
9
|
+
function ColumnSort({ onColumnSort, columnsSorting, columnId, onClick }) {
|
|
10
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
|
+
const open = Boolean(anchorEl);
|
|
12
|
+
const handleClick = (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
setAnchorEl(event.currentTarget);
|
|
15
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
16
|
+
};
|
|
17
|
+
const handleClose = (event) => {
|
|
18
|
+
event.stopPropagation();
|
|
19
|
+
setAnchorEl(null);
|
|
20
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
21
|
+
};
|
|
22
|
+
const handleSortingOption = (id, order, event) => {
|
|
23
|
+
if (id) {
|
|
24
|
+
onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
|
|
25
|
+
[id]: order,
|
|
26
|
+
});
|
|
27
|
+
handleClose(event);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx(ColumnIcon, { onClick: handleClick, src: columnIcon, alt: "column-icon", "data-id": columnId, sx: { userSelect: 'none' } }), open && _jsx(CustomBackdrop, { onClick: handleClose }), _jsxs(Menu, Object.assign({ anchorEl: anchorEl, open: open }, { children: [_jsxs(MenuItem, Object.assign({ onClick: (e) => {
|
|
31
|
+
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc', e);
|
|
32
|
+
}, sx: (theme) => (Object.assign({}, ((columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc' && { boxShadow: theme.shadows[10] }))) }, { children: [_jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }), _jsx(Text, Object.assign({ sx: { fontSize: '0.6875rem' } }, { children: "Sort Z-A" }))] })), _jsxs(MenuItem, Object.assign({ onClick: (e) => {
|
|
33
|
+
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc', e);
|
|
34
|
+
}, sx: (theme) => (Object.assign({}, ((columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc' && { boxShadow: theme.shadows[10] }))) }, { children: [_jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }), _jsx(Text, Object.assign({ sx: { fontSize: '0.6875rem' } }, { children: "Sort Z-A" }))] }))] }))] }));
|
|
35
|
+
}
|
|
36
|
+
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>, {}>;
|
|
@@ -14,8 +14,8 @@ export const EngravingLine = styled('div')(({ theme }) => ({
|
|
|
14
14
|
left: 0,
|
|
15
15
|
right: 0,
|
|
16
16
|
height: '1.5px',
|
|
17
|
-
backgroundColor: theme.palette.grey[
|
|
18
|
-
boxShadow: `inset 0 1px 0 0 ${theme.palette.grey[
|
|
17
|
+
backgroundColor: theme.palette.grey[300],
|
|
18
|
+
boxShadow: `inset 0 1px 0 0 ${theme.palette.grey[300]}`,
|
|
19
19
|
}));
|
|
20
20
|
export const Label = styled(Box)(({ theme }) => ({
|
|
21
21
|
borderRadius: '37.5px',
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableHeaderProps } from './type';
|
|
3
|
+
declare function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<typeof TableHeader>;
|
|
5
|
+
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, { 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/TableCell/TableCell.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../../../types/index.js';
|
|
2
|
+
import { TableHeaderProps } from '../../../../../VirtualTable/components/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 '../../../../../VirtualTable/components/ColumnFilter';
|
|
5
|
+
import ColumnSort from '../../../../../VirtualTable/components/ColumnSort';
|
|
6
|
+
import { StyledCell } from '../../../../../VirtualTable/style';
|
|
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 @@
|
|
|
1
|
+
export { default as TableCell } from './TableCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableCell } from './TableCell';
|
|
@@ -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,23 @@
|
|
|
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
|
+
flex: '0 0 auto',
|
|
8
|
+
boxShadow: showBackDrop ? theme.shadows[23] : 'none',
|
|
9
|
+
backgroundColor: theme.palette.background.default,
|
|
10
|
+
zIndex: 1,
|
|
11
|
+
width: '100%',
|
|
12
|
+
minWidth: 'auto',
|
|
13
|
+
overflowX: 'scroll',
|
|
14
|
+
}));
|
|
15
|
+
export const StyledMUITableRow = styled(MUITableRow, {
|
|
16
|
+
shouldForwardProp: (prop) => prop !== 'isSheetView',
|
|
17
|
+
})(({ theme, isSheetView }) => (Object.assign({ display: 'flex', justifyContent: 'flex-start', width: '100%', minWidth: 'fit-content', paddingInline: '32px', paddingBlock: '16px' }, (isSheetView && {
|
|
18
|
+
height: '28px',
|
|
19
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
20
|
+
backgroundColor: theme.palette.primary.light,
|
|
21
|
+
paddingInline: 0,
|
|
22
|
+
paddingBlock: 0,
|
|
23
|
+
}))));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TableHeadProps } from '@mui/material/TableHead';
|
|
2
|
+
import type { IColumnProps, IVirtualTable } from '../../../../types/index.js';
|
|
3
|
+
export interface TableHeaderProps {
|
|
4
|
+
columns: IColumnProps[];
|
|
5
|
+
headerProps?: TableHeadProps;
|
|
6
|
+
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
7
|
+
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
8
|
+
showBackDrop: boolean;
|
|
9
|
+
isSheetView?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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',
|
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.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.0.278-test.1",
|
|
5
|
+
"testVersion": 1,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -131,4 +131,4 @@
|
|
|
131
131
|
"publishConfig": {
|
|
132
132
|
"registry": "https://registry.npmjs.org/"
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useState } from 'react';
|
|
3
|
-
import { Box, useTheme } from '@mui/material';
|
|
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
|
-
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
10
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
|
-
const open = Boolean(anchorEl);
|
|
12
|
-
const theme = useTheme();
|
|
13
|
-
const handleClick = (event) => {
|
|
14
|
-
setAnchorEl(event.currentTarget);
|
|
15
|
-
};
|
|
16
|
-
const handleClose = () => {
|
|
17
|
-
setAnchorEl(null);
|
|
18
|
-
};
|
|
19
|
-
const handleSortingOption = (columnId, order) => {
|
|
20
|
-
if (columnId) {
|
|
21
|
-
onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
|
|
22
|
-
[columnId]: order,
|
|
23
|
-
});
|
|
24
|
-
handleClose();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const handlePinClick = (columnId) => {
|
|
28
|
-
const isCurrentlyPinned = pinnedColumns.includes(columnId);
|
|
29
|
-
if (isCurrentlyPinned) {
|
|
30
|
-
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'unpin');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
if (columnId === lastColumnId) {
|
|
34
|
-
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'end');
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'start');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return (_jsxs(StyledHeader, Object.assign({ component: "nav", "data-testid": "SheetViewVirtualTable_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": "SheetViewVirtualTable_TableHeader_StyledMUITableRow" }, { children: columns.map((column, colIndex) => {
|
|
42
|
-
const { header, id, align, headerStyle, sortable, filter, pinnable } = column;
|
|
43
|
-
const isFirst = id === columns[0].id;
|
|
44
|
-
const isLast = id === columns[columns.length - 1].id;
|
|
45
|
-
const isPinned = pinnedColumns.includes(id);
|
|
46
|
-
const isDefaultPinned = !!column.isDefaultPinned;
|
|
47
|
-
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) => onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event), 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)), sortable && _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
|
-
event.stopPropagation();
|
|
50
|
-
handlePinClick(id);
|
|
51
|
-
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] }), `${id}-${colIndex}`));
|
|
52
|
-
}) })), _jsx(Dropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: [
|
|
53
|
-
{
|
|
54
|
-
label: 'Sort A-Z',
|
|
55
|
-
name: 'asc',
|
|
56
|
-
icon: _jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }),
|
|
57
|
-
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc',
|
|
58
|
-
onClick: () => {
|
|
59
|
-
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc');
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: 'Sort Z-A',
|
|
64
|
-
name: 'desc',
|
|
65
|
-
icon: _jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }),
|
|
66
|
-
selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc',
|
|
67
|
-
onClick: () => {
|
|
68
|
-
handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc');
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
] })] })));
|
|
72
|
-
}
|
|
73
|
-
export default memo(SheetViewTableHeader);
|
|
@@ -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);
|