@tap-payments/os-micro-frontend-shared 0.1.21 → 0.1.22
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/StatusBar/StatusBar.js +12 -7
- package/build/components/StatusBar/index.d.ts +1 -1
- package/build/components/StatusBar/type.d.ts +7 -2
- package/build/components/StatusBar/type.js +6 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeader/TableCell.js +12 -15
- package/build/components/VirtualTables/components/TableHeader/components/TableCell/TableCell.js +5 -7
- package/build/components/VirtualTables/components/style.d.ts +0 -3
- package/build/components/VirtualTables/components/style.js +0 -6
- package/package.json +1 -1
|
@@ -36,18 +36,23 @@ function StatusBar({ isFilteredIdsShown, onStatusChange, availableStatuses, stat
|
|
|
36
36
|
}
|
|
37
37
|
} })));
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
if (!s.status)
|
|
40
|
+
return null;
|
|
41
|
+
const formattedStatuses = (s.status.map((item) => (typeof item === 'string' ? { value: item } : item)).filter(Boolean) ||
|
|
42
|
+
[]);
|
|
43
|
+
const isCurrentStatusDropdown = !isMultiSelection && !!status && formattedStatuses.some((item) => (item === null || item === void 0 ? void 0 : item.value) === status);
|
|
40
44
|
const variant = isCurrentStatusDropdown ? 'active' : 'inActive';
|
|
41
|
-
const statusLabel = isCurrentStatusDropdown && !isMultiSelection ? status :
|
|
45
|
+
const statusLabel = isCurrentStatusDropdown && !isMultiSelection ? status : (_b = formattedStatuses[0]) === null || _b === void 0 ? void 0 : _b.value;
|
|
42
46
|
return (_jsx("div", { children: _jsx(StatusButton, Object.assign({}, s, { label: t(statusLabel || ''), variant: variant, onButtonBodyClick: (buttonStatus) => {
|
|
43
47
|
handleStatusChange(buttonStatus);
|
|
44
|
-
}, dropdownOptions:
|
|
45
|
-
label: t(stat || ''),
|
|
48
|
+
}, dropdownOptions: formattedStatuses.map((stat) => ({
|
|
49
|
+
label: t((stat === null || stat === void 0 ? void 0 : stat.value) || ''),
|
|
46
50
|
onClick: () => {
|
|
47
|
-
handleStatusChange(stat);
|
|
51
|
+
handleStatusChange(stat.value);
|
|
48
52
|
},
|
|
49
|
-
status: stat,
|
|
50
|
-
|
|
53
|
+
status: stat === null || stat === void 0 ? void 0 : stat.value,
|
|
54
|
+
icon: stat.icon,
|
|
55
|
+
})) })) }, (_c = formattedStatuses[0]) === null || _c === void 0 ? void 0 : _c.value));
|
|
51
56
|
}) }));
|
|
52
57
|
}
|
|
53
58
|
export default memo(StatusBar);
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StatusButtonProps } from '../StatusButton';
|
|
3
3
|
import { TableHeaderStatus } from '../../types/index.js';
|
|
4
|
+
export type DetailedStatusItem<T> = {
|
|
5
|
+
value: T extends Array<unknown> ? T[number] : T;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
};
|
|
4
8
|
export type AvailableStatus<T extends TableHeaderStatus | TableHeaderStatus[] = undefined> = StatusButtonProps & {
|
|
5
|
-
status?: T;
|
|
9
|
+
status?: T | DetailedStatusItem<T>[];
|
|
6
10
|
render?: <IStatus extends T>(controls: {
|
|
7
11
|
status: IStatus;
|
|
8
|
-
onChange: (selected?:
|
|
12
|
+
onChange: (selected?: T) => void;
|
|
9
13
|
}, options?: Omit<AvailableStatus<T>, 'render'> & {
|
|
10
14
|
index: number;
|
|
11
15
|
}) => React.ReactNode;
|
|
12
16
|
};
|
|
17
|
+
export type TerminalStatus = 'ACTIVE' | 'INACTIVE' | 'DEACTIVATED' | 'FAULTY' | 'CANCELLED' | 'ARCHIVED' | (string & {});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useCallback, useMemo,
|
|
2
|
+
import { memo, useCallback, useMemo, useState } 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
|
-
import { StyledCell
|
|
6
|
+
import { StyledCell } from '../../../components/style';
|
|
7
7
|
import { PinIconContainer, HeaderText } from '../../style';
|
|
8
8
|
import ColumnSort from '../../../../VirtualTables/components/ColumnSort';
|
|
9
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
|
-
const cellRef = useRef(null);
|
|
12
11
|
const checkIsPanned = useCallback((columnId) => pinnedColumns === null || pinnedColumns === void 0 ? void 0 : pinnedColumns.includes(columnId), [pinnedColumns]);
|
|
13
12
|
const isPinned = useMemo(() => checkIsPanned(id), [id, checkIsPanned]);
|
|
14
13
|
const handlePinClick = (columnId) => {
|
|
@@ -24,11 +23,9 @@ function TableCell({ column: { header, id, align, headerStyle, sortable, filter,
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
setColumnFilterEl(cellRef.current);
|
|
29
|
-
};
|
|
30
|
-
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: (event) => {
|
|
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) => {
|
|
31
27
|
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, event, pinned);
|
|
28
|
+
setColumnFilterEl(event.currentTarget);
|
|
32
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': {
|
|
33
30
|
content: '""',
|
|
34
31
|
border: isSelected ? '1px solid #1F88D0' : '1px solid transparent',
|
|
@@ -37,13 +34,13 @@ function TableCell({ column: { header, id, align, headerStyle, sortable, filter,
|
|
|
37
34
|
right: 0,
|
|
38
35
|
left: 0,
|
|
39
36
|
bottom: 0,
|
|
40
|
-
} }, headerStyle)) }, { children:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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(colIndex, event, pinned);
|
|
39
|
+
} }))), sortable && (_jsx(ColumnSort, { columnId: id, onColumnSort: onColumnSort, columnsSorting: columnsSorting, onClick: (e) => {
|
|
40
|
+
onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(colIndex, e, pinned);
|
|
41
|
+
} })), isPinnable && pinnable && !isDefaultPinned && !isLast && (_jsx(PinIconContainer, Object.assign({ onClick: (event) => {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
handlePinClick(id);
|
|
44
|
+
}, title: isPinned ? 'Unpin column' : 'Pin column' }, { children: _jsx("img", { src: isPinned ? unpinIcon : pinIcon, alt: "pin-icon" }) })))] })));
|
|
48
45
|
}
|
|
49
46
|
export default memo(TableCell);
|
package/build/components/VirtualTables/components/TableHeader/components/TableCell/TableCell.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import Box from '@mui/material/Box';
|
|
4
4
|
import ColumnFilter from '../../../../../VirtualTables/components/ColumnFilter';
|
|
5
5
|
import ColumnSort from '../../../../../VirtualTables/components/ColumnSort';
|
|
6
|
-
import { StyledCell
|
|
6
|
+
import { StyledCell } from '../../../../../VirtualTables/components/style';
|
|
7
7
|
export function TableCell({ column: { header, id, align, headerStyle, sortable, filter, width, order }, isFirst, isLast, isSheetView, onColumnSort, columnsSorting, }) {
|
|
8
8
|
const [columnFilterEl, setColumnFilterEl] = useState(null);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
return (_jsx(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": id, "data-column-width": width, "data-column-width-used": width, "data-column-align": align, "data-column-order": order, "data-column-header": typeof header === 'string' ? header : 'component', "data-column-sortable": !!sortable, "data-column-filterable": !!filter, isFirst: isFirst, isLast: isLast, ref: cellRef, sx: (theme) => (Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: width, textAlign: align, overflow: 'unset', fontWeight: 600 }, headerStyle)), isSheetView: isSheetView }, { children: _jsxs(TableHeaderInner, Object.assign({ onClick: onOpenFilterDropdown }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && _jsx(ColumnSort, { onColumnSort: onColumnSort, columnsSorting: columnsSorting, columnId: id })] })) })));
|
|
9
|
+
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "VirtualTable_TableHeader_StyledCell", "data-column-id": id, "data-column-width": width, "data-column-width-used": width, "data-column-align": align, "data-column-order": order, "data-column-header": typeof header === 'string' ? header : 'component', "data-column-sortable": !!sortable, "data-column-filterable": !!filter, isFirst: isFirst, isLast: isLast, onClick: (event) => {
|
|
10
|
+
setColumnFilterEl(event.currentTarget);
|
|
11
|
+
}, sx: (theme) => (Object.assign({ paddingInline: '0.6875rem', paddingLeft: isFirst ? '0' : '0.6875rem', paddingRight: isLast ? '0' : '0.6875rem', display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: width, textAlign: align, overflow: 'unset', fontWeight: 600 }, headerStyle)), isSheetView: isSheetView }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "TableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "VirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter, { anchorEl: columnFilterEl, setAnchorEl: setColumnFilterEl })), sortable && _jsx(ColumnSort, { onColumnSort: onColumnSort, columnsSorting: columnsSorting, columnId: id })] })));
|
|
14
12
|
}
|
|
@@ -19,9 +19,6 @@ export declare const StyledCell: import("@emotion/styled").StyledComponent<impor
|
|
|
19
19
|
isSheetView?: boolean | undefined;
|
|
20
20
|
isSelected?: boolean | undefined;
|
|
21
21
|
}, {}, {}>;
|
|
22
|
-
export declare const TableHeaderInner: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
23
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
24
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
25
22
|
interface StyledVirtualListProps {
|
|
26
23
|
areTotalRowsNotFillingHeight: boolean;
|
|
27
24
|
isSheetView?: boolean;
|
|
@@ -49,12 +49,6 @@ export const StyledCell = styled(TableCell, {
|
|
|
49
49
|
},
|
|
50
50
|
}));
|
|
51
51
|
});
|
|
52
|
-
export const TableHeaderInner = styled(Box)(({ theme }) => ({
|
|
53
|
-
zIndex: 1,
|
|
54
|
-
display: 'flex',
|
|
55
|
-
gap: theme.spacing(0.5),
|
|
56
|
-
alignItems: 'center',
|
|
57
|
-
}));
|
|
58
52
|
export const StyledVirtualList = styled(VirtualScrollList, {
|
|
59
53
|
shouldForwardProp: (prop) => !['areTotalRowsNotFillingHeight', 'isSheetView'].includes(prop),
|
|
60
54
|
})(({ theme, areTotalRowsNotFillingHeight, isSheetView }) => (Object.assign({ backgroundColor: areTotalRowsNotFillingHeight ? 'transparent' : theme.palette.background.default }, (isSheetView && {
|
package/package.json
CHANGED