@tap-payments/os-micro-frontend-shared 0.0.257 → 0.0.258-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.
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
+ ```
@@ -5,6 +5,6 @@ interface MenuProps extends PopperProps {
5
5
  children: ReactNode;
6
6
  popperSx?: SxProps<Theme>;
7
7
  }
8
- declare function Menu({ open, anchorEl, children, sx, placement, popperSx }: MenuProps): import("react/jsx-runtime").JSX.Element;
8
+ declare function Menu({ open, anchorEl, children, sx, placement, popperSx, ...props }: MenuProps): import("react/jsx-runtime").JSX.Element;
9
9
  declare const _default: import("react").MemoExoticComponent<typeof Menu>;
10
10
  export default _default;
@@ -1,8 +1,20 @@
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
13
  import { memo } from 'react';
3
14
  import Popper from '@mui/material/Popper';
4
15
  import { Dropdown } from './style';
5
- function Menu({ open, anchorEl, children, sx, placement, popperSx }) {
6
- return (_jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: placement || 'bottom-start', sx: popperSx }, { children: _jsx(Dropdown, Object.assign({ sx: sx }, { children: children })) }), "menu"));
16
+ function Menu(_a) {
17
+ var { open, anchorEl, children, sx, placement, popperSx } = _a, props = __rest(_a, ["open", "anchorEl", "children", "sx", "placement", "popperSx"]);
18
+ return (_jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: placement || 'bottom-start', sx: popperSx }, props, { children: _jsx(Dropdown, Object.assign({ className: "MuiPopper-dropdown", sx: sx }, { children: children })) }), "menu"));
7
19
  }
8
20
  export default memo(Menu);
@@ -13,7 +13,11 @@ interface SheetViewTableHeaderProps {
13
13
  lastColumnId?: string | null;
14
14
  selectedColumn?: string | null;
15
15
  onColumnClick?: (columnId: string, event: React.MouseEvent) => void;
16
+ openFilterColumnId?: string | null;
17
+ filterAnchorEl?: HTMLElement | null;
18
+ onFilterOpen?: (columnId: string, anchorEl: HTMLElement) => void;
19
+ onFilterClose?: () => void;
16
20
  }
17
- declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
21
+ declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, openFilterColumnId: externalOpenFilterColumnId, filterAnchorEl: externalFilterAnchorEl, onFilterOpen: externalOnFilterOpen, onFilterClose: externalOnFilterClose, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
18
22
  declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeader>;
19
23
  export default _default;
@@ -6,22 +6,44 @@ import { columnIcon, pinIcon, sortAzIcon, sortZaIcon, unpinIcon } from '../../..
6
6
  import ColumnFilter from '../components/ColumnFilter';
7
7
  import { StyledCell } from '../style';
8
8
  import { ActionIcon, ColumnIcon, PinIconContainer, StyledHeader, StyledMUITableRow, HeaderText } from './style';
9
- function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
10
- const [anchorEl, setAnchorEl] = useState(null);
11
- const open = Boolean(anchorEl);
9
+ function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, openFilterColumnId: externalOpenFilterColumnId, filterAnchorEl: externalFilterAnchorEl, onFilterOpen: externalOnFilterOpen, onFilterClose: externalOnFilterClose, }) {
10
+ const [sortAnchorEl, setSortAnchorEl] = useState(null);
11
+ const sortOpen = Boolean(sortAnchorEl);
12
+ const [internalOpenFilterColumnId, setInternalOpenFilterColumnId] = useState(null);
13
+ const [internalFilterAnchorEl, setInternalFilterAnchorEl] = useState(null);
14
+ const openFilterColumnId = externalOpenFilterColumnId !== undefined ? externalOpenFilterColumnId : internalOpenFilterColumnId;
15
+ const filterAnchorEl = externalFilterAnchorEl !== undefined ? externalFilterAnchorEl : internalFilterAnchorEl;
12
16
  const theme = useTheme();
13
- const handleClick = (event) => {
14
- setAnchorEl(event.currentTarget);
17
+ const handleSortClick = (event) => {
18
+ setSortAnchorEl(event.currentTarget);
15
19
  };
16
- const handleClose = () => {
17
- setAnchorEl(null);
20
+ const handleSortClose = () => {
21
+ setSortAnchorEl(null);
22
+ };
23
+ const handleFilterOpen = (columnId) => (event) => {
24
+ if (externalOnFilterOpen) {
25
+ externalOnFilterOpen(columnId, event.currentTarget);
26
+ }
27
+ else {
28
+ setInternalOpenFilterColumnId(columnId);
29
+ setInternalFilterAnchorEl(event.currentTarget);
30
+ }
31
+ };
32
+ const handleFilterClose = () => {
33
+ if (externalOnFilterClose) {
34
+ externalOnFilterClose();
35
+ }
36
+ else {
37
+ setInternalOpenFilterColumnId(null);
38
+ setInternalFilterAnchorEl(null);
39
+ }
18
40
  };
19
41
  const handleSortingOption = (columnId, order) => {
20
42
  if (columnId) {
21
43
  onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
22
44
  [columnId]: order,
23
45
  });
24
- handleClose();
46
+ handleSortClose();
25
47
  }
26
48
  };
27
49
  const handlePinClick = (columnId) => {
@@ -45,27 +67,32 @@ function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort
45
67
  const isPinned = pinnedColumns.includes(id);
46
68
  const isDefaultPinned = !!column.isDefaultPinned;
47
69
  const isSelected = selectedColumn === id;
48
- return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event), sx: Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: isSelected ? '2px solid #1F88D0' : '1px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', height: isSelected ? '100%' : 'auto', minHeight: isSelected ? '28px' : 'auto' }, headerStyle) }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter)), sortable && _jsx(ColumnIcon, { onClick: sortable ? handleClick : undefined, src: columnIcon, alt: "column-icon", "data-id": id }), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
70
+ return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event), sx: Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: isSelected ? '2px solid #1F88D0' : '1px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', height: isSelected ? '100%' : 'auto', minHeight: isSelected ? '28px' : 'auto' }, headerStyle) }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && (_jsx(ColumnFilter, Object.assign({}, filter, { externalAnchorEl: openFilterColumnId === id ? filterAnchorEl : null, externalOpen: openFilterColumnId === id, onExternalOpen: handleFilterOpen(id), onExternalClose: handleFilterClose }))), sortable && (_jsx(ColumnIcon, { onClick: sortable
71
+ ? (event) => {
72
+ event.stopPropagation();
73
+ handleSortClick(event);
74
+ }
75
+ : undefined, src: columnIcon, alt: "column-icon", "data-id": id })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
49
76
  event.stopPropagation();
50
77
  handlePinClick(id);
51
78
  }, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] }), `${id}-${colIndex}`));
52
- }) })), _jsx(Dropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: [
79
+ }) })), _jsx(Dropdown, { open: sortOpen, onClose: handleSortClose, anchorEl: sortAnchorEl, menuItems: [
53
80
  {
54
81
  label: 'Sort A-Z',
55
82
  name: 'asc',
56
83
  icon: _jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }),
57
- selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc',
84
+ selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id) || '']) === 'asc',
58
85
  onClick: () => {
59
- handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc');
86
+ handleSortingOption(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id, 'asc');
60
87
  },
61
88
  },
62
89
  {
63
90
  label: 'Sort Z-A',
64
91
  name: 'desc',
65
92
  icon: _jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }),
66
- selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc',
93
+ selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id) || '']) === 'desc',
67
94
  onClick: () => {
68
- handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc');
95
+ handleSortingOption(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id, 'desc');
69
96
  },
70
97
  },
71
98
  ] })] })));
@@ -50,20 +50,31 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
50
50
  const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
51
51
  const [selectedCell, setSelectedCell] = useState(null);
52
52
  const [selectedColumn, setSelectedColumn] = useState(null);
53
+ const [openFilterColumnId, setOpenFilterColumnId] = useState(null);
54
+ const [filterAnchorEl, setFilterAnchorEl] = useState(null);
53
55
  const handleCellClick = useCallback((rowIndex, columnId, event) => {
54
56
  event.stopPropagation();
55
57
  const cellKey = `${rowIndex}-${columnId}`;
56
58
  setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
57
59
  setSelectedColumn(null);
58
60
  }, []);
61
+ const handleFilterOpen = useCallback((columnId, anchorEl) => {
62
+ setOpenFilterColumnId(columnId);
63
+ setFilterAnchorEl(anchorEl);
64
+ }, []);
65
+ const handleFilterClose = useCallback(() => {
66
+ setOpenFilterColumnId(null);
67
+ setFilterAnchorEl(null);
68
+ }, []);
59
69
  const handleColumnClick = useCallback((columnId, event) => {
60
70
  event.stopPropagation();
61
- if (event.target !== event.currentTarget) {
62
- return;
71
+ const column = orderedColumns.find((col) => col.id === columnId);
72
+ if (column === null || column === void 0 ? void 0 : column.filter) {
73
+ handleFilterOpen(columnId, event.currentTarget);
63
74
  }
64
75
  setSelectedColumn((prev) => (prev === columnId ? null : columnId));
65
76
  setSelectedCell(null);
66
- }, []);
77
+ }, [orderedColumns, handleFilterOpen]);
67
78
  const onPointerDown = (e) => {
68
79
  dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
69
80
  };
@@ -131,13 +142,13 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
131
142
  const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
132
143
  if (columnsData.length === 0)
133
144
  return null;
134
- 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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
145
+ 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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick, openFilterColumnId: openFilterColumnId, filterAnchorEl: filterAnchorEl, onFilterOpen: handleFilterOpen, onFilterClose: handleFilterClose })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
135
146
  width: '100%',
136
147
  minWidth: 'fit-content',
137
148
  overflowX: 'hidden',
138
149
  } }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_PinnedStyledBox", hidePadding: true, className: "list-wrapper" }, { children: createVirtualTableContainer(columnsData, containerKey, true, columnsWidth) })) }))] })) }));
139
150
  };
140
- return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, { children: [showNoDataView ? (_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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: _jsx(TableWrapper, Object.assign({ isSheetView: true, "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: _jsx(TableNoData, { error: error, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }) })) }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [renderPinnedColumn('start', pinnedStartColumnsData, pinnedStartColumnsWidth, pinnedStartColumns), _jsx(MainTableWrapper, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0 }, { 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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, 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: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
151
+ return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, { children: [showNoDataView ? (_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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: _jsx(TableWrapper, Object.assign({ isSheetView: true, "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: _jsx(TableNoData, { error: error, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }) })) }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [renderPinnedColumn('start', pinnedStartColumnsData, pinnedStartColumnsWidth, pinnedStartColumns), _jsx(MainTableWrapper, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0 }, { 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-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, 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: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick, openFilterColumnId: openFilterColumnId, filterAnchorEl: filterAnchorEl, onFilterOpen: handleFilterOpen, onFilterClose: handleFilterClose }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
141
152
  width: '100%',
142
153
  minWidth: 'fit-content',
143
154
  } }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper" }, { children: createVirtualTableContainer(unpinnedColumnsData, 'scrollable', false) })) }))] })) })) })), renderPinnedColumn('end', pinnedEndColumnsData, pinnedEndColumnsWidth, [...pinnedStartColumns, ...pinnedEndColumns])] })), !showNoDataView && areTotalRowsNotFillingHeight && !isFetchingNextPage && (_jsx(TableLastItem, { height: (itemsCount + 1) * TABLE_ROW_HEIGHT, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, "data-testid": "SheetViewVirtualTable_TableLastItem" }))] }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
@@ -1,5 +1,11 @@
1
- /// <reference types="react" />
1
+ import { MouseEvent } from 'react';
2
2
  import { IColumnFilter } from '../../../../types/index.js';
3
- declare function ColumnFilter(filter: IColumnFilter): import("react/jsx-runtime").JSX.Element;
3
+ type ColumnFilterProps = IColumnFilter & {
4
+ externalAnchorEl?: HTMLElement | null;
5
+ externalOpen?: boolean;
6
+ onExternalOpen?: (event: MouseEvent<HTMLElement>) => void;
7
+ onExternalClose?: () => void;
8
+ };
9
+ declare function ColumnFilter(props: ColumnFilterProps): import("react/jsx-runtime").JSX.Element;
4
10
  declare const _default: import("react").MemoExoticComponent<typeof ColumnFilter>;
5
11
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo, useMemo, useState } from 'react';
2
+ import { memo, useMemo, useState, useCallback } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import ClickAwayListener from '@mui/material/ClickAwayListener';
5
5
  import Popper from '@mui/material/Popper';
@@ -8,50 +8,62 @@ import Inputs from './Inputs';
8
8
  import List from './List';
9
9
  import { FilterWrapper } from './style';
10
10
  import CustomBackdrop from '../../../CustomBackdrop';
11
- function ColumnFilter(filter) {
12
- const [anchorEl, setAnchorEl] = useState(null);
11
+ function ColumnFilter(props) {
12
+ const { externalAnchorEl, externalOpen, onExternalOpen, onExternalClose } = props;
13
+ const [internalAnchorEl, setInternalAnchorEl] = useState(null);
14
+ const anchorEl = externalAnchorEl !== undefined ? externalAnchorEl : internalAnchorEl;
15
+ const open = externalOpen !== undefined ? externalOpen : Boolean(internalAnchorEl);
13
16
  const openDropdown = (event) => {
14
- setAnchorEl(event.currentTarget);
15
- };
16
- const onCloseDropdown = () => {
17
- setAnchorEl(null);
17
+ if (onExternalOpen) {
18
+ onExternalOpen(event);
19
+ }
20
+ else {
21
+ setInternalAnchorEl(event.currentTarget);
22
+ }
18
23
  };
19
- const filterData = useMemo(() => { var _a; return ((_a = filter === null || filter === void 0 ? void 0 : filter.options) === null || _a === void 0 ? void 0 : _a.reduce((acc, { apiKey }) => { var _a; return (Object.assign(Object.assign({}, acc), { [apiKey]: (_a = filter === null || filter === void 0 ? void 0 : filter.data) === null || _a === void 0 ? void 0 : _a[apiKey] })); }, {})) || {}; }, [filter]);
24
+ const onCloseDropdown = useCallback(() => {
25
+ if (onExternalClose) {
26
+ onExternalClose();
27
+ }
28
+ else {
29
+ setInternalAnchorEl(null);
30
+ }
31
+ }, [onExternalClose]);
32
+ const filterData = useMemo(() => { var _a; return ((_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.reduce((acc, { apiKey }) => { var _a; return (Object.assign(Object.assign({}, acc), { [apiKey]: (_a = props === null || props === void 0 ? void 0 : props.data) === null || _a === void 0 ? void 0 : _a[apiKey] })); }, {})) || {}; }, [props]);
20
33
  const listFilterData = useMemo(() => {
21
34
  var _a;
22
- const listFilter = filter;
35
+ const listFilter = props;
23
36
  const rawData = (_a = listFilter === null || listFilter === void 0 ? void 0 : listFilter.data) === null || _a === void 0 ? void 0 : _a[listFilter.apiKey];
24
37
  return Array.isArray(rawData) ? rawData : [];
25
- }, [filter]);
38
+ }, [props]);
26
39
  const showClearIcon = useMemo(() => Object.values(filterData || {}).some((value) => {
27
40
  if (typeof value === 'string' || Array.isArray(value))
28
41
  return value.length > 0;
29
42
  return Boolean(value);
30
43
  }) || listFilterData.length > 0, [filterData, listFilterData]);
31
- const open = Boolean(anchorEl);
32
44
  const filterApiKeys = useMemo(() => {
33
45
  var _a;
34
- if (filter.type === 'list') {
35
- return [filter.apiKey];
46
+ if (props.type === 'list') {
47
+ return [props.apiKey];
36
48
  }
37
- return (_a = ((filter === null || filter === void 0 ? void 0 : filter.options) || [])) === null || _a === void 0 ? void 0 : _a.map(({ apiKey }) => apiKey);
38
- }, [filter]);
49
+ return (_a = ((props === null || props === void 0 ? void 0 : props.options) || [])) === null || _a === void 0 ? void 0 : _a.map(({ apiKey }) => apiKey);
50
+ }, [props]);
39
51
  const renderFilter = useMemo(() => {
40
- if (filter.type === 'list')
41
- return _jsx(List, { onCloseDropdown: onCloseDropdown, filter: filter });
42
- if (filter.type === 'inputs')
43
- return _jsx(Inputs, { onCloseDropdown: onCloseDropdown, filter: filter });
44
- if (filter.type === 'custom') {
52
+ if (props.type === 'list')
53
+ return _jsx(List, { onCloseDropdown: onCloseDropdown, filter: props });
54
+ if (props.type === 'inputs')
55
+ return _jsx(Inputs, { onCloseDropdown: onCloseDropdown, filter: props });
56
+ if (props.type === 'custom') {
45
57
  const componentSharedProps = {
46
58
  anchorEl,
47
- setAnchorEl,
59
+ setAnchorEl: externalAnchorEl !== undefined ? undefined : setInternalAnchorEl,
48
60
  };
49
- return filter.render(componentSharedProps);
61
+ return props.render(componentSharedProps);
50
62
  }
51
63
  return null;
52
- }, [open, filter, anchorEl, setAnchorEl]);
64
+ }, [props, anchorEl, externalAnchorEl, setInternalAnchorEl, onCloseDropdown]);
53
65
  return (_jsx(ClickAwayListener, Object.assign({ onClickAway: onCloseDropdown }, { children: _jsxs(Box, Object.assign({ component: "section", "data-testid": "ColumnFilter", sx: { position: 'relative', display: 'flex', alignItems: 'center' } }, { children: [showClearIcon ? (_jsxs(FilterWrapper, { children: [_jsx(Box, { component: "img", "data-testid": "ColumnFilter_whiteFilterIcon", src: whiteFilterIcon, alt: "filter-icon", sx: { marginInlineEnd: '2px', height: 6 }, onClick: openDropdown }), _jsx(Box, { component: "img", "data-testid": "ColumnFilter_closeIcon", src: closeIcon, alt: "close-icon", onClick: () => {
54
- filter.onClear(filterApiKeys);
66
+ props.onClear(filterApiKeys);
55
67
  } })] })) : (_jsx(Box, { component: "img", "data-testid": "ColumnFilter_columnIcon", src: columnIcon, alt: "column-icon", sx: { cursor: 'pointer', marginTop: '2px' }, onClick: openDropdown })), open && _jsx(CustomBackdrop, { onClick: onCloseDropdown }), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-start", sx: {
56
68
  zIndex: 9999,
57
69
  } }, { children: renderFilter }))] })) })));
@@ -41,45 +41,70 @@ const StyledMUITableRow = styled(MUITableRow, {
41
41
  paddingBlock: 0,
42
42
  }))));
43
43
  function TableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, isSheetView }) {
44
- const [anchorEl, setAnchorEl] = useState(null);
45
- const open = Boolean(anchorEl);
44
+ const [sortAnchorEl, setSortAnchorEl] = useState(null);
45
+ const sortOpen = Boolean(sortAnchorEl);
46
+ const [openFilterColumnId, setOpenFilterColumnId] = useState(null);
47
+ const [filterAnchorEl, setFilterAnchorEl] = useState(null);
46
48
  const theme = useTheme();
47
- const handleClick = (event) => {
48
- setAnchorEl(event.currentTarget);
49
+ const handleSortClick = (event) => {
50
+ setSortAnchorEl(event.currentTarget);
49
51
  };
50
- const handleClose = () => {
51
- setAnchorEl(null);
52
+ const handleColumnHeaderClick = (event, column) => {
53
+ if (column.filter) {
54
+ setOpenFilterColumnId(column.id);
55
+ setFilterAnchorEl(event.currentTarget);
56
+ return;
57
+ }
58
+ if (column.sortable) {
59
+ setSortAnchorEl(event.currentTarget);
60
+ }
61
+ };
62
+ const handleFilterOpen = (columnId) => (event) => {
63
+ setOpenFilterColumnId(columnId);
64
+ setFilterAnchorEl(event.currentTarget);
65
+ };
66
+ const handleFilterClose = () => {
67
+ setOpenFilterColumnId(null);
68
+ setFilterAnchorEl(null);
69
+ };
70
+ const handleSortClose = () => {
71
+ setSortAnchorEl(null);
52
72
  };
53
73
  const handleSortingOption = (columnId, order) => {
54
74
  if (columnId) {
55
75
  onColumnSort === null || onColumnSort === void 0 ? void 0 : onColumnSort({
56
76
  [columnId]: order,
57
77
  });
58
- handleClose();
78
+ handleSortClose();
59
79
  }
60
80
  };
61
81
  return (_jsxs(StyledHeader, Object.assign({ component: "nav", "data-testid": "VirtualTable_TableHeader_StyledHeader", showBackDrop: showBackDrop }, headerProps, { sx: Object.assign({ width: '100%', minWidth: 'auto', overflowX: 'scroll' }, headerProps === null || headerProps === void 0 ? void 0 : headerProps.sx) }, { children: [_jsx(StyledMUITableRow, Object.assign({ component: "section", "data-testid": "VirtualTable_TableHeader_StyledMUITableRow", isSheetView: isSheetView }, { children: columns.map((column, colIndex) => {
62
82
  const { header, id, align, headerStyle, sortable, filter } = column;
63
83
  const isFirst = id === columns[0].id;
64
84
  const isLast = id === columns[columns.length - 1].id;
65
- return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: isFirst, isLast: isLast, sx: Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', fontWeight: 600 }, headerStyle), isSheetView: isSheetView }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter)), sortable && _jsx(ColumnIcon, { onClick: sortable ? handleClick : undefined, src: columnIcon, alt: "column-icon", "data-id": id })] }), `${id}-${colIndex}`));
66
- }) })), _jsx(Dropdown, { open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: [
85
+ return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: isFirst, isLast: isLast, onClick: (event) => handleColumnHeaderClick(event, column), sx: Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', fontWeight: 600, cursor: column.filter || column.sortable ? 'pointer' : 'default' }, headerStyle), isSheetView: isSheetView }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && (_jsx(ColumnFilter, Object.assign({}, filter, { externalAnchorEl: openFilterColumnId === id ? filterAnchorEl : null, externalOpen: openFilterColumnId === id, onExternalOpen: handleFilterOpen(id), onExternalClose: handleFilterClose }))), sortable && (_jsx(ColumnIcon, { onClick: sortable
86
+ ? (event) => {
87
+ event.stopPropagation();
88
+ handleSortClick(event);
89
+ }
90
+ : undefined, src: columnIcon, alt: "column-icon", "data-id": id }))] }), `${id}-${colIndex}`));
91
+ }) })), _jsx(Dropdown, { open: sortOpen, onClose: handleSortClose, anchorEl: sortAnchorEl, menuItems: [
67
92
  {
68
93
  label: 'Sort A-Z',
69
94
  name: 'asc',
70
95
  icon: _jsx(ActionIcon, { src: sortAzIcon, alt: "sort-icon" }),
71
- selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'asc',
96
+ selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id) || '']) === 'asc',
72
97
  onClick: () => {
73
- handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'asc');
98
+ handleSortingOption(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id, 'asc');
74
99
  },
75
100
  },
76
101
  {
77
102
  label: 'Sort Z-A',
78
103
  name: 'desc',
79
104
  icon: _jsx(ActionIcon, { src: sortZaIcon, alt: "sort-icon" }),
80
- selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id) || '']) === 'desc',
105
+ selected: (columnsSorting === null || columnsSorting === void 0 ? void 0 : columnsSorting[(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id) || '']) === 'desc',
81
106
  onClick: () => {
82
- handleSortingOption(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.dataset.id, 'desc');
107
+ handleSortingOption(sortAnchorEl === null || sortAnchorEl === void 0 ? void 0 : sortAnchorEl.dataset.id, 'desc');
83
108
  },
84
109
  },
85
110
  ] })] })));
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.0.257",
5
- "testVersion": 2,
4
+ "version": "0.0.258-test.3",
5
+ "testVersion": 3,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -131,4 +131,4 @@
131
131
  "publishConfig": {
132
132
  "registry": "https://registry.npmjs.org/"
133
133
  }
134
- }
134
+ }