@tap-payments/os-micro-frontend-shared 0.1.18 → 0.1.20-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +5 -4
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/SheetViewTableHeader.d.ts +1 -18
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/SheetViewTableHeader.js +3 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/TableCell.d.ts +2 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/TableCell.js +4 -4
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/type.d.ts +7 -4
- package/build/components/VirtualTables/components/TableRow.d.ts +1 -1
- package/build/components/VirtualTables/components/TableRow.js +5 -4
- package/build/utils/columns.d.ts +5 -0
- package/build/utils/columns.js +10 -0
- package/build/utils/index.d.ts +0 -1
- package/build/utils/index.js +0 -1
- package/package.json +3 -3
- package/build/utils/TableColumn.d.ts +0 -6
- package/build/utils/TableColumn.js +0 -10
|
@@ -51,15 +51,16 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
51
51
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
52
52
|
const [selectedCell, setSelectedCell] = useState(null);
|
|
53
53
|
const [selectedColumn, setSelectedColumn] = useState(null);
|
|
54
|
-
const handleCellClick = useCallback((rowIndex,
|
|
54
|
+
const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
|
|
55
55
|
event.stopPropagation();
|
|
56
|
-
const cellKey = `${rowIndex}-${
|
|
56
|
+
const cellKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${rowIndex}-${columnIndex}`;
|
|
57
57
|
setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
|
|
58
58
|
setSelectedColumn(null);
|
|
59
59
|
}, []);
|
|
60
|
-
const handleColumnClick = useCallback((
|
|
60
|
+
const handleColumnClick = useCallback((columnIndex, event, pinnedType) => {
|
|
61
61
|
event.stopPropagation();
|
|
62
|
-
|
|
62
|
+
const columnKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${columnIndex}`;
|
|
63
|
+
setSelectedColumn((prev) => (prev === columnKey ? null : columnKey));
|
|
63
64
|
setSelectedCell(null);
|
|
64
65
|
}, []);
|
|
65
66
|
const onPointerDown = (e) => {
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import type { IColumnProps, IVirtualTable, TablePosition } from '../../../../../types/index.js';
|
|
4
|
-
interface SheetViewTableHeaderProps {
|
|
5
|
-
columns: IColumnProps[];
|
|
6
|
-
headerProps?: TableHeadProps;
|
|
7
|
-
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
8
|
-
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
9
|
-
showBackDrop: boolean;
|
|
10
|
-
pinnedColumns?: string[];
|
|
11
|
-
onColumnPin?: (columnId: string, position: 'start' | 'end' | 'unpin') => void;
|
|
12
|
-
isPinnable?: boolean;
|
|
13
|
-
lastColumnId?: string | null;
|
|
14
|
-
selectedColumn?: string | null;
|
|
15
|
-
onColumnClick?: (columnId: string, event: React.MouseEvent) => void;
|
|
16
|
-
tablePosition?: TablePosition;
|
|
17
|
-
hasPinnedStart?: boolean;
|
|
18
|
-
hasPinnedEnd?: boolean;
|
|
19
|
-
}
|
|
2
|
+
import { SheetViewTableHeaderProps } from './type';
|
|
20
3
|
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
4
|
declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeader>;
|
|
22
5
|
export default _default;
|
|
@@ -4,7 +4,9 @@ import { StyledHeader, StyledMUITableRow } from '../../style';
|
|
|
4
4
|
import TableCell from './TableCell';
|
|
5
5
|
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
6
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
|
-
|
|
7
|
+
var _a;
|
|
8
|
+
const columnKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${colIndex}`;
|
|
9
|
+
return (_jsx(TableCell, { 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}`));
|
|
8
10
|
}) })) })));
|
|
9
11
|
}
|
|
10
12
|
export default memo(SheetViewTableHeader);
|
|
@@ -3,11 +3,12 @@ import type { IColumnProps } from '../../../../../types/index.js';
|
|
|
3
3
|
import { SheetViewTableHeaderProps } from './type';
|
|
4
4
|
interface TableCellProps extends Pick<SheetViewTableHeaderProps, 'onColumnSort' | 'columnsSorting' | 'onColumnPin' | 'isPinnable' | 'lastColumnId' | 'onColumnClick' | 'pinnedColumns'> {
|
|
5
5
|
column: IColumnProps;
|
|
6
|
+
colIndex: number;
|
|
6
7
|
isFirst: boolean;
|
|
7
8
|
isLast: boolean;
|
|
8
9
|
isSelected: boolean;
|
|
9
10
|
isDefaultPinned: boolean;
|
|
10
11
|
}
|
|
11
|
-
declare function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order }, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, tableViewId, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
declare const _default: import("react").MemoExoticComponent<typeof TableCell>;
|
|
13
14
|
export default _default;
|
|
@@ -6,7 +6,7 @@ import ColumnFilter from '../../../components/ColumnFilter';
|
|
|
6
6
|
import { StyledCell } from '../../../components/style';
|
|
7
7
|
import { PinIconContainer, HeaderText } from '../../style';
|
|
8
8
|
import ColumnSort from '../../../../VirtualTables/components/ColumnSort';
|
|
9
|
-
function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order }, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }) {
|
|
9
|
+
function TableCell({ column: { header, id, align, headerStyle, sortable, filter, pinnable, width, order, tableViewId, pinned }, colIndex, isFirst, isLast, isSelected, isDefaultPinned, onColumnSort, columnsSorting, onColumnPin, isPinnable, lastColumnId, onColumnClick, pinnedColumns, }) {
|
|
10
10
|
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
11
11
|
const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
|
|
12
12
|
const isPinned = useMemo(() => checkIsPanned(id), [id, checkIsPanned]);
|
|
@@ -24,7 +24,7 @@ function TableCell({ column: { header, id, align, headerStyle, sortable, filter,
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": id, "data-column-width": width, "data-column-width-used": width, "data-column-align": align, "data-column-order": order, "data-column-header": typeof header === 'string' ? header : 'component', "data-column-sortable": !!sortable, "data-column-filterable": !!filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => {
|
|
27
|
-
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(
|
|
27
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, event, pinned);
|
|
28
28
|
setColumnFilterEl(event.currentTarget);
|
|
29
29
|
}, sx: (theme) => (Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: isSelected ? '1px solid #1F88D0' : '1px solid #F2F2F2', backgroundColor: isSelected ? '#F2F2F2' : '#FCFCFC', minHeight: isSelected ? '28px' : 'auto', position: 'relative', '&:before': {
|
|
30
30
|
content: '""',
|
|
@@ -35,9 +35,9 @@ function TableCell({ column: { header, id, align, headerStyle, sortable, filter,
|
|
|
35
35
|
left: 0,
|
|
36
36
|
bottom: 0,
|
|
37
37
|
} }, headerStyle)) }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && _jsx(HeaderText, Object.assign({ "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header })) }))), filter && (_jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl, onClose: (event) => {
|
|
38
|
-
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(
|
|
38
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, event, pinned);
|
|
39
39
|
} }))), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
40
|
-
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(
|
|
40
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
|
|
41
41
|
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
42
42
|
event.stopPropagation();
|
|
43
43
|
handlePinClick(id);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import { IColumnProps, IVirtualTable } from '../../../../../types/index.js';
|
|
2
|
+
import { type TableHeadProps } from '@mui/material/TableHead';
|
|
3
|
+
import { IColumnProps, IVirtualTable, TablePosition } from '../../../../../types/index.js';
|
|
4
4
|
export interface SheetViewTableHeaderProps {
|
|
5
5
|
columns: IColumnProps[];
|
|
6
|
-
headerProps?:
|
|
6
|
+
headerProps?: TableHeadProps;
|
|
7
7
|
columnsSorting?: IVirtualTable['columnsSorting'];
|
|
8
8
|
onColumnSort?: IVirtualTable['onColumnSort'];
|
|
9
9
|
showBackDrop: boolean;
|
|
@@ -12,5 +12,8 @@ export interface SheetViewTableHeaderProps {
|
|
|
12
12
|
isPinnable?: boolean;
|
|
13
13
|
lastColumnId?: string | null;
|
|
14
14
|
selectedColumn?: string | null;
|
|
15
|
-
onColumnClick?: (
|
|
15
|
+
onColumnClick?: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
|
|
16
|
+
tablePosition?: TablePosition;
|
|
17
|
+
hasPinnedStart?: boolean;
|
|
18
|
+
hasPinnedEnd?: boolean;
|
|
16
19
|
}
|
|
@@ -13,7 +13,7 @@ interface ITableRowProps<R = any> {
|
|
|
13
13
|
isSheetView?: boolean;
|
|
14
14
|
selectedCell?: string | null;
|
|
15
15
|
selectedColumn?: string | null;
|
|
16
|
-
onCellClick?: (rowIndex: number,
|
|
16
|
+
onCellClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
|
|
17
17
|
isLastRow?: boolean;
|
|
18
18
|
}
|
|
19
19
|
declare function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell, selectedColumn, onCellClick, isLastRow, }: Readonly<ITableRowProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,10 +14,11 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
|
|
|
14
14
|
return render ? render({ row, column, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : _jsx(_Fragment, { children: formattedValue });
|
|
15
15
|
};
|
|
16
16
|
const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
|
|
17
|
-
|
|
18
|
-
const cellKey = `${index}-${
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const cellKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${index}-${colIndex}`;
|
|
19
19
|
const isCellSelected = selectedCell === cellKey;
|
|
20
|
-
const
|
|
20
|
+
const columnKey = `${(_b = column.pinned) !== null && _b !== void 0 ? _b : 'default'}-${colIndex}`;
|
|
21
|
+
const isColumnSelected = selectedColumn === columnKey;
|
|
21
22
|
const isSelected = isCellSelected || isColumnSelected;
|
|
22
23
|
const selectionStyles = getSelectionStyles({
|
|
23
24
|
isSelected,
|
|
@@ -33,7 +34,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
|
|
|
33
34
|
effectiveFirst = isFirstColumn && column.pinned !== 'start';
|
|
34
35
|
effectiveLast = isLastColumn && column.pinned !== 'end';
|
|
35
36
|
}
|
|
36
|
-
return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "TableRow_TableCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: effectiveFirst, isLast: effectiveLast, onClick: (event) => onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index,
|
|
37
|
+
return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "TableRow_TableCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: effectiveFirst, isLast: effectiveLast, onClick: (event) => onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned), sx: Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: renderCell(column) }), `${column.id}-${colIndex}`));
|
|
37
38
|
}) })), [columns, row, index, selectedCell, selectedColumn, onCellClick, isLastRow]);
|
|
38
39
|
return (_createElement(StyledTableRow, Object.assign({ "data-testid": "TableRow", onClick: rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick, showShadowHighlight: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showShadowHighlight, showLoadedStyle: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showLoadedStyle, component: "article" }, rowProps, { key: index, isSheetView: isSheetView }), content));
|
|
39
40
|
}
|
package/build/utils/columns.d.ts
CHANGED
|
@@ -9,3 +9,8 @@ export declare function filterShownColumns<T>(columns: Array<IColumnProps<T & {
|
|
|
9
9
|
export declare function isParameterSelected(columns: ColumnViewProps[], columnId: string, parameter: string): boolean;
|
|
10
10
|
export declare function mapDataToViews(columnData?: ColumnsView[], language?: string): ColumnViewProps[];
|
|
11
11
|
export declare function mapViewsToData(columns: ColumnViewProps[]): ColumnsView[];
|
|
12
|
+
export declare const updateColumnSelection: ({ columnsViewData, columnName, selected, }: {
|
|
13
|
+
columnsViewData: ColumnsView[];
|
|
14
|
+
columnName: string;
|
|
15
|
+
selected: boolean;
|
|
16
|
+
}) => ColumnsView[];
|
package/build/utils/columns.js
CHANGED
|
@@ -65,3 +65,13 @@ export function mapViewsToData(columns) {
|
|
|
65
65
|
};
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
export const updateColumnSelection = ({ columnsViewData, columnName, selected, }) => {
|
|
69
|
+
return columnsViewData.map((column) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const columnText = (_b = (_a = column.name[0]) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
72
|
+
if (columnText === columnName.toLowerCase()) {
|
|
73
|
+
return Object.assign(Object.assign({}, column), { selected });
|
|
74
|
+
}
|
|
75
|
+
return column;
|
|
76
|
+
});
|
|
77
|
+
};
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.20-test.1",
|
|
5
|
+
"testVersion": 1,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -131,4 +131,4 @@
|
|
|
131
131
|
"publishConfig": {
|
|
132
132
|
"registry": "https://registry.npmjs.org/"
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const updateColumnSelection = ({ columnsViewData, columnName, selected, }) => {
|
|
2
|
-
return columnsViewData.map((column) => {
|
|
3
|
-
var _a, _b;
|
|
4
|
-
const columnText = (_b = (_a = column.name[0]) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
5
|
-
if (columnText === columnName.toLowerCase()) {
|
|
6
|
-
return Object.assign(Object.assign({}, column), { selected });
|
|
7
|
-
}
|
|
8
|
-
return column;
|
|
9
|
-
});
|
|
10
|
-
};
|