@tap-payments/os-micro-frontend-shared 0.1.133-test.10 → 0.1.133-test.3

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.
Files changed (61) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +72 -34
  4. package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.d.ts +1 -1
  5. package/build/components/VirtualTables/SheetViewVirtualTable/components/LoadingMainTable.js +2 -1
  6. package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.d.ts +1 -1
  7. package/build/components/VirtualTables/SheetViewVirtualTable/components/MainTable.js +2 -1
  8. package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataView.d.ts +1 -1
  9. package/build/components/VirtualTables/SheetViewVirtualTable/components/NoDataView.js +2 -1
  10. package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.d.ts +1 -1
  11. package/build/components/VirtualTables/SheetViewVirtualTable/components/PinnedColumn.js +2 -1
  12. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader.js +90 -7
  13. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.d.ts +4 -1
  14. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +67 -22
  15. package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +15 -12
  16. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.d.ts +1 -0
  17. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.js +1 -0
  18. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts +25 -0
  19. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +69 -0
  20. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedColumns.js +73 -35
  21. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +1 -0
  22. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +1 -23
  23. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +32 -28
  24. package/build/components/VirtualTables/SheetViewVirtualTable/types.d.ts +14 -7
  25. package/build/components/VirtualTables/components/ColumnFilter/ColumnFilter.js +45 -14
  26. package/build/components/VirtualTables/components/TableRow.js +20 -18
  27. package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +1 -1
  28. package/build/components/index.d.ts +0 -2
  29. package/build/components/index.js +0 -2
  30. package/build/constants/table/cell/authorizationTableCellWidth.d.ts +4 -4
  31. package/build/constants/table/cell/authorizationTableCellWidth.js +4 -4
  32. package/build/constants/table/cell/chargeTableCellWidth.d.ts +5 -5
  33. package/build/constants/table/cell/chargeTableCellWidth.js +5 -5
  34. package/build/constants/table/cell/destinationsTableCellWidth.d.ts +1 -1
  35. package/build/constants/table/cell/destinationsTableCellWidth.js +1 -1
  36. package/build/constants/table/cell/terminalsTableCellWidth.d.ts +3 -3
  37. package/build/constants/table/cell/terminalsTableCellWidth.js +3 -3
  38. package/build/constants/table.d.ts +1 -1
  39. package/build/constants/table.js +1 -1
  40. package/build/types/entity.d.ts +0 -5
  41. package/build/utils/style.d.ts +2 -2
  42. package/build/utils/style.js +2 -2
  43. package/package.json +2 -2
  44. package/build/components/ErrorToast/ErrorToast.d.ts +0 -3
  45. package/build/components/ErrorToast/ErrorToast.js +0 -7
  46. package/build/components/ErrorToast/index.d.ts +0 -2
  47. package/build/components/ErrorToast/index.js +0 -2
  48. package/build/components/ErrorToast/style.d.ts +0 -9
  49. package/build/components/ErrorToast/style.js +0 -33
  50. package/build/components/ErrorToast/type.d.ts +0 -10
  51. package/build/components/ErrorToast/type.js +0 -1
  52. package/build/components/ToggleView/ToggleView.d.ts +0 -16
  53. package/build/components/ToggleView/ToggleView.js +0 -32
  54. package/build/components/ToggleView/ToggleWrapper.d.ts +0 -4
  55. package/build/components/ToggleView/ToggleWrapper.js +0 -8
  56. package/build/components/ToggleView/index.d.ts +0 -3
  57. package/build/components/ToggleView/index.js +0 -3
  58. package/build/components/ToggleView/style.d.ts +0 -14
  59. package/build/components/ToggleView/style.js +0 -31
  60. package/build/components/ToggleView/types.d.ts +0 -6
  61. 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
