@tap-payments/os-micro-frontend-shared 0.1.130-test.2 → 0.1.130-test.5-test.6
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/TableCells/CustomCells/BankCell/BankCell.js +2 -2
- package/build/components/TableCells/CustomCells/DateCell/DateCell.js +2 -2
- package/build/components/TableCells/CustomCells/EntityCell/EntityCell.js +2 -2
- package/build/components/TableCells/CustomCells/WalletCell/WalletCell.js +3 -3
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +4 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataView.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +1 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.d.ts +2 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js +4 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.d.ts +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts +11 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +38 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +1 -23
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +15 -19
- package/build/components/VirtualTables/SheetViewVirtualTable/types.d.ts +1 -0
- package/build/components/VirtualTables/components/TableRow.js +20 -18
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +1 -1
- package/build/components/index.d.ts +0 -2
- package/build/components/index.js +0 -2
- package/build/constants/table.d.ts +1 -1
- package/build/constants/table.js +1 -1
- package/build/utils/country.d.ts +1 -1
- package/build/utils/country.js +1 -1
- package/build/utils/style.d.ts +2 -2
- package/build/utils/style.js +2 -2
- package/package.json +2 -2
- package/build/components/ErrorToast/ErrorToast.d.ts +0 -3
- package/build/components/ErrorToast/ErrorToast.js +0 -7
- package/build/components/ErrorToast/index.d.ts +0 -2
- package/build/components/ErrorToast/index.js +0 -2
- package/build/components/ErrorToast/style.d.ts +0 -9
- package/build/components/ErrorToast/style.js +0 -37
- package/build/components/ErrorToast/type.d.ts +0 -10
- package/build/components/ErrorToast/type.js +0 -1
- package/build/components/ToggleView/ToggleView.d.ts +0 -16
- package/build/components/ToggleView/ToggleView.js +0 -32
- package/build/components/ToggleView/ToggleWrapper.d.ts +0 -4
- package/build/components/ToggleView/ToggleWrapper.js +0 -8
- package/build/components/ToggleView/index.d.ts +0 -3
- package/build/components/ToggleView/index.js +0 -3
- package/build/components/ToggleView/style.d.ts +0 -14
- package/build/components/ToggleView/style.js +0 -31
- package/build/components/ToggleView/types.d.ts +0 -6
- package/build/components/ToggleView/types.js +0 -6
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
|
+
```
|
|
@@ -14,12 +14,12 @@ import Tooltip from '../../../Tooltip';
|
|
|
14
14
|
import CountryFlag from '../../../CountryFlag';
|
|
15
15
|
import { TableCell } from '../../../TableCells';
|
|
16
16
|
import { bankIcon } from '../../../../constants/index.js';
|
|
17
|
-
import {
|
|
17
|
+
import { getCountryNameByISO } from '../../../../utils/index.js';
|
|
18
18
|
import { BankCellContainer, BankIcon, BankIdContainer, BankWrapper, IconWrapper } from './style';
|
|
19
19
|
import { GeographyBox } from '../style';
|
|
20
20
|
function BankCell(_a) {
|
|
21
21
|
var { walletId, country, name } = _a, props = __rest(_a, ["walletId", "country", "name"]);
|
|
22
|
-
const icon = country && (_jsx(Tooltip, Object.assign({ title:
|
|
22
|
+
const icon = country && (_jsx(Tooltip, Object.assign({ title: getCountryNameByISO(country) }, { children: _jsx(CountryFlag, { code: country, sx: { padding: '1px' } }) })));
|
|
23
23
|
return (_jsx(TableCell, Object.assign({ style: {
|
|
24
24
|
textAlign: 'center',
|
|
25
25
|
overflow: 'visible',
|
|
@@ -14,13 +14,13 @@ import { useMemo } from 'react';
|
|
|
14
14
|
import { TableCell } from '../../../TableCells';
|
|
15
15
|
import Tooltip from '../../../Tooltip';
|
|
16
16
|
import CountryFlag from '../../../CountryFlag';
|
|
17
|
-
import { formatCellDate,
|
|
17
|
+
import { formatCellDate, getCountryNameByISO } from '../../../../utils/index.js';
|
|
18
18
|
import { DateCellContainer } from './style';
|
|
19
19
|
import { GeographyBox } from '../style';
|
|
20
20
|
import { Box } from '@mui/material';
|
|
21
21
|
function DateCell(_a) {
|
|
22
22
|
var { value, format: dateFormat, flagIcon, hasFlag, tableMode } = _a, props = __rest(_a, ["value", "format", "flagIcon", "hasFlag", "tableMode"]);
|
|
23
|
-
const icon = flagIcon && (_jsx(Tooltip, Object.assign({ title:
|
|
23
|
+
const icon = flagIcon && (_jsx(Tooltip, Object.assign({ title: getCountryNameByISO(flagIcon || '') }, { children: _jsx(CountryFlag, { code: flagIcon }) })));
|
|
24
24
|
const renderedValue = useMemo(() => formatCellDate(value, dateFormat), [value]);
|
|
25
25
|
return (_jsx(TableCell, Object.assign({}, props, { children: _jsxs(DateCellContainer, { children: [hasFlag && (_jsx(GeographyBox, Object.assign({ sx: {
|
|
26
26
|
visibility: 'visible',
|
|
@@ -15,10 +15,10 @@ import { EntityName, EntityWrapper, VerificationIcon, VerificationContainer } fr
|
|
|
15
15
|
import { verificationIcon } from './constants';
|
|
16
16
|
import Tooltip from '../../../Tooltip';
|
|
17
17
|
import { CountryFlag } from '../../../index.js';
|
|
18
|
-
import {
|
|
18
|
+
import { getCountryNameByISO } from '../../../../utils/index.js';
|
|
19
19
|
import { Box } from '@mui/material';
|
|
20
20
|
export default function EntityCell(_a) {
|
|
21
21
|
var { entity, country, verificationStatus, licenseNumber, hideStatus } = _a, props = __rest(_a, ["entity", "country", "verificationStatus", "licenseNumber", "hideStatus"]);
|
|
22
22
|
const icon = verificationIcon[verificationStatus !== null && verificationStatus !== void 0 ? verificationStatus : 'incomplete'];
|
|
23
|
-
return (_jsx(TableCell, Object.assign({}, props, { sx: { cursor: (props === null || props === void 0 ? void 0 : props.onClick) ? 'pointer' : 'default' } }, { children: _jsx(Tooltip, Object.assign({ title: entity }, { children: _jsx(EntityWrapper, Object.assign({ sx: { cursor: props.onClick ? 'pointer' : 'default' } }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", gap: '5px', sx: { overflow: 'hidden', width: '100%' } }, { children: [_jsx(Tooltip, Object.assign({ title:
|
|
23
|
+
return (_jsx(TableCell, Object.assign({}, props, { sx: { cursor: (props === null || props === void 0 ? void 0 : props.onClick) ? 'pointer' : 'default' } }, { children: _jsx(Tooltip, Object.assign({ title: entity }, { children: _jsx(EntityWrapper, Object.assign({ sx: { cursor: props.onClick ? 'pointer' : 'default' } }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", gap: '5px', sx: { overflow: 'hidden', width: '100%' } }, { children: [_jsx(Tooltip, Object.assign({ title: getCountryNameByISO(country) }, { children: _jsx(CountryFlag, { code: country }) })), _jsx(EntityName, { children: licenseNumber }), !hideStatus && (_jsx(VerificationContainer, { children: _jsx(VerificationIcon, { src: icon }) }))] })) })) })) })));
|
|
24
24
|
}
|
|
@@ -14,16 +14,16 @@ import Tooltip from '../../../Tooltip';
|
|
|
14
14
|
import CountryFlag from '../../../CountryFlag';
|
|
15
15
|
import { TableCell } from '../../../TableCells';
|
|
16
16
|
import { walletIcon } from '../../../../constants/index.js';
|
|
17
|
-
import {
|
|
17
|
+
import { getCountryNameByISO } from '../../../../utils/index.js';
|
|
18
18
|
import { WalletCellContainer, WalletIcon, WalletIdContainer, WalletWrapper } from './style';
|
|
19
19
|
import { GeographyBox, StatusIconWrapper } from '../style';
|
|
20
20
|
function WalletCell(_a) {
|
|
21
21
|
var { walletId, country, showCountry = true } = _a, props = __rest(_a, ["walletId", "country", "showCountry"]);
|
|
22
|
-
const icon = country && (_jsx(Tooltip, Object.assign({ title:
|
|
22
|
+
const icon = country && (_jsx(Tooltip, Object.assign({ title: getCountryNameByISO(country) }, { children: _jsx(CountryFlag, { code: country, sx: { padding: '1px' } }) })));
|
|
23
23
|
return (_jsx(TableCell, Object.assign({ style: {
|
|
24
24
|
textAlign: 'center',
|
|
25
25
|
overflow: 'visible',
|
|
26
|
-
} }, props, { children: _jsxs(WalletCellContainer, { children: [showCountry && (_jsx(StatusIconWrapper, { children: _jsx(Tooltip, Object.assign({ title: country ?
|
|
26
|
+
} }, props, { children: _jsxs(WalletCellContainer, { children: [showCountry && (_jsx(StatusIconWrapper, { children: _jsx(Tooltip, Object.assign({ title: country ? getCountryNameByISO(country) : '' }, { children: _jsx(GeographyBox, Object.assign({ sx: {
|
|
27
27
|
visibility: 'visible',
|
|
28
28
|
}, variant: undefined }, { children: icon })) })) })), _jsxs(WalletWrapper, { children: [_jsx(WalletIcon, { src: walletIcon, alt: "wallet-icon" }), walletId && _jsxs(WalletIdContainer, { children: ["\u00B7\u00B7\u00B7\u00B7 ", walletId === null || walletId === void 0 ? void 0 : walletId.substring(((walletId === null || walletId === void 0 ? void 0 : walletId.length) || 0) - 4)] })] })] }) })));
|
|
29
29
|
}
|
|
@@ -4,9 +4,10 @@ import { SHEET_VIEW_TABLE_THRESHOLD } from '../../../constants/index.js';
|
|
|
4
4
|
import TableFooter from '../components/TableFooter/TableFooter';
|
|
5
5
|
import { SheetViewTableContainer } from '../components/style';
|
|
6
6
|
import { SheetViewVirtualTableWrapper } from './style';
|
|
7
|
-
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths } from './hooks';
|
|
7
|
+
import { usePinnedColumns, useSynchronizedScroll, useTableState, useTableData, useVirtualTableContainer, usePinnedColumnsWidths, usePerformanceOptimizations, } from './hooks';
|
|
8
8
|
import { PinnedColumn, MainTable, LoadingMainTable, NoDataView, VirtualTable } from './components';
|
|
9
9
|
function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, rowHeight = 28, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableTitle, dragControls, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, overscanCount, }) {
|
|
10
|
+
const { stableColumns } = usePerformanceOptimizations(columns);
|
|
10
11
|
const { selectedCell, selectedColumn, selectedRow, showBackDrop, setShowBackdrop, handleCellClick, handleColumnClick, handleChipClick, selectedChip, } = useTableState();
|
|
11
12
|
const { isError, tableLoading, tableError, tableEmpty, hasTimeoutError, showNoDataView, lastItemIndex, areTotalRowsNotFillingHeight, itemsCount, isDelayedFetchingNextPage, } = useTableData({
|
|
12
13
|
rows,
|
|
@@ -15,7 +16,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
15
16
|
isFetchingNextPage,
|
|
16
17
|
areAllRowsLoaded,
|
|
17
18
|
});
|
|
18
|
-
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(
|
|
19
|
+
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(stableColumns, isPinnable, onColumnPin);
|
|
19
20
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
20
21
|
const { pinnedStartColumnsWidth, pinnedEndColumnsWidth } = usePinnedColumnsWidths(pinnedStartColumnsData, pinnedEndColumnsData);
|
|
21
22
|
const { getItemSize, getItemDataForContainer } = useVirtualTableContainer({
|
|
@@ -57,6 +58,7 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
|
|
|
57
58
|
clearBackdropVisibilityTimeout,
|
|
58
59
|
handleScroll,
|
|
59
60
|
setShowBackdrop,
|
|
61
|
+
overscanCount,
|
|
60
62
|
pinnedStartVirtualListRef,
|
|
61
63
|
pinnedEndVirtualListRef,
|
|
62
64
|
scrollableVirtualListRef,
|
|
@@ -7,7 +7,7 @@ import SheetViewTableHeader from './SheetViewTableHeader';
|
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
8
|
function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
-
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox_Loading", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_LoadingTableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_LoadingTableWrapper", sx: {
|
|
10
|
+
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox_Loading", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_LoadingTableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd, isLoading: isLoading }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_LoadingTableWrapper", sx: {
|
|
11
11
|
width: '100%',
|
|
12
12
|
minWidth: 'fit-content',
|
|
13
13
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_LoadingStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
@@ -7,7 +7,7 @@ import SheetViewTableHeader from './SheetViewTableHeader';
|
|
|
7
7
|
import SheetViewTableLoading from './SheetViewTableLoading';
|
|
8
8
|
function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, pinnedStartColumns, pinnedEndColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, createVirtualTableContainer, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
|
-
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
10
|
+
return (_jsx(MainTableWrapper, Object.assign({ hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: "scrollable", hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd, isLoading: isLoading }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
11
11
|
width: '100%',
|
|
12
12
|
minWidth: 'fit-content',
|
|
13
13
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper", sx: {
|
|
@@ -8,6 +8,6 @@ import SheetViewTableHeader from './SheetViewTableHeader';
|
|
|
8
8
|
function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, tableMode, tableBodyStyles, error, triggerDataRefetch, footerProps, }) {
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
|
|
11
|
-
return (_jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: orderedColumns, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [], onColumnPin: onColumnPin, isPinnable: false, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick }) })), _jsx(TableNoData, { error: error || null, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch || (() => Promise.resolve()), footerProps: footerProps })] })) })));
|
|
11
|
+
return (_jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_LoadingTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: orderedColumns, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [], onColumnPin: onColumnPin, isPinnable: false, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, isLoading: isLoading }) })), _jsx(TableNoData, { error: error || null, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch || (() => Promise.resolve()), footerProps: footerProps })] })) })));
|
|
12
12
|
}
|
|
13
13
|
export default memo(NoDataView);
|
|
@@ -11,7 +11,7 @@ function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList,
|
|
|
11
11
|
return null;
|
|
12
12
|
const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
|
|
13
13
|
const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
14
|
-
return (_jsx(Wrapper, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: position === 'start' ? 'pinnedStart' : 'pinnedEnd', hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
14
|
+
return (_jsx(Wrapper, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: onColumnClick, tablePosition: position === 'start' ? 'pinnedStart' : 'pinnedEnd', hasPinnedStart: hasPinnedStart, hasPinnedEnd: hasPinnedEnd, isLoading: isLoading })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
15
15
|
width: '100%',
|
|
16
16
|
minWidth: 'fit-content',
|
|
17
17
|
overflowX: 'hidden',
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SheetViewTableHeaderProps } from '../types';
|
|
3
3
|
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const MemoizedSheetViewTableHeader: import("react").MemoExoticComponent<typeof SheetViewTableHeader>;
|
|
5
|
+
export default MemoizedSheetViewTableHeader;
|
package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js
CHANGED
|
@@ -9,4 +9,7 @@ function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort
|
|
|
9
9
|
return (_jsx(SheetViewTableHeaderCell, { column: column, colIndex: colIndex, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, isDefaultPinned: !!column.isDefaultPinned, isSelected: selectedColumn === columnKey, onColumnSort: onColumnSort, columnsSorting: columnsSorting, pinnedColumns: pinnedColumns, onColumnPin: onColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, onColumnClick: onColumnClick }, `${column.id}-${colIndex}`));
|
|
10
10
|
}) })) })));
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const MemoizedSheetViewTableHeader = memo(SheetViewTableHeader, (prevProps, nextProps) => {
|
|
13
|
+
return prevProps.isLoading === nextProps.isLoading;
|
|
14
|
+
});
|
|
15
|
+
export default MemoizedSheetViewTableHeader;
|
|
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
|
|
|
4
4
|
export { useTableData } from './useTableData';
|
|
5
5
|
export { useVirtualTableContainer } from './useVirtualTableContainer';
|
|
6
6
|
export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
|
|
7
|
+
export { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
|
@@ -4,3 +4,4 @@ export { useTableState } from './useTableState';
|
|
|
4
4
|
export { useTableData } from './useTableData';
|
|
5
5
|
export { useVirtualTableContainer } from './useVirtualTableContainer';
|
|
6
6
|
export { usePinnedColumnsWidths } from './usePinnedColumnsWidths';
|
|
7
|
+
export { usePerformanceOptimizations } from './usePerformanceOptimizations';
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IColumnProps } from '../../../../types/index.js';
|
|
2
|
+
export declare const usePerformanceOptimizations: (columns: readonly IColumnProps[]) => {
|
|
3
|
+
stableColumns: IColumnProps<any>[];
|
|
4
|
+
columnMetrics: {
|
|
5
|
+
visibleColumns: IColumnProps<any>[];
|
|
6
|
+
totalWidth: number;
|
|
7
|
+
columnCount: number;
|
|
8
|
+
firstColumnId: string | number | symbol;
|
|
9
|
+
lastColumnId: string | number | symbol;
|
|
10
|
+
};
|
|
11
|
+
};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
export const usePerformanceOptimizations = (columns) => {
|
|
3
|
+
const stableColumnsRef = useRef([]);
|
|
4
|
+
const stableColumns = useMemo(() => {
|
|
5
|
+
const hasChanged = columns.length !== stableColumnsRef.current.length ||
|
|
6
|
+
columns.some((col, index) => {
|
|
7
|
+
const prevCol = stableColumnsRef.current[index];
|
|
8
|
+
return (!prevCol ||
|
|
9
|
+
col.id !== prevCol.id ||
|
|
10
|
+
col.width !== prevCol.width ||
|
|
11
|
+
col.pinned !== prevCol.pinned ||
|
|
12
|
+
col.hidden !== prevCol.hidden ||
|
|
13
|
+
col.order !== prevCol.order ||
|
|
14
|
+
col.filter !== prevCol.filter);
|
|
15
|
+
});
|
|
16
|
+
if (hasChanged) {
|
|
17
|
+
stableColumnsRef.current = [...columns];
|
|
18
|
+
}
|
|
19
|
+
return stableColumnsRef.current;
|
|
20
|
+
}, [columns]);
|
|
21
|
+
const columnMetrics = useMemo(() => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const visibleColumns = stableColumns.filter((col) => !col.hidden);
|
|
24
|
+
const totalWidth = visibleColumns.reduce((sum, col) => sum + +((col === null || col === void 0 ? void 0 : col.width) || 100), 0);
|
|
25
|
+
const columnCount = visibleColumns.length;
|
|
26
|
+
return {
|
|
27
|
+
visibleColumns,
|
|
28
|
+
totalWidth,
|
|
29
|
+
columnCount,
|
|
30
|
+
firstColumnId: (_a = visibleColumns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
31
|
+
lastColumnId: (_b = visibleColumns[columnCount - 1]) === null || _b === void 0 ? void 0 : _b.id,
|
|
32
|
+
};
|
|
33
|
+
}, [stableColumns]);
|
|
34
|
+
return {
|
|
35
|
+
stableColumns,
|
|
36
|
+
columnMetrics,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -17,6 +17,7 @@ export const useTableState = () => {
|
|
|
17
17
|
}
|
|
18
18
|
setSelectedChip(chipKey);
|
|
19
19
|
setSelectedCell(cellKey);
|
|
20
|
+
setSelectedColumn(null);
|
|
20
21
|
setSelectedRow(null);
|
|
21
22
|
}, [selectedChip, setSelectedChip, setSelectedCell, setSelectedRow]);
|
|
22
23
|
const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts
CHANGED
|
@@ -23,28 +23,6 @@ interface UseVirtualTableContainerProps<T = unknown> extends TableChipProps {
|
|
|
23
23
|
}
|
|
24
24
|
export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }: UseVirtualTableContainerProps<T>) => {
|
|
25
25
|
getItemSize: (index: number, height: number) => number;
|
|
26
|
-
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) =>
|
|
27
|
-
columns: any;
|
|
28
|
-
isLoading: any;
|
|
29
|
-
rows: any;
|
|
30
|
-
rowProps: any;
|
|
31
|
-
scrollToIndex: any;
|
|
32
|
-
totalCount: any;
|
|
33
|
-
lastItemIndex: any;
|
|
34
|
-
isError: any;
|
|
35
|
-
areAllRowsLoaded: any;
|
|
36
|
-
limit: any;
|
|
37
|
-
newLoadedRowsEndIndex: any;
|
|
38
|
-
isSheetView: boolean;
|
|
39
|
-
isPinned: any;
|
|
40
|
-
selectedCell: any;
|
|
41
|
-
selectedColumn: any;
|
|
42
|
-
selectedRow: any;
|
|
43
|
-
selectedChip: any;
|
|
44
|
-
onCellClick: any;
|
|
45
|
-
onChipClick: any;
|
|
46
|
-
containerHeight: any;
|
|
47
|
-
rowHeight: any;
|
|
48
|
-
};
|
|
26
|
+
getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) => any;
|
|
49
27
|
};
|
|
50
28
|
export {};
|
package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
2
|
import memoize from 'memoize-one';
|
|
3
|
-
const
|
|
3
|
+
const createCoreItemData = memoize((columns, rows, rowProps, totalCount, lastItemIndex, isError, areAllRowsLoaded, isPinned, containerHeight, rowHeight) => ({
|
|
4
4
|
columns,
|
|
5
|
-
isLoading,
|
|
6
5
|
rows,
|
|
7
6
|
rowProps,
|
|
8
|
-
scrollToIndex,
|
|
9
7
|
totalCount,
|
|
10
8
|
lastItemIndex,
|
|
11
9
|
isError,
|
|
@@ -14,15 +12,19 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
|
|
|
14
12
|
newLoadedRowsEndIndex: lastItemIndex,
|
|
15
13
|
isSheetView: true,
|
|
16
14
|
isPinned,
|
|
15
|
+
containerHeight,
|
|
16
|
+
rowHeight,
|
|
17
|
+
}));
|
|
18
|
+
const createInteractionData = memoize((selectedCell, selectedColumn, selectedRow, selectedChip, onCellClick, onChipClick) => ({
|
|
17
19
|
selectedCell,
|
|
18
20
|
selectedColumn,
|
|
19
21
|
selectedRow,
|
|
20
22
|
selectedChip,
|
|
21
23
|
onCellClick,
|
|
22
24
|
onChipClick,
|
|
23
|
-
containerHeight,
|
|
24
|
-
rowHeight,
|
|
25
25
|
}));
|
|
26
|
+
const createItemData = (coreData, interactionData, scrollToIndex, isLoading) => (Object.assign(Object.assign(Object.assign({}, coreData), interactionData), { scrollToIndex,
|
|
27
|
+
isLoading }));
|
|
26
28
|
export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick, }) => {
|
|
27
29
|
const getItemSize = useCallback((index, height) => {
|
|
28
30
|
const isLastRow = areAllRowsLoaded && index === rows.length;
|
|
@@ -34,21 +36,15 @@ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, is
|
|
|
34
36
|
}
|
|
35
37
|
return rowHeight;
|
|
36
38
|
}, [areAllRowsLoaded, rows.length, rowHeight]);
|
|
37
|
-
const
|
|
39
|
+
const coreItemData = useMemo(() => {
|
|
38
40
|
var _a;
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
isError,
|
|
47
|
-
areAllRowsLoaded,
|
|
48
|
-
];
|
|
49
|
-
}, [isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded]);
|
|
50
|
-
const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick], [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
|
|
51
|
-
const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight), [commonItemDataParams, commonItemDataSuffix, rowHeight]);
|
|
41
|
+
return createCoreItemData(null, rows, rowProps, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, rows.length - 1, isError, areAllRowsLoaded, false, 0, rowHeight);
|
|
42
|
+
}, [rows, rowProps, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded, rowHeight]);
|
|
43
|
+
const interactionData = useMemo(() => createInteractionData(selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick), [selectedCell, selectedColumn, selectedRow, selectedChip, handleCellClick, handleChipClick]);
|
|
44
|
+
const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => {
|
|
45
|
+
const coreWithOverrides = Object.assign(Object.assign({}, coreItemData), { columns: columnsData, isPinned: isPinnedColumn, containerHeight: height });
|
|
46
|
+
return createItemData(coreWithOverrides, interactionData, scrollToIndex, isDelayedFetchingNextPage);
|
|
47
|
+
}, [coreItemData, interactionData, scrollToIndex, isDelayedFetchingNextPage]);
|
|
52
48
|
return {
|
|
53
49
|
getItemSize,
|
|
54
50
|
getItemDataForContainer,
|
|
@@ -6,23 +6,25 @@ import { areEqual } from 'react-window';
|
|
|
6
6
|
import { StyledCell, StyledTableRow } from './style';
|
|
7
7
|
import { getSelectionStyles, getRowSelectionBorderStyles } from '../../../utils/index.js';
|
|
8
8
|
function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, selectedRow = null, selectedChip = null, onCellClick, isLastRow = false, onChipClick, }) {
|
|
9
|
-
const renderCell = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const renderCell = useMemo(() => {
|
|
10
|
+
return (column, rowIndex, colIndex) => {
|
|
11
|
+
const { render, format, selector } = column;
|
|
12
|
+
const handleChipClick = (event, chipIndex) => {
|
|
13
|
+
onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(rowIndex, colIndex, event, chipIndex, column.pinned);
|
|
14
|
+
};
|
|
15
|
+
if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
|
|
16
|
+
return null;
|
|
17
|
+
const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
|
|
18
|
+
const formattedValue = format ? format({ value, row, index }) : value;
|
|
19
|
+
return render ? (render({
|
|
20
|
+
row,
|
|
21
|
+
column,
|
|
22
|
+
index,
|
|
23
|
+
value: row[column === null || column === void 0 ? void 0 : column.id],
|
|
24
|
+
selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
|
|
25
|
+
})) : (_jsx(_Fragment, { children: formattedValue }));
|
|
13
26
|
};
|
|
14
|
-
|
|
15
|
-
return null;
|
|
16
|
-
const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
|
|
17
|
-
const formattedValue = format ? format({ value, row, index }) : value;
|
|
18
|
-
return render ? (render({
|
|
19
|
-
row,
|
|
20
|
-
column,
|
|
21
|
-
index,
|
|
22
|
-
value: row[column === null || column === void 0 ? void 0 : column.id],
|
|
23
|
-
selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
|
|
24
|
-
})) : (_jsx(_Fragment, { children: formattedValue }));
|
|
25
|
-
};
|
|
27
|
+
}, [row, index, selectedChip, onChipClick]);
|
|
26
28
|
const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
|
|
27
29
|
var _a, _b;
|
|
28
30
|
const cellKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${index}-${colIndex}`;
|
|
@@ -48,7 +50,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
|
|
|
48
50
|
}
|
|
49
51
|
const rowSelectionBorderStyles = isRowSelected
|
|
50
52
|
? getRowSelectionBorderStyles({
|
|
51
|
-
|
|
53
|
+
isFirstColumn,
|
|
52
54
|
isPinnedStart: column.pinned === 'start',
|
|
53
55
|
isPinnedEnd: column.pinned === 'end',
|
|
54
56
|
})
|
|
@@ -57,7 +59,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
|
|
|
57
59
|
return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "TableRow_TableCell", "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: effectiveFirst, isLast: effectiveLast, onClick: (event) => {
|
|
58
60
|
onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned);
|
|
59
61
|
}, sx: Object.assign(Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: isIndexColumn ? 'center' : column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), rowSelectionBorderStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: isSheetView ? (_jsx(Box, Object.assign({ sx: { position: 'relative', zIndex: 1 } }, { children: renderCell(column, index, colIndex) }))) : (_jsx(_Fragment, { children: renderCell(column, index, colIndex) })) }), `${column.id}-${colIndex}`));
|
|
60
|
-
}) })), [columns,
|
|
62
|
+
}) })), [columns, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, isSheetView, renderCell]);
|
|
61
63
|
return (_createElement(StyledTableRow, Object.assign({ "data-testid": "TableRow", onClick: rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick, showShadowHighlight: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showShadowHighlight, showLoadedStyle: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showLoadedStyle, component: "article" }, rowProps, { key: index, isSheetView: isSheetView }), content));
|
|
62
64
|
}
|
|
63
65
|
export default memo(TableRow, areEqual);
|
|
@@ -66,9 +66,9 @@ function ListItemWrapper(_a) {
|
|
|
66
66
|
width: '100%',
|
|
67
67
|
} }, { children: isError ? _jsx(RowErrorState, {}) : lastRowContent })));
|
|
68
68
|
}, [isError]);
|
|
69
|
+
const isLastRow = React.useMemo(() => isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1), [isLoadingRow, areAllRowsLoaded, index, lastItemIndex]);
|
|
69
70
|
const memoizedListItemComponent = React.useMemo(() => {
|
|
70
71
|
const lastRowContent = _jsx(LastRowContent, { isSheetView: isSheetView, isLoadingRow: isLoadingRow, columns: columns, currentRowCount: rows.length });
|
|
71
|
-
const isLastRow = isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1);
|
|
72
72
|
if (isPinned && isLastRow) {
|
|
73
73
|
if (isSheetView && isLoadingRow && columns && columns.length > 0) {
|
|
74
74
|
return renderSheetViewLoadingRow(lastRowContent);
|
|
@@ -109,5 +109,3 @@ export { default as AmountStatusChip, type AmountStatusChipProps } from './Amoun
|
|
|
109
109
|
export { default as AuthenticationTypeChip, type AuthenticationTypeChipProps } from './AuthenticationTypeChip';
|
|
110
110
|
export * from './LazyImage';
|
|
111
111
|
export { default as SearchListInput } from './SearchListInput';
|
|
112
|
-
export { default as ErrorToast } from './ErrorToast';
|
|
113
|
-
export { default as ToggleView, type ToggleViewsValues, ToggleViews } from './ToggleView';
|
|
@@ -109,5 +109,3 @@ export { default as AmountStatusChip } from './AmountStatusChip';
|
|
|
109
109
|
export { default as AuthenticationTypeChip } from './AuthenticationTypeChip';
|
|
110
110
|
export * from './LazyImage';
|
|
111
111
|
export { default as SearchListInput } from './SearchListInput';
|
|
112
|
-
export { default as ErrorToast } from './ErrorToast';
|
|
113
|
-
export { default as ToggleView, ToggleViews } from './ToggleView';
|
|
@@ -3,6 +3,6 @@ export declare const TABLE_CONTENT_ROW_HEIGHT = 70;
|
|
|
3
3
|
export declare const TABLE_ROW_HEIGHT = 57;
|
|
4
4
|
export declare const TABLE_THRESHOLD = 200;
|
|
5
5
|
export declare const TABLE_LIST_OVER_SCAN = 5;
|
|
6
|
-
export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN =
|
|
6
|
+
export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
|
|
7
7
|
export declare const SHEET_VIEW_TABLE_THRESHOLD = 20;
|
|
8
8
|
export declare const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
|
package/build/constants/table.js
CHANGED
|
@@ -3,6 +3,6 @@ export const TABLE_CONTENT_ROW_HEIGHT = 70;
|
|
|
3
3
|
export const TABLE_ROW_HEIGHT = 57;
|
|
4
4
|
export const TABLE_THRESHOLD = 200;
|
|
5
5
|
export const TABLE_LIST_OVER_SCAN = 5;
|
|
6
|
-
export const SHEET_VIEW_TABLE_LIST_OVER_SCAN =
|
|
6
|
+
export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
|
|
7
7
|
export const SHEET_VIEW_TABLE_THRESHOLD = 20;
|
|
8
8
|
export const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
|
package/build/utils/country.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getCountryNameByISO(countryCode: string): string | undefined;
|
package/build/utils/country.js
CHANGED
package/build/utils/style.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ interface GetSelectionStylesParams {
|
|
|
14
14
|
type SelectionStyles = Record<string, string | Record<string, string>>;
|
|
15
15
|
export declare const getSelectionStyles: ({ isSelected, isCellSelected, isColumnSelected, isRowSelected, isLastRow, }: GetSelectionStylesParams) => SelectionStyles;
|
|
16
16
|
interface GetRowSelectionBorderStylesParams {
|
|
17
|
-
|
|
17
|
+
isFirstColumn: boolean;
|
|
18
18
|
isPinnedStart: boolean;
|
|
19
19
|
isPinnedEnd: boolean;
|
|
20
20
|
}
|
|
21
|
-
export declare const getRowSelectionBorderStyles: ({
|
|
21
|
+
export declare const getRowSelectionBorderStyles: ({ isFirstColumn, isPinnedStart, isPinnedEnd }: GetRowSelectionBorderStylesParams) => SelectionStyles;
|
|
22
22
|
export {};
|
package/build/utils/style.js
CHANGED
|
@@ -59,9 +59,9 @@ const getBorderWidthForColumn = () => {
|
|
|
59
59
|
const getBorderBottomForColumn = (isLastRow) => {
|
|
60
60
|
return isLastRow ? `${BORDER_STYLES.thick} solid ${SELECTION_COLORS.primary}` : `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.border}`;
|
|
61
61
|
};
|
|
62
|
-
export const getRowSelectionBorderStyles = ({
|
|
62
|
+
export const getRowSelectionBorderStyles = ({ isFirstColumn, isPinnedStart, isPinnedEnd }) => ({
|
|
63
63
|
borderTop: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
|
|
64
64
|
borderBottom: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
|
|
65
65
|
borderRight: `${BORDER_STYLES.thin} solid ${isPinnedEnd ? SELECTION_COLORS.primary : 'none'}`,
|
|
66
|
-
borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart &&
|
|
66
|
+
borderLeft: `${BORDER_STYLES.thin} solid ${isPinnedStart && isFirstColumn ? SELECTION_COLORS.primary : 'transparent'}`,
|
|
67
67
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.130-test.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.130-test.5-test.6",
|
|
5
|
+
"testVersion": 6,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { reloadIcon } from '../../constants/index.js';
|
|
3
|
-
import { ToastContainer, ToastIcon, ToastText } from './style';
|
|
4
|
-
function ErrorToast({ message = 'Something went wrong', onRetry, position = 'bottom-center', iconSrc }) {
|
|
5
|
-
return (_jsxs(ToastContainer, Object.assign({ toastPosition: position }, { children: [_jsx(ToastText, { children: message }), _jsx(ToastIcon, { onClick: onRetry, src: iconSrc || reloadIcon, alt: "toast-icon" })] })));
|
|
6
|
-
}
|
|
7
|
-
export default ErrorToast;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ToastContainerProps } from './type';
|
|
3
|
-
export declare const ToastContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & ToastContainerProps, {}, {}>;
|
|
6
|
-
export declare const ToastIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
7
|
-
export declare const ToastText: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
8
|
-
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
9
|
-
}, "width" | "minHeight" | "height" | "bottom" | "left" | "right" | "top" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "justifyContent" | "justifyItems" | "justifySelf" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "visibility" | "whiteSpace" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "style" | "className" | "classes" | "children" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "sx" | "variant" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Box, styled, Typography } from '@mui/material';
|
|
2
|
-
export const ToastContainer = styled(Box, {
|
|
3
|
-
shouldForwardProp: (prop) => prop !== 'toastPosition'
|
|
4
|
-
})(({ theme, toastPosition }) => (Object.assign(Object.assign(Object.assign(Object.assign({ width: 160, position: 'absolute', bottom: 12, zIndex: 1000, display: 'flex', justifyContent: 'space-between', alignItems: 'center', backgroundColor: theme.palette.background.paper, height: 31, gap: theme.spacing(1), borderRadius: theme.shape.borderRadius, borderWidth: 1, padding: theme.spacing(1), border: `1px solid ${theme.palette.divider}`, boxShadow: '0px 0px 16px 0px #00000014', animation: 'slideIn 0.5s ease-out' }, (toastPosition === 'bottom-center' && {
|
|
5
|
-
left: '50%',
|
|
6
|
-
transform: 'translateX(-50%)'
|
|
7
|
-
})), (toastPosition === 'bottom-right' && {
|
|
8
|
-
right: 12,
|
|
9
|
-
transform: 'none'
|
|
10
|
-
})), (toastPosition === 'bottom-left' && {
|
|
11
|
-
left: 12,
|
|
12
|
-
transform: 'none'
|
|
13
|
-
})), { '@keyframes slideIn': {
|
|
14
|
-
'0%': {
|
|
15
|
-
opacity: 0,
|
|
16
|
-
transform: toastPosition === 'bottom-center'
|
|
17
|
-
? 'translate(-50%, 100%)'
|
|
18
|
-
: toastPosition === 'bottom-right'
|
|
19
|
-
? 'translateX(100%)'
|
|
20
|
-
: 'translateX(-100%)'
|
|
21
|
-
},
|
|
22
|
-
'100%': {
|
|
23
|
-
opacity: 1,
|
|
24
|
-
transform: toastPosition === 'bottom-center' ? 'translate(-50%, 0)' : 'translateX(0)'
|
|
25
|
-
}
|
|
26
|
-
} })));
|
|
27
|
-
export const ToastIcon = styled('img')({
|
|
28
|
-
cursor: 'pointer'
|
|
29
|
-
});
|
|
30
|
-
export const ToastText = styled(Typography)(({ theme }) => ({
|
|
31
|
-
fontSize: 11,
|
|
32
|
-
fontWeight: 500,
|
|
33
|
-
color: theme.palette.text.primary,
|
|
34
|
-
overflow: 'hidden',
|
|
35
|
-
textOverflow: 'ellipsis',
|
|
36
|
-
whiteSpace: 'nowrap'
|
|
37
|
-
}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type ToastPosition = 'bottom-center' | 'bottom-right' | 'bottom-left';
|
|
2
|
-
export interface ErrorToastProps {
|
|
3
|
-
message?: string;
|
|
4
|
-
onRetry?: () => void;
|
|
5
|
-
position?: ToastPosition;
|
|
6
|
-
iconSrc?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ToastContainerProps {
|
|
9
|
-
toastPosition: ToastPosition;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ToggleViews, ToggleViewsValues } from './types';
|
|
3
|
-
declare const DEFAULT_TOGGLE_VIEWS: {
|
|
4
|
-
icon: import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
value: ToggleViews;
|
|
6
|
-
}[];
|
|
7
|
-
export interface ToggleViewProps {
|
|
8
|
-
onToggleClick: (view: ToggleViewsValues) => void;
|
|
9
|
-
currentView: ToggleViewsValues;
|
|
10
|
-
getOverrideViews?: (defaultViews: typeof DEFAULT_TOGGLE_VIEWS) => {
|
|
11
|
-
icon: React.ReactNode;
|
|
12
|
-
value: ToggleViewsValues;
|
|
13
|
-
}[];
|
|
14
|
-
}
|
|
15
|
-
declare const ToggleView: (props: ToggleViewProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
-
export default ToggleView;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cardViewButtonIcon, listViewButtonIcon } from '../../constants/index.js';
|
|
3
|
-
import { ActiveOverlay, ViewButton } from './style';
|
|
4
|
-
import { ToggleViews } from './types';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import ToggleWrapper from './ToggleWrapper';
|
|
7
|
-
const DEFAULT_TOGGLE_VIEWS = [
|
|
8
|
-
{
|
|
9
|
-
icon: _jsx("img", { src: cardViewButtonIcon, alt: "card" }),
|
|
10
|
-
value: ToggleViews.CARDS,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
icon: _jsx("img", { src: listViewButtonIcon, alt: ToggleViews.LIST }),
|
|
14
|
-
value: ToggleViews.LIST,
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
const ToggleView = (props) => {
|
|
18
|
-
const { currentView, onToggleClick, getOverrideViews } = props;
|
|
19
|
-
const views = useMemo(() => {
|
|
20
|
-
if (getOverrideViews)
|
|
21
|
-
return getOverrideViews(DEFAULT_TOGGLE_VIEWS);
|
|
22
|
-
return DEFAULT_TOGGLE_VIEWS;
|
|
23
|
-
}, [getOverrideViews]);
|
|
24
|
-
const viewIndex = useMemo(() => views.findIndex((view) => view.value === currentView), [views, currentView]);
|
|
25
|
-
if (!onToggleClick)
|
|
26
|
-
return null;
|
|
27
|
-
return (_jsxs(ToggleWrapper, { children: [views.map((view) => (_jsx(ViewButton, Object.assign({ onClick: () => onToggleClick(view.value), sx: {
|
|
28
|
-
height: '11.6px',
|
|
29
|
-
width: '11.6px',
|
|
30
|
-
}, isActive: currentView === view.value }, { children: view.icon }), view.value))), _jsx(ActiveOverlay, { activeIndex: viewIndex })] }));
|
|
31
|
-
};
|
|
32
|
-
export default ToggleView;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ToggleWrapperStyled } from './style';
|
|
4
|
-
const ToggleWrapper = (props) => {
|
|
5
|
-
const viewTogglers = React.Children.count(props.children) - 1;
|
|
6
|
-
return _jsx(ToggleWrapperStyled, Object.assign({}, props, { sx: { width: viewTogglers * 30 + 2 } }));
|
|
7
|
-
};
|
|
8
|
-
export default ToggleWrapper;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const ToggleWrapperStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
5
|
-
export declare const ViewButton: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
7
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
8
|
-
isActive: boolean;
|
|
9
|
-
}, {}, {}>;
|
|
10
|
-
export declare const ActiveOverlay: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
11
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
12
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
13
|
-
activeIndex: number;
|
|
14
|
-
}, {}, {}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Box, styled } from '@mui/material';
|
|
2
|
-
export const ToggleWrapperStyled = styled(Box)(({ theme }) => ({
|
|
3
|
-
height: '32px',
|
|
4
|
-
borderRadius: '4px',
|
|
5
|
-
backgroundColor: theme.palette.action.hover,
|
|
6
|
-
padding: '2px',
|
|
7
|
-
display: 'flex',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
position: 'relative',
|
|
10
|
-
cursor: 'pointer'
|
|
11
|
-
}));
|
|
12
|
-
export const ViewButton = styled(Box, { shouldForwardProp: (props) => props !== 'isActive' })(({ isActive }) => ({
|
|
13
|
-
flex: 1,
|
|
14
|
-
display: 'flex',
|
|
15
|
-
justifyContent: 'center',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
position: 'relative',
|
|
18
|
-
zIndex: 2,
|
|
19
|
-
opacity: isActive ? 1 : 0.5
|
|
20
|
-
}));
|
|
21
|
-
export const ActiveOverlay = styled(Box, { shouldForwardProp: (props) => props !== 'activeIndex' })(({ theme, activeIndex }) => ({
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
top: 2,
|
|
24
|
-
left: activeIndex * 30 + 2,
|
|
25
|
-
transition: 'all 0.25s ease-in-out',
|
|
26
|
-
width: '28px',
|
|
27
|
-
height: '28px',
|
|
28
|
-
backgroundColor: theme.palette.common.white,
|
|
29
|
-
borderRadius: '2px',
|
|
30
|
-
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.20)'
|
|
31
|
-
}));
|