+ ```
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { memo, useCallback } from 'react';
2
+ import { memo, useCallback, useMemo } from 'react';
3
3
  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, columnMetrics, createStableCallback } = 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(columns, isPinnable, onColumnPin);
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({
@@ -37,41 +38,43 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
37
38
  const onPointerDown = (e) => {
38
39
  dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
39
40
  };
40
- const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
41
- const listRef = containerKey === 'pinnedStart' ? pinnedStartVirtualListRef : containerKey === 'pinnedEnd' ? pinnedEndVirtualListRef : scrollableVirtualListRef;
42
- const handleScrollCallback = (scrollProps) => {
43
- const source = containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable';
44
- handleScroll(scrollProps, source);
45
- };
46
- return (_jsx(VirtualTable, { columnsData: columnsData, itemCount: itemsCount, lastItemIndex: lastItemIndex, areAllRowsLoaded: areAllRowsLoaded, loadMoreItems: loadMoreItems, threshold: threshold, getItemSize: getItemSize, getItemData: getItemDataForContainer, isPinned: isPinned, fixedWidth: fixedWidth, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, onScroll: handleScrollCallback, setBackdropVisibility: setShowBackdrop, listRef: listRef, overscanCount: overscanCount }));
47
- }, [
48
- itemsCount,
49
- lastItemIndex,
41
+ const stableOnColumnSort = useMemo(() => (onColumnSort ? createStableCallback('onColumnSort', onColumnSort) : undefined), [onColumnSort, createStableCallback]);
42
+ const stableOnColumnPin = useMemo(() => handleColumnPin
43
+ ? createStableCallback('handleColumnPin', handleColumnPin)
44
+ :
45
+ createStableCallback('noopColumnPin', () => { }), [handleColumnPin, createStableCallback]);
46
+ const stableOnColumnClick = useMemo(() => (handleColumnClick ? createStableCallback('handleColumnClick', handleColumnClick) : undefined), [handleColumnClick, createStableCallback]);
47
+ const baseCommonProps = useMemo(() => ({
48
+ showHeader,
49
+ columnsSorting,
50
+ onColumnSort: stableOnColumnSort,
51
+ headerProps,
52
+ showBackDrop,
53
+ onColumnPin: stableOnColumnPin,
54
+ isPinnable,
55
+ lastColumnId,
56
+ selectedColumn,
57
+ onColumnClick: stableOnColumnClick,
58
+ tableTitle,
50
59
  areAllRowsLoaded,
51
- loadMoreItems,
52
- threshold,
53
- getItemSize,
54
- getItemDataForContainer,
60
+ isFetchingNextPage,
55
61
  scrollToIndex,
56
- areTotalRowsNotFillingHeight,
57
- clearBackdropVisibilityTimeout,
58
- handleScroll,
59
- setShowBackdrop,
60
- pinnedStartVirtualListRef,
61
- pinnedEndVirtualListRef,
62
- scrollableVirtualListRef,
63
- ]);
64
- const baseCommonProps = {
62
+ isLoading,
63
+ isError,
64
+ tableMode,
65
+ showNoDataView,
66
+ tableBodyStyles,
67
+ }), [
65
68
  showHeader,
66
69
  columnsSorting,
67
- onColumnSort,
70
+ stableOnColumnSort,
68
71
  headerProps,
69
72
  showBackDrop,
70
- onColumnPin: handleColumnPin,
73
+ stableOnColumnPin,
71
74
  isPinnable,
72
- lastColumnId,
75
+ columnMetrics.lastColumnId,
73
76
  selectedColumn,
74
- onColumnClick: handleColumnClick,
77
+ stableOnColumnClick,
75
78
  tableTitle,
76
79
  areAllRowsLoaded,
77
80
  isFetchingNextPage,
@@ -81,9 +84,44 @@ function SheetViewVirtualTable({ columns, rows, threshold = SHEET_VIEW_TABLE_THR
81
84
  tableMode,
82
85
  showNoDataView,
83
86
  tableBodyStyles,
84
- };
85
- const commonPropsWithTableStates = Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
86
- tableLoading });
87
- return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(LoadingMainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns }, commonPropsWithTableStates)), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) : (_jsx(NoDataView, Object.assign({ tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumns, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }, baseCommonProps)))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates))), _jsx(MainTable, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, Object.assign({ position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer }, commonPropsWithTableStates)))] })) }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
87
+ ]);
88
+ const commonPropsWithTableStates = useMemo(() => (Object.assign(Object.assign({}, baseCommonProps), { hasTimeoutError,
89
+ tableLoading })), [baseCommonProps, hasTimeoutError, tableLoading]);
90
+ const virtualTableBaseProps = useMemo(() => ({
91
+ itemCount: itemsCount,
92
+ lastItemIndex,
93
+ areAllRowsLoaded,
94
+ loadMoreItems,
95
+ threshold,
96
+ getItemSize,
97
+ getItemData: getItemDataForContainer,
98
+ scrollToIndex,
99
+ areTotalRowsNotFillingHeight,
100
+ clearBackdropVisibilityTimeout,
101
+ setBackdropVisibility: setShowBackdrop,
102
+ overscanCount,
103
+ }), [
104
+ itemsCount,
105
+ lastItemIndex,
106
+ areAllRowsLoaded,
107
+ loadMoreItems,
108
+ threshold,
109
+ getItemSize,
110
+ getItemDataForContainer,
111
+ scrollToIndex,
112
+ areTotalRowsNotFillingHeight,
113
+ clearBackdropVisibilityTimeout,
114
+ setShowBackdrop,
115
+ overscanCount,
116
+ ]);
117
+ const createVirtualTableContainer = useCallback((columnsData, containerKey, isPinned = false, fixedWidth) => {
118
+ const listRef = containerKey === 'pinnedStart' ? pinnedStartVirtualListRef : containerKey === 'pinnedEnd' ? pinnedEndVirtualListRef : scrollableVirtualListRef;
119
+ const handleScrollCallback = (scrollProps) => {
120
+ const source = containerKey === 'pinnedStart' ? 'start' : containerKey === 'pinnedEnd' ? 'end' : 'scrollable';
121
+ handleScroll(scrollProps, source);
122
+ };
123
+ return (_jsx(VirtualTable, Object.assign({}, virtualTableBaseProps, { columnsData: columnsData, isPinned: isPinned, fixedWidth: fixedWidth, onScroll: handleScrollCallback, listRef: listRef })));
124
+ }, [virtualTableBaseProps, handleScroll, pinnedStartVirtualListRef, pinnedEndVirtualListRef, scrollableVirtualListRef]);
125
+ return (_jsxs(_Fragment, { children: [_jsx(SheetViewTableContainer, { children: showNoDataView ? (tableLoading ? (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates })), _jsx(LoadingMainTable, { hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, commonProps: commonPropsWithTableStates }), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }))] })) : (_jsx(NoDataView, { tableLoading: tableLoading, tableError: tableError, tableEmpty: tableEmpty, hasTimeoutError: hasTimeoutError, orderedColumns: orderedColumns, error: error, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps, commonProps: baseCommonProps }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [pinnedStartColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "start", columnsData: pinnedStartColumnsData, columnsWidth: pinnedStartColumnsWidth, pinnedColumnsList: pinnedStartColumns, hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates })), _jsx(MainTable, { hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, unpinnedColumnsData: unpinnedColumnsData, pinnedStartColumns: pinnedStartColumns, pinnedEndColumns: pinnedEndColumns, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }), pinnedEndColumnsData.length > 0 && (_jsx(PinnedColumn, { position: "end", columnsData: pinnedEndColumnsData, columnsWidth: pinnedEndColumnsWidth, pinnedColumnsList: [...pinnedStartColumns, ...pinnedEndColumns], hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0, createVirtualTableContainer: createVirtualTableContainer, commonProps: commonPropsWithTableStates }))] })) }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
88
126
  }
89
127
  export default memo(SheetViewVirtualTable);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { LoadingMainTableProps } from '../types';
3
- declare 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, }: LoadingMainTableProps): import("react/jsx-runtime").JSX.Element;
3
+ declare function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, commonProps, }: LoadingMainTableProps): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof LoadingMainTable>;
5
5
  export default _default;
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
5
5
  import { MainTableWrapper, UnpinnedTableHeaderWrapper } from '../style';
6
6
  import SheetViewTableHeader from './SheetViewTableHeader';
7
7
  import SheetViewTableLoading from './SheetViewTableLoading';
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, }) {
8
+ function LoadingMainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, commonProps, }) {
9
9
  const theme = useTheme();
10
+ const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, } = commonProps;
10
11
  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: {
11
12
  width: '100%',
12
13
  minWidth: 'fit-content',
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { MainTableProps } from '../types';
3
- declare 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, }: MainTableProps): import("react/jsx-runtime").JSX.Element;
3
+ declare function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, createVirtualTableContainer, commonProps, }: MainTableProps): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof MainTable>;
5
5
  export default _default;
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
5
5
  import { MainTableWrapper, UnpinnedTableHeaderWrapper } from '../style';
6
6
  import SheetViewTableHeader from './SheetViewTableHeader';
7
7
  import SheetViewTableLoading from './SheetViewTableLoading';
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, }) {
8
+ function MainTable({ hasPinnedStart, hasPinnedEnd, unpinnedColumnsData, pinnedStartColumns, pinnedEndColumns, createVirtualTableContainer, commonProps, }) {
9
9
  const theme = useTheme();
10
+ const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableBodyStyles, tableLoading, } = commonProps;
10
11
  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: {
11
12
  width: '100%',
12
13
  minWidth: 'fit-content',
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { NoDataViewProps } from '../types';
3
- declare 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, }: NoDataViewProps): import("react/jsx-runtime").JSX.Element;
3
+ declare function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns, error, triggerDataRefetch, footerProps, commonProps, }: NoDataViewProps): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof NoDataView>;
5
5
  export default _default;
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper } from '../../components/style';
5
5
  import { UnpinnedTableHeaderWrapper } from '../style';
6
6
  import TableNoData from '../../components/TableNoData';
7
7
  import SheetViewTableHeader from './SheetViewTableHeader';
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, }) {
8
+ function NoDataView({ tableLoading, tableError, tableEmpty, hasTimeoutError, orderedColumns, error, triggerDataRefetch, footerProps, commonProps, }) {
9
9
  const theme = useTheme();
10
+ const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, tableMode, tableBodyStyles, } = commonProps;
10
11
  const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
11
12
  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 })] })) })));
12
13
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { PinnedColumnProps } from '../types';
3
- declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, }: PinnedColumnProps): import("react/jsx-runtime").JSX.Element | null;
3
+ declare function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, hasPinnedStart, hasPinnedEnd, createVirtualTableContainer, commonProps, }: PinnedColumnProps): import("react/jsx-runtime").JSX.Element | null;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof PinnedColumn>;
5
5
  export default _default;
@@ -5,8 +5,9 @@ import { StyledTableBox, TableWrapper, StyledBox } from '../../components/style'
5
5
  import { PinnedStartColumnWrapper, PinnedEndColumnWrapper } from '../style';
6
6
  import SheetViewTableHeader from './SheetViewTableHeader';
7
7
  import SheetViewTableLoading from './SheetViewTableLoading';
8
- function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, hasPinnedStart, hasPinnedEnd, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, createVirtualTableContainer, }) {
8
+ function PinnedColumn({ position, columnsData, columnsWidth, pinnedColumnsList, hasPinnedStart, hasPinnedEnd, createVirtualTableContainer, commonProps, }) {
9
9
  const theme = useTheme();
10
+ const { showHeader, columnsSorting, onColumnSort, headerProps, showBackDrop, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, tableTitle, areAllRowsLoaded, isFetchingNextPage, scrollToIndex, isLoading, isError, hasTimeoutError, tableMode, showNoDataView, tableLoading, } = commonProps;
10
11
  if (columnsData.length === 0)
11
12
  return null;
12
13
  const Wrapper = position === 'start' ? PinnedStartColumnWrapper : PinnedEndColumnWrapper;
@@ -1,12 +1,95 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { memo } from 'react';
13
+ import { memo, useCallback, useMemo, useState } from 'react';
3
14
  import { StyledHeader, StyledMUITableRow } from '../style';
4
15
  import SheetViewTableHeaderCell from './SheetViewTableHeaderCell';
5
16
  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
- var _a;
8
- const columnKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${colIndex}`;
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
- }) })) })));
17
+ const [openFilterColumn, setOpenFilterColumn] = useState(null);
18
+ const [filterElements, setFilterElements] = useState({});
19
+ const handleFilterOpen = useCallback((columnId, element) => {
20
+ setOpenFilterColumn(columnId);
21
+ setFilterElements((prev) => (Object.assign(Object.assign({}, prev), { [columnId]: element })));
22
+ }, []);
23
+ const handleFilterClose = useCallback((columnId) => {
24
+ setOpenFilterColumn(null);
25
+ setFilterElements((prev) => {
26
+ const _a = prev, _b = columnId, removed = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
27
+ return rest;
28
+ });
29
+ }, []);
30
+ const columnElements = useMemo(() => {
31
+ return columns.map((column, colIndex) => {
32
+ var _a;
33
+ const columnKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${colIndex}`;
34
+ const columnId = column.id;
35
+ const isFilterOpen = openFilterColumn === columnId;
36
+ const filterElement = isFilterOpen ? filterElements[columnId] : null;
37
+ 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, columnFilterEl: filterElement, onFilterOpen: handleFilterOpen, onFilterClose: handleFilterClose }, `${columnId}-${colIndex}`));
38
+ });
39
+ }, [
40
+ columns,
41
+ selectedColumn,
42
+ onColumnSort,
43
+ columnsSorting,
44
+ pinnedColumns,
45
+ onColumnPin,
46
+ isPinnable,
47
+ lastColumnId,
48
+ onColumnClick,
49
+ openFilterColumn,
50
+ filterElements,
51
+ handleFilterOpen,
52
+ handleFilterClose,
53
+ ]);
54
+ 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: columnElements })) })));
11
55
  }
12
- export default memo(SheetViewTableHeader);
56
+ function areHeaderEqual(prevProps, nextProps) {
57
+ if (prevProps.showBackDrop !== nextProps.showBackDrop ||
58
+ prevProps.isPinnable !== nextProps.isPinnable ||
59
+ prevProps.lastColumnId !== nextProps.lastColumnId ||
60
+ prevProps.selectedColumn !== nextProps.selectedColumn ||
61
+ prevProps.onColumnSort !== nextProps.onColumnSort ||
62
+ prevProps.onColumnPin !== nextProps.onColumnPin ||
63
+ prevProps.onColumnClick !== nextProps.onColumnClick) {
64
+ return false;
65
+ }
66
+ if (prevProps.columns.length !== nextProps.columns.length) {
67
+ return false;
68
+ }
69
+ for (let i = 0; i < prevProps.columns.length; i++) {
70
+ const prevCol = prevProps.columns[i];
71
+ const nextCol = nextProps.columns[i];
72
+ if (prevCol.id !== nextCol.id ||
73
+ prevCol.header !== nextCol.header ||
74
+ prevCol.width !== nextCol.width ||
75
+ prevCol.pinned !== nextCol.pinned ||
76
+ prevCol.sortable !== nextCol.sortable ||
77
+ prevCol.pinnable !== nextCol.pinnable ||
78
+ prevCol.hidden !== nextCol.hidden ||
79
+ prevCol.order !== nextCol.order ||
80
+ prevCol.isDefaultPinned !== nextCol.isDefaultPinned) {
81
+ return false;
82
+ }
83
+ if (prevCol.filter !== nextCol.filter) {
84
+ if (!prevCol.filter || !nextCol.filter)
85
+ return false;
86
+ if (prevCol.filter.type !== nextCol.filter.type || JSON.stringify(prevCol.filter.data) !== JSON.stringify(nextCol.filter.data)) {
87
+ return false;
88
+ }
89
+ }
90
+ }
91
+ return (JSON.stringify(prevProps.pinnedColumns) === JSON.stringify(nextProps.pinnedColumns) &&
92
+ JSON.stringify(prevProps.columnsSorting) === JSON.stringify(nextProps.columnsSorting) &&
93
+ JSON.stringify(prevProps.headerProps) === JSON.stringify(nextProps.headerProps));
94
+ }
95
+ export default memo(SheetViewTableHeader, areHeaderEqual);
@@ -8,7 +8,10 @@ interface SheetViewTableHeaderCellProps extends Pick<SheetViewTableHeaderProps,
8
8
  isLast: boolean;
9
9
  isSelected: boolean;
10
10
  isDefaultPinned: boolean;
11
+ columnFilterEl?: HTMLElement | null;
12
+ onFilterOpen?: (columnId: string, element: HTMLElement) => void;
13
+ onFilterClose?: (columnId: string) => void;
11
14
  }
12
- declare function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }: SheetViewTableHeaderCellProps): import("react/jsx-runtime").JSX.Element;
15
+ declare function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, columnFilterEl, onFilterOpen, onFilterClose, }: SheetViewTableHeaderCellProps): import("react/jsx-runtime").JSX.Element;
13
16
  declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeaderCell>;
14
17
  export default _default;
@@ -1,18 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo, useCallback, useMemo, useRef, useState } from 'react';
2
+ import { memo, useCallback, useMemo, useRef } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import { pinIcon, unpinIcon } from '../../../../constants/index.js';
5
5
  import ColumnFilter from '../../components/ColumnFilter';
6
6
  import { StyledCell, TableHeaderInner } from '../../components/style';
7
7
  import { PinIconContainer, HeaderText } from '../style';
8
8
  import ColumnSort from '../../components/ColumnSort';
9
- function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }) {
10
- const [columnFilterEl, setColumnFilterEl] = useState(null);
9
+ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, columnFilterEl, onFilterOpen, onFilterClose, }) {
11
10
  const cellRef = useRef(null);
12
- const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
13
- const isPinned = useMemo(() => checkIsPanned(id), [id, checkIsPanned]);
14
- const handlePinClick = (columnId) => {
15
- if (checkIsPanned(columnId)) {
11
+ const isPinned = useMemo(() => {
12
+ var _a;
13
+ return (_a = pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(id)) !== null && _a !== void 0 ? _a : false;
14
+ }, [pinnedColumns, id]);
15
+ const handlePinClick = useCallback((columnId) => {
16
+ if (pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId)) {
16
17
  onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'unpin');
17
18
  }
18
19
  else {
@@ -23,19 +24,34 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
23
24
  onColumnPin === null || onColumnPin === void 0 ? void 0 : onColumnPin(columnId, 'start');
24
25
  }
25
26
  }
26
- };
27
- const onOpenFilterDropdown = () => {
28
- setColumnFilterEl(cellRef.current);
29
- };
30
- const handleCellClick = (event) => {
27
+ }, [pinnedColumns, onColumnPin, lastColumnId]);
28
+ const onOpenFilterDropdown = useCallback(() => {
29
+ if (cellRef.current) {
30
+ onFilterOpen === null || onFilterOpen === void 0 ? void 0 : onFilterOpen(id, cellRef.current);
31
+ }
32
+ }, [onFilterOpen, id]);
33
+ const handleCellClick = useCallback((event) => {
31
34
  if (event.target === event.currentTarget) {
32
35
  onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, event, pinned);
33
36
  }
34
- };
35
- const handleHeaderInnerClick = (event) => {
37
+ }, [onColumnClick, colIndex, pinned]);
38
+ const handleHeaderInnerClick = useCallback((event) => {
36
39
  event.stopPropagation();
37
40
  onOpenFilterDropdown();
38
- };
41
+ }, [onOpenFilterDropdown]);
42
+ const handlePinClickMemoized = useCallback((event) => {
43
+ event.stopPropagation();
44
+ handlePinClick(id);
45
+ }, [handlePinClick, id]);
46
+ const stableFilterProps = useMemo(() => {
47
+ if (!filter)
48
+ return null;
49
+ return Object.assign(Object.assign({}, filter), { anchorEl: columnFilterEl || null, setAnchorEl: (element) => {
50
+ if (element === null) {
51
+ onFilterClose === null || onFilterClose === void 0 ? void 0 : onFilterClose(id);
52
+ }
53
+ } });
54
+ }, [filter, columnFilterEl, onFilterClose, id]);
39
55
  return (_jsx(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, ref: cellRef, onClick: handleCellClick, 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: '0.5px solid transparent', borderColor: isSelected ? '#1F88D0' : '#F2F2F2', borderBottom: isSelected ? '0.5px solid transparent' : '0.5px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', minHeight: '28px', position: 'relative', '&:before': {
40
56
  content: '""',
41
57
  borderBottom: 'none',
@@ -44,11 +60,40 @@ function SheetViewTableHeaderCell({ column: { header, id, align, headerStyle, so
44
60
  right: 0,
45
61
  left: 0,
46
62
  bottom: 0,
47
- } }, headerStyle)) }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { 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 })), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
48
- onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
49
- } })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
50
- event.stopPropagation();
51
- handlePinClick(id);
52
- }, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })) })));
63
+ } }, headerStyle)) }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: handleHeaderInnerClick }, { 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 && stableFilterProps && _jsx(ColumnFilter, Object.assign({}, stableFilterProps)), sortable && _jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: handleCellClick }), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: handlePinClickMemoized, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })) })));
64
+ }
65
+ function areEqual(prevProps, nextProps) {
66
+ if (prevProps.column.id !== nextProps.column.id ||
67
+ prevProps.column.header !== nextProps.column.header ||
68
+ prevProps.column.width !== nextProps.column.width ||
69
+ prevProps.column.pinned !== nextProps.column.pinned ||
70
+ prevProps.column.sortable !== nextProps.column.sortable ||
71
+ prevProps.column.pinnable !== nextProps.column.pinnable ||
72
+ prevProps.column.hidden !== nextProps.column.hidden ||
73
+ prevProps.column.order !== nextProps.column.order) {
74
+ return false;
75
+ }
76
+ if (prevProps.column.filter !== nextProps.column.filter) {
77
+ if (!prevProps.column.filter || !nextProps.column.filter)
78
+ return false;
79
+ if (JSON.stringify(prevProps.column.filter) !== JSON.stringify(nextProps.column.filter)) {
80
+ return false;
81
+ }
82
+ }
83
+ return (prevProps.colIndex === nextProps.colIndex &&
84
+ prevProps.isFirst === nextProps.isFirst &&
85
+ prevProps.isLast === nextProps.isLast &&
86
+ prevProps.isSelected === nextProps.isSelected &&
87
+ prevProps.isDefaultPinned === nextProps.isDefaultPinned &&
88
+ prevProps.isPinnable === nextProps.isPinnable &&
89
+ prevProps.lastColumnId === nextProps.lastColumnId &&
90
+ prevProps.columnFilterEl === nextProps.columnFilterEl &&
91
+ prevProps.onColumnSort === nextProps.onColumnSort &&
92
+ prevProps.onColumnPin === nextProps.onColumnPin &&
93
+ prevProps.onColumnClick === nextProps.onColumnClick &&
94
+ prevProps.onFilterOpen === nextProps.onFilterOpen &&
95
+ prevProps.onFilterClose === nextProps.onFilterClose &&
96
+ JSON.stringify(prevProps.pinnedColumns) === JSON.stringify(nextProps.pinnedColumns) &&
97
+ JSON.stringify(prevProps.columnsSorting) === JSON.stringify(nextProps.columnsSorting));
53
98
  }
54
- export default memo(SheetViewTableHeaderCell);
99
+ export default memo(SheetViewTableHeaderCell, areEqual);
@@ -8,26 +8,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { memo } from 'react';
11
+ import { memo, useCallback, useMemo } from 'react';
12
12
  import InfiniteLoader from 'react-window-infinite-loader';
13
13
  import AutoSizer from 'react-virtualized-auto-sizer';
14
14
  import { SHEET_VIEW_TABLE_LIST_OVER_SCAN } from '../../../../constants/index.js';
15
15
  import ListItemWrapper from '../../components/virtualScroll/ListItemWrapper';
16
16
  import { StyledVirtualList } from '../../components/style';
17
17
  function VirtualTable({ columnsData, itemCount, lastItemIndex, areAllRowsLoaded, loadMoreItems, threshold, getItemSize, getItemData, isPinned, fixedWidth, scrollToIndex, areTotalRowsNotFillingHeight, clearBackdropVisibilityTimeout, onScroll, setBackdropVisibility, listRef, overscanCount = SHEET_VIEW_TABLE_LIST_OVER_SCAN, }) {
18
- const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
18
+ const handleOnLoadMoreItems = useCallback(() => __awaiter(this, void 0, void 0, function* () {
19
19
  if (areAllRowsLoaded)
20
20
  return;
21
21
  yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
22
- });
23
- return (_jsx(InfiniteLoader, Object.assign({ isItemLoaded: (index) => index !== lastItemIndex, itemCount: itemCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref }, { children: ({ height, width }) => {
24
- const itemSize = (index) => getItemSize(index, height);
25
- const itemData = getItemData(columnsData, isPinned, height);
26
- return (_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: fixedWidth || width, itemCount: itemCount, itemSize: itemSize, itemData: itemData, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: {
27
- overflowX: isPinned ? 'hidden' : 'auto',
28
- paddingBottom: isPinned ? '25px' : '13px',
29
- backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
30
- } }, { children: ListItemWrapper })));
31
- } }))) })));
22
+ }), [areAllRowsLoaded, loadMoreItems]);
23
+ const isItemLoaded = useCallback((index) => index !== lastItemIndex, [lastItemIndex]);
24
+ const listStyle = useMemo(() => ({
25
+ overflowX: isPinned ? 'hidden' : 'auto',
26
+ paddingBottom: isPinned ? '25px' : '13px',
27
+ backgroundColor: isPinned ? 'transparent' : '#F6F8FACC',
28
+ }), [isPinned]);
29
+ return (_jsx(InfiniteLoader, Object.assign({ isItemLoaded: isItemLoaded, itemCount: itemCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(AutoSizer, Object.assign({ ref: ref }, { children: ({ height, width }) => (_jsx(MemoizedVirtualList, { listRef: listRef, height: height, width: fixedWidth || width, itemCount: itemCount, getItemSize: getItemSize, getItemData: getItemData, columnsData: columnsData, isPinned: isPinned, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, listStyle: listStyle })) }))) })));
32
30
  }
31
+ const MemoizedVirtualList = memo(function MemoizedVirtualList({ listRef, height, width, itemCount, getItemSize, getItemData, columnsData, isPinned, onItemsRendered, overscanCount, setBackdropVisibility, scrollToIndex, areTotalRowsNotFillingHeight, onScroll, clearBackdropVisibilityTimeout, listStyle, }) {
32
+ const itemSize = useCallback((index) => getItemSize(index, height), [getItemSize, height]);
33
+ const itemData = useMemo(() => getItemData(columnsData, isPinned, height), [getItemData, columnsData, isPinned, height]);
34
+ return (_jsx(StyledVirtualList, Object.assign({ listRef: listRef, height: height, width: width, itemCount: itemCount, itemSize: itemSize, itemData: itemData, onItemsRendered: onItemsRendered, overscanCount: overscanCount, setBackdropVisibility: setBackdropVisibility, scrollToIndex: scrollToIndex, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, useIsScrolling: true, onScroll: onScroll, clearBackdropVisibilityTimeout: clearBackdropVisibilityTimeout, style: listStyle }, { children: ListItemWrapper })));
35
+ });
33
36
  export default memo(VirtualTable);